Skip to content

Commit

Permalink
*: fix processlist.txnstart when tidb_snapshot is set (#23381)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackysp authored Mar 18, 2021
1 parent 3cfb984 commit da0b6eb
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,11 @@ func (s *session) SetProcessInfo(sql string, t time.Time, command byte, maxExecu
if command != mysql.ComSleep || s.GetSessionVars().InTxn() {
curTxnStartTS = s.sessionVars.TxnCtx.StartTS
}
// Set curTxnStartTS to SnapshotTS directly when the session is trying to historic read.
// It will avoid the session meet GC lifetime too short error.
if s.GetSessionVars().SnapshotTS != 0 {
curTxnStartTS = s.GetSessionVars().SnapshotTS
}
p := s.currentPlan
if explain, ok := p.(*plannercore.Explain); ok && explain.Analyze && explain.TargetPlan != nil {
p = explain.TargetPlan
Expand Down

0 comments on commit da0b6eb

Please sign in to comment.