Check if .ready file exists in _archive_ready_wals (#2387)

This commit is contained in:
Polina Bungina
2022-08-18 09:07:21 +02:00
committed by GitHub
parent ae0ede6944
commit 2ee09d0a66
+3 -2
View File
@@ -346,13 +346,14 @@ class Rewind(object):
# skip fsync, as postgres --single or pg_rewind will anyway run it
for wal in sorted(wals_to_archive):
if os.path.isfile(os.path.join(self._postgresql.wal_dir, wal)):
old_name = os.path.join(status_dir, wal + '.ready')
# wal file might have alredy been archived
if os.path.isfile(old_name) and os.path.isfile(os.path.join(self._postgresql.wal_dir, wal)):
cmd = self._buid_archiver_command(archive_cmd, wal)
# it is the author of archive_command, who is responsible
# for not overriding the WALs already present in archive
logger.info('Trying to archive %s: %s', wal, cmd)
if self._postgresql.cancellable.call(shlex.split(cmd)) == 0:
old_name = os.path.join(status_dir, wal + '.ready')
new_name = os.path.join(status_dir, wal + '.done')
try:
shutil.move(old_name, new_name)