guard RefreshPeer():sync() not to insert the same record twice.
authorBarış Metin <Talip-Baris.Metin@sophia.inria.fr>
Wed, 29 Apr 2009 14:39:04 +0000 (14:39 +0000)
committerBarış Metin <Talip-Baris.Metin@sophia.inria.fr>
Wed, 29 Apr 2009 14:39:04 +0000 (14:39 +0000)
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.

PLC/Methods/RefreshPeer.py

index 4d66a05..3d48cf2 100644 (file)
@@ -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":