Skip to content

Commit

Permalink
Warn about .partial files in the WAL archive during recovery
Browse files Browse the repository at this point in the history
Updates _xlog_copy so that special handling is only used for `.partial`
files in the streaming directory. Any `.partial` files found in the
WAL archive are handled the same way Barman would previously handle
them, i.e. they are copied across to the recovery WAL destination
(decompressing if necessary) and *not* renamed. Because this is a
situation which requires some manual intervention a warning message is
now logged to tell the user about each `.partial` WAL found in the
archive.

The user must then determine whether the `.partial` WAL in the archive
is the result of a recovery from backup or a standby promotion and, if
so, can rename the file to omit its `.partial` extension.

There is a clear opportunity for Barman to handle this itself however
this is deliberately not tackled by this patch and will instead be
added at a later date when we improve the behaviour of Barman in a
clustered environment.

Relates to #393.
  • Loading branch information
mikewallace1979 committed Oct 10, 2022
1 parent 8539e0b commit dc650f1
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion barman/recovery_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,9 +785,27 @@ def _xlog_copy(self, required_xlog_files, wal_dest, remote_command):
compression_manager = self.backup_manager.compression_manager
# Fill xlogs and compressors maps from required_xlog_files
for wal_info in required_xlog_files:
if xlog.is_partial_file(wal_info.name):
if (
xlog.is_partial_file(wal_info.name)
and hasattr(wal_info, "orig_filename")
and (
os.path.dirname(wal_info.orig_filename)
== self.config.streaming_wals_directory
)
):
# If a .partial file is in the `streaming` directory then add it to a
# separate list so it can be renamed and transferred in a separate
# Rsync operation.
partial_xlogs.append(wal_info)
else:
if xlog.is_partial_file(wal_info.name):
# If a .partial file is in the main WAL archive then either a
# standby was promoted or a primary was recovered from a backup.
# In either case we do not attempt to handle it and instead warn
# the user.
output.warning(
".partial WAL file '%s' found in WAL archive", wal_info.name
)
hashdir = xlog.hash_dir(wal_info.name)
xlogs[hashdir].append(wal_info)
# If a compressor is required, make sure it exists in the cache
Expand Down

0 comments on commit dc650f1

Please sign in to comment.