Repository navigation
Fix weekly retention keeping the wrong weeks - #1506
Merged
Jubilee101 merged 1 commit intoOct 30, 2026
Merged
Conversation
The retention_weeks loop in mark_retention() computed each week's target Monday by subtracting j weeks from tmp_time, but tmp_time had already been decremented by the previous iterations (and wound back to a Monday). The offset therefore accumulated (0, 1, 3, 6, 10 ... weeks back) instead of stepping one week at a time, so from the third week onward the code probed the wrong Mondays. Weekly backups the operator intended to keep matched none of those windows and were deleted. Subtract from the stable base t, matching how the months and years loops step from a fixed reference.
Member
|
Yikes, merged, thanks for your contribution~ Yes, retention is very hard to test... |
This was referenced Nov 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1505.
Problem
The
retention_weeksloop inmark_retention()(src/libpgmoneta/wf_retention.c) computed each week's target Monday by subtractingjweeks fromtmp_time, buttmp_timehad already been decremented (and wound back to a Monday) by the previous iterations. The offset accumulated0, 1, 3, 6, 10 …weeks back instead of0, 1, 2, 3, 4 …, so from the third week onward the code probed the wrong Mondays. Weekly backups the operator intended to keep matched none of those windows and were deleted.Target Mondays, base = Thu 2026-10-22:
Fix
Subtract from the stable base
tinstead of the mutatedtmp_time, matching how theretention_monthsandretention_yearsloops step from a fixed reference. One line.