Skip to content

Rotation live tests wait for the logging collector to write a burst before asserting on it - #4707

Merged
erikdarlingdata merged 1 commit into
devfrom
fix/4704-rotation-test-read-poll
Sep 29, 2026
Merged

erikdarlingdata merged 1 commit into
devfrom
fix/4704-rotation-test-read-poll

Conversation

@erikdarlingdata

Copy link
Copy Markdown
Owner

Rotation live tests wait for the logging collector to write a burst before asserting on it.

Why

PgServerLogTailRotationLiveTests.ALogThatGrewPastTheWindow_DisclosesTheBytesSkipped_AndCollectsTheLastWindow failed once in CI (Darling PG tests shard 1, run for #4706 at 1954b70, 2026-09-29): Assert.Equal(1, Count(cycle.Rows, pid)) got 0. The test RAISEs about 6.5 MB of LOG lines, logs its marker, then reads once. PostgreSQL's logging collector writes from a pipe asynchronously, so right after a multi-MB burst the marker line can still be unwritten when the read runs. The product read is not at fault; the test read too early.

Change (test files only)

  • PgServerLogTailRotationLiveTests: a CycleUntilLoggedAsync helper repeats ONE logical read (the same carried state on every attempt, never advanced) every 500 ms until the marker's pid is in the rows, for up to 30 s, and on the deadline fails naming the pid, the file read, the attempts, the rows and the bytes skipped. The grew-past-the-window test uses it; both of its assertions are unchanged (bytes skipped > 0, and the marker counted exactly once, so a retry cannot hide a duplicate).
  • PgLogBurstAndRotationLiveTests: the same wait, as a predicate helper, before the single-file 500-deadlock burst's assertions (waits for the newest deadlock's tag; Rows.Count == 500 unchanged) and before the csv quoted multi-line record's first cycle (waits for the record's tag; exactly-once unchanged).
  • Checked and left alone: the next-offset test (it asserts only on the offset and a later file size, and accepts any complete prefix), the rotation, missing-file and recycled-file tests (no large burst; RotateAsync already waits), PgServerLogTailCsvJsonRotationLiveTests (small RAISEs only) and PgDeadlocksResumeLiveTests (already polls for the new file).

Verification

  • Darling.Tests Release build: 0 warnings.
  • The two changed classes plus DocCommentHygieneTests, three runs on local stderr, csvlog and jsonlog targets configured like the CI clusters: 92 tests each run, 0 failed, 0 skipped.
  • The flake did not reproduce locally; the CI failure above is the observed failure.

CHANGELOG

None: test-only.

@erikdarlingdata
erikdarlingdata marked this pull request as ready for review September 29, 2026 04:20
@erikdarlingdata
erikdarlingdata merged commit cdc8d7d into dev Sep 29, 2026
15 of 16 checks passed
@erikdarlingdata
erikdarlingdata deleted the fix/4704-rotation-test-read-poll branch September 29, 2026 04:21
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.

1 participant