-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check WAL shipping setup only in archiver mode #720
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -641,27 +641,39 @@ def check_archive(self, check_strategy): | |
of the results of the various checks | ||
""" | ||
check_strategy.init_check("WAL archive") | ||
# Make sure that WAL archiving has been setup | ||
# XLOG_DB needs to exist and its size must be > 0 | ||
# NOTE: we do not need to acquire a lock in this phase | ||
xlogdb_empty = True | ||
if os.path.exists(self.xlogdb_file_name): | ||
with open(self.xlogdb_file_name, "rb") as fxlogdb: | ||
if os.fstat(fxlogdb.fileno()).st_size > 0: | ||
xlogdb_empty = False | ||
|
||
# NOTE: This check needs to be only visible if it fails | ||
if xlogdb_empty: | ||
# Skip the error if we have a terminated backup | ||
# with status WAITING_FOR_WALS. | ||
# TODO: Improve this check | ||
backup_id = self.get_last_backup_id([BackupInfo.WAITING_FOR_WALS]) | ||
if not backup_id: | ||
check_strategy.result( | ||
self.config.name, | ||
False, | ||
hint="please make sure WAL shipping is setup", | ||
) | ||
if not os.access(self.config.wals_directory, os.W_OK): | ||
check_strategy.result( | ||
self.config.name, False, | ||
hint=f"wals_directory {self.config.wals_directory} must be writable" | ||
) | ||
return | ||
if self.config.archiver: | ||
# Make sure that WAL archiving has been setup | ||
# XLOG_DB needs to exist and its size must be > 0 | ||
# NOTE: we do not need to acquire a lock in this phase | ||
xlogdb_empty = True | ||
if os.path.exists(self.xlogdb_file_name): | ||
with open(self.xlogdb_file_name, "rb") as fxlogdb: | ||
if os.fstat(fxlogdb.fileno()).st_size > 0: | ||
xlogdb_empty = False | ||
|
||
# NOTE: This check needs to be only visible if it fails | ||
if xlogdb_empty: | ||
# Skip the error if we have a terminated backup | ||
# with status WAITING_FOR_WALS. | ||
# TODO: Improve this check | ||
backup_id = self.get_last_backup_id([BackupInfo.WAITING_FOR_WALS]) | ||
if not backup_id: | ||
check_strategy.result( | ||
self.config.name, | ||
False, | ||
hint="please make sure WAL shipping is setup", | ||
) | ||
if self.config.streaming_archiver: | ||
if not glob(os.path.join(self.config.streaming_wals_directory, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately when I suggested this check I didn't take into account the fact that the While there's still a need to improve on how Barman verifies WAL streaming is working, checking for the |
||
"*" + PARTIAL_EXTENSION)): | ||
check_strategy.result(self.config.name, False, | ||
hint="partial file should be present") | ||
|
||
# Check the number of wals in the incoming directory | ||
self._check_wal_queue(check_strategy, "incoming", "archiver") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
f
string should be fine for future Barman releases because they will require Python 3.6 as a minimum. If we did want to backport it to the 3.4.x branch then it would need to be compatible with Python 2.7 but that would be a small enough change to deal with if it came up.