Skip to content

Record commit stats on the automatic idempotency recovery path#13388

Open
PierreZ wants to merge 1 commit into
apple:mainfrom
PierreZ:fix/idempotency-replay-commit-stats
Open

Record commit stats on the automatic idempotency recovery path#13388
PierreZ wants to merge 1 commit into
apple:mainfrom
PierreZ:fix/idempotency-replay-commit-stats

Conversation

@PierreZ

@PierreZ PierreZ commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #13038, as promised there ("Will backport it to 7.4, and do a follow-up for main"). Part of the ongoing idempotency-id stabilization work (#12344).

Background

#13038 (closes #12582) fixed a client-side gap in tryCommit: on the automatic idempotency replay path, determineCommitStatus() recovers the original commit version after commit_unknown_result, but the result was never written into trState->committedVersion, so getCommittedVersion() returned invalidVersion after a successful replay. That was a one-line fix mirroring the normal-path assignment.

While reviewing #13038 it was noted (I raised it on the PR: "did you think I should address the other gaps in the recovery path?") that the replay success block still skips the rest of the post-commit bookkeeping the normal path performs. This PR closes those remaining gaps.

Change

Extract the shared bookkeeping into a recordSuccessfulCommit() helper, called from both the normal success path and the replay path, so idempotency-recovered commits now also:

  • increment transactionsCommitCompleted (previously uncounted, which undercounts the commit-throughput view, e.g. the MovingData trace event),
  • add to transactionCommittedMutations / transactionCommittedMutationBytes,
  • refresh the cached read version (updateCachedReadVersion),
  • reset numErrors.

Intentionally left to the normal path:

  • the metadata-version cache update: the replay path's CommitResult from determineCommitStatus() carries only commitVersion and batchIndex, no metadataVersion, so there is nothing to cache there;
  • the commitLatencies / latencies histograms and the EventCommit_V2 client log: the replay path's elapsed time includes failover detection + commitDummyTransaction + the determineCommitStatus read loop, which would skew the proxy-commit-latency view.

No wire / system keyspace changes.

Test plan

  • tests/fast/AutomaticIdempotency.toml simulation (buggify on) across 10 seeds: all pass, replay path exercised 30 times total (DetermineCommitStatus Committed=1 / AutomaticIdempotencyCommitted CODE_PROBE), no IdempotencyCommitMissingVersion.
  • Joshua correctness ensemble, 1000 runs: pass, no failures.
  • CI across many seeds (requires core committer)

🤖 Generated with Claude Code

When a transaction commits via the automatic idempotency recovery path
(after commit_unknown_result, once determineCommitStatus discovers the
commit actually succeeded), tryCommit set committedVersion but skipped the
rest of the post-commit bookkeeping the normal success path performs. As a
result, idempotency-recovered commits were not counted in
transactionsCommitCompleted (undercounting the commit-throughput view), the
committed-mutation stats were undercounted, the cached read version was not
refreshed, and numErrors was not reset.

Extract the shared bookkeeping into recordSuccessfulCommit() and call it from
both the normal path and the recovery path: updateCachedReadVersion,
committedVersion, numErrors reset, transactionsCommitCompleted, and the
committed-mutation counters.

The metadata-version cache update stays inline in the normal path: it needs the
proxy reply's metadataVersion, which the recovery path's CommitResult does not
carry. The commit-latency histograms and the EventCommit_V2 client log are also
left to the normal path, since the recovery path's elapsed time includes
failover and determineCommitStatus and would skew those metrics.

Follow-up to apple#13038.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

Automatic idempotency success does not return commit version to client

1 participant