fix(native): dispatch txn commit batch to the owning vshard#196
Merged
farhan-syah merged 2 commits intoJul 21, 2026
Merged
Conversation
A row committed inside an explicit native-protocol transaction (Begin op, SQL DML, Commit op) was durably applied on the wrong core: the native COMMIT seam routed the commit's ResolveTxn/TransactionBatch meta-ops through the gateway, discarding the task's pre-classified vshard_id. The gateway router cannot derive a route for collection-less Meta plans and fell back to vShard 0, so the commit batch (heap put + index maintenance) landed on vShard 0's core while point lookups and index-assisted reads consulted the collection's owning vShard — the row was visible to full scans but permanently invisible to PK point lookups and filtered aggregates, across connections (NodeDB-Lab#193). NativeTxnDp::dispatch_no_wal now always dispatches through the direct write path with task.vshard_id, matching pgwire's dispatch_task_no_wal and native's own pre-gateway branch. The gateway router additionally rejects ResolveTxn/TransactionBatch plans outright instead of silently misrouting them to vShard 0. Fixes NodeDB-Lab#193
farhan-syah
requested changes
Jul 21, 2026
farhan-syah
approved these changes
Jul 21, 2026
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 #193.
Problem
A row committed inside an explicit transaction over the native binary protocol (
Beginop → SQL INSERT →Commitop) was durably stored but permanently invisible to PK point lookups and filteredcount(*)— full scans saw it, and the same SQL over pgwire was correct.Root cause (full trace in the issue comment): both transports share
run_commit→dispatch_single_shard, which builds the commit tasks (MetaOp::ResolveTxn+MetaOp::TransactionBatch) with the correctvshard_id. The pgwire seam submits them with thatvshard_id; the native seam (NativeTxnDp::dispatch_no_wal) sent them throughgw.execute(...), which dropstask.vshard_idand re-routes from the plan.MetaOpplans have no collection name, so the router'sprimary_vshardfell back to vShard 0 — the whole commit batch (row write + index maintenance) was applied on vShard 0's core instead of the collection's owning vShard.Fix
NativeTxnDp::dispatch_no_walnow always dispatches through the direct write path withtask.vshard_id, matching pgwire'sdispatch_task_no_waland native's own pre-gateway fallback branch (which was already correct).route_planrejectsResolveTxn/TransactionBatchplans with an error instead of silently misrouting them to vShard 0, so any future caller that sends a commit meta-op through the gateway fails loudly instead of corrupting placement.Tests
native_txn_commit_visibility.rs: the issue's exact repro (Begin op / INSERT / Commit op over the native wire), asserting the committed row is visible to a PK point lookup and a filteredcount(*)on the writing connection and on a fresh connection, with the full scan as control. The test wires the gateway the way production boot does and runs 4 data-plane cores with a collection homed off core 0 — reproducing the bug requires both (the default single-core, gateway-less test harness masks it; verified red before the fix, green after).commit_meta_ops_are_rejectedfor the guardrail.cargo test -p nodedbsuite passes (one pre-existing, unrelated failure onmain:shuffle_grace_infeasible_budget_is_deterministic_error, fails identically onmain @ 48281658).Notes for reviewers
dispatch_no_walcall site goes through the fixed seam.