Skip to content

Fix issues. - #153

Closed
visualYJD wants to merge 3 commits into
dingodb:mainfrom
visualYJD:yjd-dev
Closed

visualYJD wants to merge 3 commits into
dingodb:mainfrom
visualYJD:yjd-dev

Conversation

@visualYJD

Copy link
Copy Markdown
Contributor

No description provided.

CheckTxnStatus errors were swallowed and the empty response was turned
into TxnStatus{lock_ttl=0, commit_ts=0}, which satisfies IsRollbacked().
A resolver hitting a lock whose primary prewrite was still retrying
(e.g. region epoch change backoff) treated the live txn as rolled back
and removed its secondary lock without any durable rollback record on
the primary. The writer's prewrite retry then succeeded, the async
commit point was reached and success was returned to the client, while
the background commit hit SelfRolledBack on that key: partial commit
and silent lost update.

- txn_check_status_task: restore error propagation (locked stays a
  normal state) and only fill txn_status_ from a successful response.
- ResolveLock: on TxnNotFound wait in place while the conflict lock ttl
  is alive; after ttl expiry escalate rollback_if_not_exist once so the
  store durably rollbacks the primary before any lock is removed; bail
  out fail-closed if the store still reports txn_not_found; drop the
  dead TxnLockConflict branch; do not cache states that still carry a
  live lock.
- ResolveNormalLock: a lock reported via txn_result means the txn is
  alive even if the top-level ttl/commit_ts fields are unset.
- ResolveLockSecondaryLocks: pass through MinCommitTSPushed for readers
  and only run the async commit resolution after the primary lock ttl
  has expired.
- TxnGetTask::DoAsync: reset status_ per attempt so a clean retry
  response does not inherit the previous error.
…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.
@visualYJD visualYJD closed this Jul 16, 2026
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