Skip to content

Commit

Permalink
session: fix data race in the TrxHistoryRecorder.OnTrxEnd (pingcap#37476
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkingrei authored Aug 30, 2022
1 parent 8277bd5 commit 4481145
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions session/txninfo/summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ func (recorder *TrxHistoryRecorder) DumpTrxSummary() [][]types.Datum {
func (recorder *TrxHistoryRecorder) OnTrxEnd(info *TxnInfo) {
now := time.Now()
startTime := time.UnixMilli(oracle.ExtractPhysical(info.StartTS))
recorder.mu.Lock()
defer recorder.mu.Unlock()
if now.Sub(startTime) < recorder.minDuration {
return
}
recorder.mu.Lock()
defer recorder.mu.Unlock()
recorder.summaries.onTrxEnd(info.AllSQLDigests)
}

Expand Down

0 comments on commit 4481145

Please sign in to comment.