Skip to content

Commit

Permalink
Do not broadcast txn status when heartbeat fail (#1471)
Browse files Browse the repository at this point in the history
 

Signed-off-by: ekexium <[email protected]>
  • Loading branch information
ekexium authored Oct 10, 2024
1 parent c3e10ae commit bce97bb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.21.0"
go-version: "1.23.0"

- name: Checkout Client-Go
uses: actions/checkout@v2
Expand Down
12 changes: 8 additions & 4 deletions txnkv/transaction/2pc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1343,12 +1343,15 @@ func keepAlive(
}
return
}
} else {
keepFail = 0
metrics.TxnHeartBeatHistogramOK.Observe(time.Since(startTime).Seconds())
continue
}

// broadcast to all stores
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,
Expand Down Expand Up @@ -1412,6 +1415,7 @@ func broadcastToAllStores(
ResourceGroupName: resourceGroupName,
}
req.Context.ResourceGroupTag = resourceGroupTag
req.Context.RequestSource = txn.GetRequestSource()

_, err := store.GetTiKVClient().SendRequest(
bo.GetCtx(),
Expand Down

0 comments on commit bce97bb

Please sign in to comment.