Move set_last_complete AFTER rsync.
authorMartin Pihlak <martin.pihlak@gmail.com>
Wed, 24 Oct 2012 11:03:50 +0000 (14:03 +0300)
committerMartin Pihlak <martin.pihlak@gmail.com>
Wed, 24 Oct 2012 11:03:50 +0000 (14:03 +0300)
Previously .walshipping.last was updated before the rsync succeeded,
it turns out that this was too optimistic -- occasionally the rsync
fails and the .last file contains wrong information. This results
in skipped files during "master sync".

python/walmgr.py

index 604ba6913e36f40e50b98e2e419661e02c727277..830e0e1a401d93943a2f51b5d9274f51ac5ca41e 100755 (executable)
@@ -1502,7 +1502,6 @@ STOP TIME: %(stop_time)s
         self.log.debug("%s: start copy", srcname)
         
         self.master_periodic()
-        self.set_last_complete(srcname)
         
         dst_loc = self.cf.getfile("completed_wals")
         if dst_loc[-1] != "/":
@@ -1517,6 +1516,9 @@ STOP TIME: %(stop_time)s
         cmdline = ["ssh", "-nT", slave, "sync" ]
         self.exec_cmd(cmdline)
 
+       # slave has the file now, set markers
+        self.set_last_complete(srcname)
+
         self.log.debug("%s: done", srcname)
         end_time = time.time()
         self.stat_add('count', 1)