Skip to content

fix core - #155

Merged
chuandew merged 2 commits into
dingodb:mainfrom
visualYJD:yjd-dev
Jul 20, 2026
Merged

chuandew merged 2 commits into
dingodb:mainfrom
visualYJD:yjd-dev

Conversation

@visualYJD

Copy link
Copy Markdown
Contributor

No description provided.

…rship

A zero-delay retry round (txn_resolved_lock_retry_delay_ms=0) cleared
rpcs_/controllers_ while the previous round's issuing loop and rpc
callback chains were still on other threads' stacks, freeing objects
under them. Recycled same-size allocations let late writes corrupt the
new round's controller region_, crashing in Region::IsStale (MDS core).

- Add StoreRpcRound<RpcT>: each round's rpcs/controllers/pending are
  owned by the AsyncCall callbacks via shared_ptr, so a new round can
  never free state a previous round still uses.
- Completion barrier: pending = rpcs + 1; the issuing DoAsync frame
  releases the extra count after its last task-state access, so the
  task cannot complete (and be destroyed) under that frame.
- Guard region_id_to_resolved_lock_ writes with rw_lock_.
- Harden brpc/grpc OnRpcDone: move the callback onto the stack before
  invoking; nothing may touch rpc members after it runs.
Apply the StoreRpcRound pattern from TxnBatchGetTask to TxnPrewriteTask
and TxnCommitTask: per-round rpcs/controllers owned by the AsyncCall
callbacks, pending = rpcs + 1 with the extra count released by the
issuing DoAsync frame, and every completion path routed through
FinishSubTask. This removes the cross-round clear() UAF and stops the
task completing (and being destroyed) under a live issuing frame -- the
races TSan reported in PrimaryKeyLockConflict and CommitSencondError
(including a heap-use-after-free on the callback-owned commit task).

Add TSan-verified regression tests for both paths. The full txn suite
under TSan now reports 0 issues (was 79). Timer reports in the
std::thread actuator are pre-existing, break TSan's happens-before
tracking downstream, and are suppressed with a note; they need a
separate fix.
@chuandew
chuandew added this pull request to the merge queue Jul 20, 2026
Merged via the queue into dingodb:main with commit ce218f1 Jul 20, 2026
1 check passed
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.

2 participants