Repository navigation
v4: transactions honour PreferReplica, escalate for primary-only work, and are profiled (port of #3381) - #3404
Merged
Conversation
…mary-only work, and are profiled as EXEC Port of main #3381 by intent. RespTransaction resolved its target with no flags, so every transaction went to the primary: a read-only transaction sent with PreferReplica never reached a replica. It now routes with the caller's preference, and goes to the primary when any queued command is primary-only (DemandReplica is left alone, as in main). Queued operations now record their command, which the escalation reads. The transaction is also profiled again, as one EXEC record, which is what the v3 core reported; the v4 run was unprofiled. RespExecOperation carries the record the way RespPayloadOperation does, through a small IProfiledOperation view of Diagnostics.HostState.
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.
Ports main's #3381 to v4 by intent, and fixes two v4 transaction gaps its tests exposed. Part of absorbing main's 3.5.0 (see #3403).
Problem
RespTransaction.ExecuteAsyncresolved its target withCommandFlags.None, so every transaction went to the primary. Send a transaction to the primary when it has primary-only work and the caller prefers a replica #3381's bug (primary-only work sent to a replica underPreferReplica) couldn't happen here, but neither could the intended behaviour: a read-only transaction sent withPreferReplicanever reached a replica, unlike main.SendRunwith profiling off, so a profiling session saw nothing for a transaction. A comment there said that was how it always was, but v3 reports the transaction as oneEXECrecord (its transaction is a single message whose command isEXEC), and Send a transaction to the primary when it has primary-only work and the caller prefers a replica #3381's tests rely on that.Change
RoutingFlags: route with the caller's primary/replica preference, but useDemandMasterwhen any queued command is primary-only.DemandReplicais left alone, so it still fails the same way, as in main. Queued operations now record theirCommand, which the check reads.RespExecOperationcarries a profiling record the wayRespPayloadOperationdoes (Diagnostics.HostState, stamped on sent, response and finish).SendRunstarts it asEXEC, with the caller's flags and the run's database. The queued commands themselves stay unprofiled.StartProfilenow takes a smallIProfiledOperationview, because the two operation types share no non-generic base that exposesDiagnostics.RespPayloadOperation's declaration was indented 8 spaces; it's now 4, which StyleCop requires once the file declares a second type.Tests
#3381's two tests come over unchanged and pass. Before this change, both failed on v4.
TransactionTests,ProfilingTests,QueuedResultTests,MultiMessageInTransactionTests,LockingTests,RetryEndToEndTests,RetryGuardTests,HighIntegrityWireTestsandSanityCheckspass on net10.0 (562 tests, 7 skipped). On net481,QueuedResultTests.RetryTransactionFireAndForgetSharesOneCompletedTaskfails, and fails the same way on plain v4; that's #3402.