Repository navigation
v4: queued transaction tasks - no bridge for the retry proxy; tests wait rather than peek (#3402's example) - #3405
Merged
Conversation
…ait for queued tasks rather than peek A queued command's task in v4 is completed off the reader, through the thread pool, so it can trail ExecuteAsync by a moment - unlike v3, which set every queued task complete before EXEC's result. Awaiting is unaffected; IsCompleted straight after ExecuteAsync is not. That is the race behind #3402's example, which net481 reproduced on every run. - RespRetryTransactionExecutor notes its proxy task (NoteDispatchedTask), so TaskBridge returns it as-is rather than wrapping it in a second completion source completed from a pool continuation. - QueuedResultTests: RetryTransactionFireAndForgetSharesOneCompletedTask waits, bounded, instead of asserting IsCompleted; QueuedTaskCompletesPromptlyAfterExecute covers plain and retry transactions, with and without an async state. - docs/Transactions.md: fetch queued results by awaiting, not by peeking; note the change from v3.
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.
Fixes the example in #3402:
QueuedResultTests.RetryTransactionFireAndForgetSharesOneCompletedTask, which flaked on Ubuntu CI and failed on every local run on net481. The wider sweep in #3402 stays open.Cause
In v4, a queued command's
Taskis completed off the reader thread, through the thread pool, so a caller's continuation never runs on the reader. For a transaction,EXEC's reply settles every queued operation on the reader, and each one queues the completion of itsTask. ThenEXECcompletes, and the caller'sawait tran.ExecuteAsync()resumes, also through the pool. Nothing orders the two, so a queuedTaskcan still be incomplete for a moment afterExecuteAsyncreturns.v3 differs: it set every queued
Taskcomplete beforeEXEC's result, and only the continuations went to the pool. Awaiting can't tell the difference. CheckingIsCompletedstraight afterExecuteAsynccan, and that's what the test did. Restoring v3's ordering would mean deferring task completion intoExecuteAsync. That isn't worth it for a gap only visible to code that peeks, so the tests change instead, and the docs say how to fetch results.Change
RespRetryTransactionExecutornotes its proxy task (NoteDispatchedTask), as the batch executor does.TaskBridgethen hands that task back as it is. Before, it wrapped the task in a second completion source, completed from a continuation the proxy queues to the pool: one extra allocation per queued command, and an extra hop.QueuedResultTests:RetryTransactionFireAndForgetSharesOneCompletedTasknow waits for the queued task, with a timeout, instead of assertingIsCompleted. It usesWhenAnybecause theGETfaults withWRONGTYPE: the test's ownHSETmade the key a hash.QueuedTaskCompletesPromptlyAfterExecutecovers plain and retry transactions, with and without an async state.docs/Transactions.md: fetch queued results by awaiting orWait-ing, not by peeking atIsCompleted, with a note that this differs from earlier versions.Tests
QueuedResultTests,RetryEndToEndTestsandTransactionTests, three runs each on net10.0 and net481: 528 tests per run, none failed.