Skip to content

Commit

Permalink
Fix the async broadcast & resolveFlushedLocks (#1493)
Browse files Browse the repository at this point in the history
close pingcap/tidb#57213

Signed-off-by: ekexium <[email protected]>
  • Loading branch information
ekexium authored Nov 18, 2024
1 parent 245d2c3 commit 983d7ff
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
4 changes: 2 additions & 2 deletions txnkv/transaction/pipelined_flush.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ func (c *twoPhaseCommitter) resolveFlushedLocks(bo *retry.Backoffer, start, end
)
runner.SetStatLogInterval(30 * time.Second)

go func() {
c.txn.spawnWithStorePool(func() {
if err = runner.RunOnRange(bo.GetCtx(), start, end); err != nil {
logutil.Logger(bo.GetCtx()).Error("[pipelined dml] resolve flushed locks failed",
zap.String("txn-status", status),
Expand Down Expand Up @@ -529,5 +529,5 @@ func (c *twoPhaseCommitter) resolveFlushedLocks(bo *retry.Backoffer, start, end
c.resourceGroupTag,
)
}
}()
})
}
36 changes: 20 additions & 16 deletions txnkv/transaction/txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -842,23 +842,27 @@ func (txn *KVTxn) Rollback() error {
// no need to clean up locks when no flush triggered.
pipelinedStart, pipelinedEnd := txn.committer.pipelinedCommitInfo.pipelinedStart, txn.committer.pipelinedCommitInfo.pipelinedEnd
needCleanUpLocks := len(pipelinedStart) != 0 && len(pipelinedEnd) != 0
broadcastToAllStores(
txn,
txn.committer.store,
retry.NewBackofferWithVars(
txn.store.Ctx(),
broadcastMaxBackoff,
txn.committer.txn.vars,
),
&kvrpcpb.TxnStatus{
StartTs: txn.startTS,
MinCommitTs: txn.committer.minCommitTSMgr.get(),
CommitTs: 0,
RolledBack: true,
IsCompleted: !needCleanUpLocks,
txn.spawnWithStorePool(
func() {
broadcastToAllStores(
txn,
txn.committer.store,
retry.NewBackofferWithVars(
txn.store.Ctx(),
broadcastMaxBackoff,
txn.committer.txn.vars,
),
&kvrpcpb.TxnStatus{
StartTs: txn.startTS,
MinCommitTs: txn.committer.minCommitTSMgr.get(),
CommitTs: 0,
RolledBack: true,
IsCompleted: !needCleanUpLocks,
},
txn.resourceGroupName,
txn.resourceGroupTag,
)
},
txn.resourceGroupName,
txn.resourceGroupTag,
)
if needCleanUpLocks {
rollbackBo := retry.NewBackofferWithVars(txn.store.Ctx(), CommitSecondaryMaxBackoff, txn.vars)
Expand Down

0 comments on commit 983d7ff

Please sign in to comment.