Skip to content

Commit

Permalink
executor: fix some bug for global memory control (#38798)
Browse files Browse the repository at this point in the history
  • Loading branch information
wshwsh12 committed Nov 2, 2022
1 parent a3d7420 commit 26ba9b6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions util/servermemorylimit/servermemorylimit.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ func (smqh *Handle) Run() {
}

type sessionToBeKilled struct {
isKilling bool
sqlStartTime time.Time
sessionID uint64
isKilling bool
sqlStartTime time.Time
sessionID uint64
sessionTracker *memory.Tracker
}

func killSessIfNeeded(s *sessionToBeKilled, bt uint64, sm util.SessionManager) {
Expand All @@ -91,6 +92,7 @@ func killSessIfNeeded(s *sessionToBeKilled, bt uint64, sm util.SessionManager) {
}
s.isKilling = false
IsKilling.Store(false)
memory.MemUsageTop1Tracker.CompareAndSwap(s.sessionTracker, nil)
//nolint: all_revive,revive
runtime.GC()
}
Expand All @@ -109,6 +111,7 @@ func killSessIfNeeded(s *sessionToBeKilled, bt uint64, sm util.SessionManager) {
s.sessionID = t.SessionID
s.sqlStartTime = info.Time
s.isKilling = true
s.sessionTracker = t
t.NeedKill.Store(true)

killTime := time.Now()
Expand Down

0 comments on commit 26ba9b6

Please sign in to comment.