We should run checkpoint before shutdown all the time except one case

(when patroni is being shutdown)
This commit is contained in:
Alexander Kukushkin
2016-03-24 14:50:34 +01:00
parent e6af18f0bb
commit 9c41ce9f1c
2 changed files with 5 additions and 4 deletions
+1 -1
View File
@@ -85,5 +85,5 @@ def main():
pass
finally:
patroni.api.shutdown()
patroni.postgresql.stop()
patroni.postgresql.stop(checkpoint=False)
patroni.dcs.delete_leader()
+4 -3
View File
@@ -388,7 +388,7 @@ class Postgresql(object):
except psycopg2.Error:
logging.exception('Exception during CHECKPOINT')
def stop(self, mode='fast', block_callbacks=False):
def stop(self, mode='fast', block_callbacks=False, checkpoint=True):
# make sure we close all connections established against
# the former node, otherwise, we might get a stalled one
# after kill -9, which would report incorrect data to
@@ -400,9 +400,10 @@ class Postgresql(object):
self.set_state('stopped')
return True
if block_callbacks:
if checkpoint:
self.checkpoint()
else:
if not block_callbacks:
self.set_state('stopping')
ret = subprocess.call(self._pg_ctl + ['stop', '-m', mode]) == 0