Skip to content

Commit

Permalink
fix typo and refactor
Browse files Browse the repository at this point in the history
Signed-off-by: ekexium <eke@fastmail.com>
  • Loading branch information
ekexium committed Oct 10, 2024
1 parent a0e8ccc commit 15abaa4
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions txnkv/transaction/2pc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1343,13 +1343,16 @@ func keepAlive(
}
return
}
} else {
keepFail = 0
metrics.TxnHeartBeatHistogramOK.Observe(time.Since(startTime).Seconds())
continue
}

// broadcast to all stores
if err != nil && isPipelinedTxn {
keepFail = 0
metrics.TxnHeartBeatHistogramOK.Observe(time.Since(startTime).Seconds())
// Broadcast to all stores only when the heartbeat succeeds.
// This ensures that PK is the single source of truth for transaction status on the
// TiKV side. It prevents potential inconsistencies where the cached information might
// be more up-to-date than the info stored in the PK.
if isPipelinedTxn {
broadcastToAllStores(
c.txn,
c.store,
Expand Down

0 comments on commit 15abaa4

Please sign in to comment.