Skip to content

v4: transactions honour PreferReplica, escalate for primary-only work, and are profiled (port of #3381) - #3404

Merged
mgravell merged 1 commit into
v4from
marc/v4-transaction-routing-profiling
Dec 3, 2026
Merged

mgravell merged 1 commit into
v4from
marc/v4-transaction-routing-profiling

Conversation

@mgravell

@mgravell mgravell commented Dec 3, 2026

Copy link
Copy Markdown
Member

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

Change

  • RoutingFlags: route with the caller's primary/replica preference, but use DemandMaster when any queued command is primary-only. DemandReplica is left alone, so it still fails the same way, as in main. Queued operations now record their Command, which the check reads.
  • RespExecOperation carries a profiling record the way RespPayloadOperation does (Diagnostics.HostState, stamped on sent, response and finish). SendRun starts it as EXEC, with the caller's flags and the run's database. The queued commands themselves stay unprofiled. StartProfile now takes a small IProfiledOperation view, because the two operation types share no non-generic base that exposes Diagnostics.
  • 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, HighIntegrityWireTests and SanityChecks pass on net10.0 (562 tests, 7 skipped). On net481, QueuedResultTests.RetryTransactionFireAndForgetSharesOneCompletedTask fails, and fails the same way on plain v4; that's #3402.

…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.
@mgravell
mgravell merged commit 9404aa4 into v4 Dec 3, 2026
4 of 5 checks passed
@mgravell
mgravell deleted the marc/v4-transaction-routing-profiling branch December 3, 2026 16:01
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