Repository navigation
Description
QueuedResultTests.RetryTransactionFireAndForgetSharesOneCompletedTask (RESP2) failed once on the Ubuntu job of #3399 (run, first attempt), and passed on re-run with no change:
var pending = tran.StringGetAsync(key);
Assert.False(pending.IsCompleted);
Assert.True(await tran.ExecuteAsync());
Assert.True(pending.IsCompleted); // QueuedResultTests.cs:160 - failedThe retry transaction settles its proxies before ExecuteAsync returns, but they are RunContinuationsAsynchronously, and the task the test holds sits a layer above the proxy, so "complete by the time the other await resumes" is a timing assumption rather than a guarantee. The test is at fault, not the library: it should wait for the task it is asserting on, with a short bound so a genuine hang still fails fast, e.g.
Assert.True(pending.Wait(TimeSpan.FromSeconds(5))); // or: await pending.WaitAsync(timeout)TransactionTests already does the right thing (await Task.WhenAll(a, b, ...) before checking IsCompleted).
The sweep
This is one example; the same shape is worth checking across the suite. Roughly 50 assertions inspect task state directly (IsCompleted, IsCompletedSuccessfully, IsFaulted, IsCanceled). They fall into three groups:
- Synchronous completion is the contract under test: fire-and-forget returning a completed task, empty-input short-circuits (
SetPopAsync(count: 0)and friends), cache hits, the blocking context, the fakes inRespSurfaceTests/RespRetryExecutorTests. These must stay as they are; turning them into waits would hide the regression they exist to catch. - Already safe: the check follows an
awaitof the same task (PubSubTests,RetryGuardTests,TransactionTests), or a bounded poll (ConfigurationChannelUnitTests). - Racy: "it completed because something else did". The check follows an await of a different task, or a fixed delay.
QueuedResultTests.cs:160is the confirmed one;Issues/Issue1101Tests(first.Completion.IsCompletedafter unsubscribe +Task.Delay(200)) looks like another candidate. These should wait on the task itself, with a bound.
The mirror image applies too: Assert.False(x.IsCompleted) is only sound when nothing could have completed it yet (no reply has been fed, or the test is asserting it stays incomplete for a bounded wait, as InertClusterNodeUnitTests does).
Activity
mgravell commentedon Dec 3, 2026
This one reproduces every time locally on net481, against plain
v4(607caaf):RetryTransactionFireAndForgetSharesOneCompletedTask (RESP2), line 160, each run. net10.0 passes. So net481 is a reliable way to check a fix.mgravell commentedon Dec 3, 2026
Another one of the same shape, from #3405's Windows job:
ClusterTopologyUnitTests.SlotLessNodesAreKnownButNotConnected(also seen once on #3399). The last line isAssert.True(api.IsConnected), straight afterawait api.PingAsync(). ThePINGhas an answer, but the endpoint'sIsConnectedis set when the connection is reported established, which can trail the first reply. It should wait on the condition, with a bound, rather than read it once.The task-completion example itself is addressed in #3405.
Retry transaction: hand back the proxy task without a bridge; tests w…
mgravell commentedon Dec 3, 2026
Another of the same shape, from #3407's Ubuntu job (passed on re-run, and 6/6 locally on both the PR branch and
v4):BacklogTests.TotalOutstandingIncludesBacklogQueue, atBacklogTests.cs:437. It assertsInteractive.TotalOutstanding == 0immediately afterawait db.PingAsync(). The awaiter sees the reply before the outstanding count is decremented, so it reads 1. It should wait for the counter to settle, with a bound, rather than read it once.