Repository navigation
The wide-grid short-window pin flushes pending table stats before it counts reads - #4449
Merged
Merged
Conversation
…h timing ShortWindowRead_IssuesNoRoundTripAgainstTheWideTable counts reads with pg_stat_user_tables.seq_scan before and after the call under test. PostgreSQL throttles a backend's cumulative-stats report to once per second (PGSTAT_MIN_INTERVAL), so a seed backend's own scan against the wide table can still be pending when the "before" snapshot is taken and land only after it, producing a spurious (0,9) vs (1,9) mismatch with nothing wrong in the code under test. Force every backend that touched the table during setup to report its pending stats (pg_stat_force_next_flush()) before the "before" snapshot, and this test's own backend again before the "after" snapshot. The viewer's read runs on its own pooled data source this test cannot flush directly, so a short delay stands in for a flush there, long enough to clear the once-per-second throttle.
erikdarlingdata
marked this pull request as ready for review
September 26, 2026 20:59
erikdarlingdata
deleted the
test/qsiw-short-window-read-count-deflake
branch
September 26, 2026 21:00
9 of 10 tasks
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.
Refs #4310. Test-only; no product code touched.
Why
QueryStoreIntervalWideGridLiveTests.ShortWindowRead_IssuesNoRoundTripAgainstTheWideTableproves that ashort-window Query Store grid read issues zero round trips against
collect.query_store_interval_wide, bysnapshotting
pg_stat_user_tables.seq_scan/idx_scanbefore and after the read under test. It failed once inCI with
Expected (0, 9), Actual (1, 9)and passed on a re-run with no code change.PostgreSQL throttles a backend's cumulative-stats report to at most once per second
(
PGSTAT_MIN_INTERVAL). The test's own setup issues real scans against the wide table from a differentbackend (the seed runner's own connection). If that backend's pending report has not flushed yet when the
test takes its "before" snapshot, and flushes moments later, the "after" snapshot picks up a scan the test
under test never issued — a stats-visibility race, not a defect in the code the test exercises.
What changes
Darling/Darling.Tests/QueryStoreIntervalWideGridLiveTests.cs:(this test's own connection and the seed runner's pooled data source) to report its pending stats
immediately with
pg_stat_force_next_flush(), so "before" reflects setup's scans completely rather thana partially-flushed view of them.
still visible immediately.
pg_stat_force_next_flush()on directly. A short delay (1.1s, longer than the once-per-second throttle)stands in for a flush on that connection — the documented fallback shape for this class of flake when the
product read doesn't go through an instrumentable data source.
needed.
Test plan
Darling.TestsandLite.Testsbuild 0 errors / 0 warnings.ShortWindowRead_IssuesNoRoundTripAgainstTheWideTablerun 20 times in a loop against a freshtimescale/timescaledb:2.30.1-pg18container: 20/20 green.QueryStoreIntervalWideGridLiveTestsclass plusDocCommentHygieneTests: 81/81 green.(
windowEnd - windowStart < minWindow) withfalse, forcing a short window to route to the table. Thepin went RED (
Expected (1, 9), Actual (1, 10)), proving it still catches the bug it exists for. Reverted;clean diff confirmed against the committed source; rebuilt 0 errors.
CHANGELOG entry
SECTION: None
ENTRY: None: test-only de-flake, no user-visible effect.