Skip to content

Fix the partition lookahead test for runs in the 00:00 UTC hour - #5971

Merged
warwickschroeder merged 1 commit into
masterfrom
john/partition_midnight_test
Oct 13, 2026
Merged

warwickschroeder merged 1 commit into
masterfrom
john/partition_midnight_test

Conversation

@johnsimons

@johnsimons johnsimons commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

PartitioningTests.Setup_provisions_whole_days_through_the_lookahead fails whenever the PostgreSQL audit persistence tests run between 00:00 and 00:59 UTC. CI run 37861906054 failed on Linux-PostgreSql and Windows-PostgreSql, in both attempts, with Expected: greater than or equal to 2026-10-11 00:00:57.538, But was: 2026-10-11 00:00:00.

Cause

Setup truncates the current time to the hour and provisions whole-day partitions through that hour plus AuditHours.Lookahead (48 hours). In the 00:00 hour, the hour plus 48 hours lands exactly on a day boundary, so the last partition ends there. The test compared the end of the provisioned range with the untruncated time plus 48 hours, which can be up to an hour later. In every other hour, rounding up to whole days leaves enough slack to hide the difference.

Change

The test now compares against AuditHours.Truncate(now) + AuditHours.Lookahead, the bound setup uses. Provisioning is unchanged.

Why the fix is in the test

At 00:59, setup leaves 47 hours of partitions ahead, which does not put ingestion at risk:

  • ingestion only needs a partition for the current hour;
  • the retention sweep provisions partitions every hour, so the window is back to 71 hours at 01:00;
  • AuditPartitionCustomCheck fails only when less than 12 hours remain.

Extending the window would provision an extra day for one hour in every 24 and change none of the above.

Testing

  • Reproduced the CI failure by seeding the fixture clock at 2026-10-09T00:00:57.538Z.
  • ServiceControl.Audit.Persistence.Tests.PostgreSql, Release: 75/75 with the clock seeded at 00:00:57, and 75/75 on the real clock.
  • PartitioningTests with the clock seeded at 00:59:59.999, 01:00:00 and 23:59:59.999.

…hour

The test compared partition bounds to the raw current time, but provisioning
works off hour-truncated timestamps. Near an hour boundary (especially
midnight) this mismatch could make the assertions fail intermittently.
@johnsimons johnsimons self-assigned this Oct 9, 2026
@johnsimons johnsimons changed the title Fix flaky partitioning test by truncating the comparison time to the hour Fix the partition lookahead test for runs in the 00:00 UTC hour Oct 9, 2026
@warwickschroeder
warwickschroeder merged commit a41d9a8 into master Oct 13, 2026
69 of 70 checks passed
@warwickschroeder
warwickschroeder deleted the john/partition_midnight_test branch October 13, 2026 04:17
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.

3 participants