londiste copy: fix after-copy wait
authorMarko Kreen <markokr@gmail.com>
Fri, 23 Dec 2011 12:27:27 +0000 (14:27 +0200)
committerMarko Kreen <markokr@gmail.com>
Fri, 23 Dec 2011 12:27:27 +0000 (14:27 +0200)
Wait now on any non-NULL role.

The string changed in .sql but code here was not updated.
But new simpler rule is that role will be NULL it catchup
can proceed.  So follow that.

Also dont do some potentially dangerous operations (lock, drop-fkey)
on follow-up copies.

python/londiste/table_copy.py

index ee035ef1a6e82f3cd719bc56789754ade2a65dac..3c137ae62c4be42f1f1e8d9b1d1c51ea56d65aa6 100644 (file)
@@ -105,11 +105,13 @@ class CopyTable(Replicator):
 
         # just in case, drop all fkeys (in case "replay" was skipped)
         # !! this may commit, so must be done before anything else !!
-        self.drop_fkeys(dst_db, tbl_stat.dest_table)
+        if cmode > 0:
+            self.drop_fkeys(dst_db, tbl_stat.dest_table)
 
         # now start ddl-dropping tx
-        q = "lock table " + skytools.quote_fqident(tbl_stat.dest_table)
-        dst_curs.execute(q)
+        if cmode > 0:
+            q = "lock table " + skytools.quote_fqident(tbl_stat.dest_table)
+            dst_curs.execute(q)
 
         # find dst struct
         src_struct = TableStruct(src_curs, src_real_table)
@@ -179,7 +181,7 @@ class CopyTable(Replicator):
             dst_db.commit()
 
             # start waiting for other copy processes to finish
-            while tbl_stat.copy_role == 'lead':
+            while tbl_stat.copy_role:
                 self.log.info('waiting for other partitions to finish copy')
                 time.sleep(10)
                 tbl_stat = self.reload_table_stat(dst_curs, tbl_stat.name)