Skip to content

Conversation

@dverite
Copy link
Collaborator

@dverite dverite commented Mar 25, 2025

The expression -int(date.Weekday()-time.Monday) was used as an offset from today back to the previous monday. But since time.Sunday=0, it goes into the next week when run on Sunday, producing incorrect partitions bounds.

@dverite dverite added the bug Something isn't working label Mar 25, 2025
@dverite
Copy link
Collaborator Author

dverite commented Mar 25, 2025

#sre-storage

@dcupif
Copy link
Contributor

dcupif commented Mar 27, 2025

I've tested this change locally, this was indeed a nasty bug. Nice catch Daniel 👏
I believe the computation of the bounds is critical enough to add tests around it, could you please add those before releasing this change?

The expression -int(date.Weekday()-time.Monday) was used
as an offset from today back to the previous monday.
But since time.Sunday=0, it goes into the next week when
run on Sunday, producing incorrect partitions bounds.

Also add tests for partition.getWeeklyBounds()

Signed-off-by: Daniel Vérité <dverite@gmail.com>
@dverite dverite force-pushed the fix-weekly-sunday-issue branch from 6ae8558 to 0b53739 Compare March 27, 2025 17:09
@github-actions
Copy link

Code Coverage

Package Line Rate Health
github.com/qonto/postgresql-partition-manager/internal/infra/partition 6%
github.com/qonto/postgresql-partition-manager/internal/infra/postgresql 89%
github.com/qonto/postgresql-partition-manager/internal/infra/retry 100%
github.com/qonto/postgresql-partition-manager/internal/infra/uuid7 91%
github.com/qonto/postgresql-partition-manager/pkg/ppm 73%
Summary 65% (568 / 869)

Minimum allowed line rate is 60%

@dverite
Copy link
Collaborator Author

dverite commented Mar 27, 2025

Squashed the commits. It should be good to go.
#sre-storage

Copy link
Contributor

@dcupif dcupif left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@qfritz qfritz merged commit 49890e0 into main Mar 28, 2025
12 checks passed
@qfritz qfritz deleted the fix-weekly-sunday-issue branch March 28, 2025 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants