Skip to content

Commit

Permalink
txn: skip the transaction start_ts used by analyze calculating the gc…
Browse files Browse the repository at this point in the history
… safepoint (pingcap#35144)
  • Loading branch information
cfzjywxk authored Jun 5, 2022
1 parent 4c39b09 commit 1a89dec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 5 additions & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -833,8 +833,12 @@ func (s *Server) GetInternalSessionStartTSList() []uint64 {
s.sessionMapMutex.Lock()
defer s.sessionMapMutex.Unlock()
tsList := make([]uint64, 0, len(s.internalSessions))
analyzeProcID := util.GetAutoAnalyzeProcID(s.ServerID)
for se := range s.internalSessions {
if ts := session.GetStartTSFromSession(se); ts != 0 {
if ts, processInfoID := session.GetStartTSFromSession(se); ts != 0 {
if processInfoID == analyzeProcID {
continue
}
tsList = append(tsList, ts)
}
}
Expand Down
12 changes: 8 additions & 4 deletions session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -3230,12 +3230,16 @@ func (s *session) ShowProcess() *util.ProcessInfo {
}

// GetStartTSFromSession returns the startTS in the session `se`
func GetStartTSFromSession(se interface{}) uint64 {
var startTS uint64
func GetStartTSFromSession(se interface{}) (uint64, uint64) {
var startTS, processInfoID uint64
tmp, ok := se.(*session)
if !ok {
logutil.BgLogger().Error("GetStartTSFromSession failed, can't transform to session struct")
return 0
return 0, 0
}
processInfo := tmp.ShowProcess()
if processInfo != nil {
processInfoID = processInfo.ID
}
txnInfo := tmp.TxnInfo()
if txnInfo != nil {
Expand All @@ -3246,7 +3250,7 @@ func GetStartTSFromSession(se interface{}) uint64 {
"GetStartTSFromSession getting startTS of internal session",
zap.Uint64("startTS", startTS), zap.Time("start time", oracle.GetTimeFromTS(startTS)))

return startTS
return startTS, processInfoID
}

// logStmt logs some crucial SQL including: CREATE USER/GRANT PRIVILEGE/CHANGE PASSWORD/DDL etc and normal SQL
Expand Down

0 comments on commit 1a89dec

Please sign in to comment.