From: Barış Metin Date: Wed, 29 Apr 2009 14:39:04 +0000 (+0000) Subject: guard RefreshPeer():sync() not to insert the same record twice. X-Git-Tag: PLCAPI-4.3-13~2 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=f053ba034efef11d4435feebdc84c8022a9e76b5;p=plcapi.git guard RefreshPeer():sync() not to insert the same record twice. The problem is sync() inserts duplicated records, but when we try to insert into peer_* tables it fails for the second one. That creates strange problems like federated objects appear as local objects. We still need to find why sync is called with duplicated records but this patch should prevent the db problems. --- diff --git a/PLC/Methods/RefreshPeer.py b/PLC/Methods/RefreshPeer.py index 4d66a05..3d48cf2 100644 --- a/PLC/Methods/RefreshPeer.py +++ b/PLC/Methods/RefreshPeer.py @@ -124,6 +124,10 @@ class RefreshPeer(Method): for peer_object_id, peer_object in peer_objects.iteritems(): message_verbose ('DBG %s peer_object_id=%d (%d/%d)'%(classname,peer_object_id,count,total)) count += 1 + if peer_object_id in synced: + message("Warning: %s Skipping already added %s: %r"%( + peer['peername'], classname, peer_object)) + continue if classname == 'Node': message_verbose ('DBG>> hostname=%s'%peer_object['hostname']) elif classname == "Slice":