Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

txn: skip the transaction start_ts used by analyze calculating the gc safepoint #35144

Merged
merged 1 commit into from
Jun 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can get the id from "tmp.sessionVars.ConnectionID"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the analyze identifier is injected using ProcessID perhaps it's safer to use ProcessID to do the comparison.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AutoAnalyzeProcID is assigned to session.GetSessionVars().ConnectionID and then session.processInfo.ID is set to session.GetSessionVars().ConnectionID.

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