Skip to content
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

Proof of concept fix for barman backup --wait on pg17 #1044

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cameronmurdoch
Copy link

pg_walfile_name_offset() has been changed in pg17 to return the current segment if on a segment boundary.

Implement previous_segment_name() to calulate the previous segment and use this to restore the pre pg17 behaviour.

Tested with pg16 and pg17.

pg_walfile_name_offset() has been changed in pg17 to return the current
segment if on a segment boundary.

Implement previous_segment_name() to calulate the previous segment
and use this to restore the pre pg17 behaviour.

Tested with pg16 and pg17.
Copy link
Contributor

@andremagui andremagui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The job of current_xlog_info is to get the location, file_name, file_offset and timestamp by running pg_walfile_name_offset on the pg_current_wal_lsn. This must stay as it is because we do not care about the way it handles boundaries in the property itself, but we do care about this when some part of the code is calling this property, probably.

For example, for every backup a backup_info object is created which will retain all the information needed from a backup. In that object, we have fields like end_wal, begin_wal, etc... When barman backup command is run, it calls the current_xlog_info property to populate begin_wal, end_wal, begin_lsn, end_lsn, begin_offset, end_offset.

For begin_wal, we just get the current WAL. It is unlikely to start a backup at a boundary but even if it happens, we do not want begin_wal as the previous WAL.

So, this is one reason to move away the logic from the property.

So, as a start guide, please, check the link i shared in the review message that will send you to the location where stop information is created. Also, provide or refactor unit tests for this implementation and fix possible broken tests. Lastly, see if this would need any new documentation.

result = cur.fetchone()
# pg_walfile_name_offset() in Postgres 17 returns the current segment
# if on a segment boundary so return the previous segment name in that case.
if self.server_version >= 170000 and result["file_offset"] == 00000000:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep this method unchanged and move this logic to the part of the code where the backup info is created, here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants