Skip to content

AlertReadFailureSurfaceTests.TheNewestFailuresFactsAreNeverABlendOfTwo fails when the writers finish before the reader's first check #4312

Closed

Description

@erikdarlingdata

What happened

CI failed on #4292 at 92bcaa19, in the build job's "Run Darling tests" step, with one failure:

Darling.Tests.AlertReadFailureSurfaceTests.TheNewestFailuresFactsAreNeverABlendOfTwo: "the reader observed nothing, so its silence proves nothing" (Darling/Darling.Tests/AlertReadFailureSurfaceTests.cs, line 803).

#4292 does not touch this file or AlertReadFailureCounter.

Why it fails

The test starts five writer tasks with TaskCreationOptions.LongRunning. Then it reads on the test thread:

while (!writers.All(w => w.IsCompleted))
{
    var reading = counter.ReadFor(Key);
    observations++;
    // ...
}

A while loop checks its condition before its first pass. If all five writers finish before the test thread first checks it, the body never runs, and observations stays 0. On a busy runner, the test thread can wait for a CPU while five dedicated writer threads run 200,000 iterations each.

The comment above the assert says that the seeded bucket makes one observation certain. The seed makes the first reading complete, but it does not make the loop run.

Fix

Make the loop run at least once:

do
{
    var reading = counter.ReadFor(Key);
    observations++;
    // ...
}
while (!writers.All(w => w.IsCompleted));

The seeded bucket then makes the first observation a complete trio, as the comment says. This is a change to the test only.

Activity

  1. added
    in-progressActively being worked by a local session or its agents (PR open or in flight)
    on Sep 25, 2026
  2. erikdarlingdata commented on Sep 25, 2026

    @erikdarlingdata
    OwnerAuthor

    Closed by the watcher: delivered in PR #4335, merged to dev.

  3. removed
    in-progressActively being worked by a local session or its agents (PR open or in flight)
    on Sep 25, 2026
  4. erikdarlingdata commented on Sep 25, 2026

    @erikdarlingdata
    OwnerAuthor

    Fixed by #4335, merged to dev (c48b696).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions