-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
util: add more log for expensive and global memory control #39397
util: add more log for expensive and global memory control #39397
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
/run-build |
1 similar comment
/run-build |
} | ||
|
||
func killSessIfNeeded(s *sessionToBeKilled, bt uint64, sm util.SessionManager) { | ||
if s.isKilling { | ||
if info, ok := sm.GetProcessInfo(s.sessionID); ok { | ||
if info.Time == s.sqlStartTime { | ||
if time.Since(s.lastLogTime) > 5*time.Second { | ||
logutil.BgLogger().Warn("Memory usage Top1 SQL can't handle the kill signal", | ||
zap.String("sql_text", info.Info), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- connID needs to be logged.
- sql digest needs to be logged.
- info.Info needs to be truncated, I think we do not need to log the full text.
@@ -119,6 +129,13 @@ func killSessIfNeeded(s *sessionToBeKilled, bt uint64, sm util.SessionManager) { | |||
SessionKillLast.Store(killTime) | |||
IsKilling.Store(true) | |||
GlobalMemoryOpsHistoryManager.recordOne(info, killTime, bt, instanceStats.HeapInuse) | |||
s.lastLogTime = time.Now() | |||
logutil.BgLogger().Warn("tidb-server has the risk of OOM. Try to kill the memory usage Top1 SQL.", | |||
zap.String("sql_text", info.Info), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
if time.Since(s.lastLogTime) > 5*time.Second { | ||
logutil.BgLogger().Warn("Memory usage Top1 SQL can't handle the kill signal", | ||
zap.String("sql_text", info.Info), | ||
zap.Int64("sql_memory_usage", info.MemTracker.BytesConsumed())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if time.Since(s.lastLogTime) > 5*time.Second { | |
logutil.BgLogger().Warn("Memory usage Top1 SQL can't handle the kill signal", | |
zap.String("sql_text", info.Info), | |
zap.Int64("sql_memory_usage", info.MemTracker.BytesConsumed())) | |
if time.Since(s.lastLogTime) > 5*time.Second { | |
logutil.BgLogger().Warn("Memory usage Top1 SQL can't handle the kill signal", | |
zap.String("sql text", info.Info), | |
zap.Int64("sql memory usage", info.MemTracker.BytesConsumed())) |
logutil.BgLogger().Warn("tidb-server has the risk of OOM. Try to kill the memory usage Top1 SQL.", | ||
zap.String("sql_text", info.Info), | ||
zap.Uint64("server_memory_limit", bt), | ||
zap.Uint64("heap_in_use", instanceStats.HeapInuse), | ||
zap.Int64("sql_memory_usage", info.MemTracker.BytesConsumed()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logutil.BgLogger().Warn("tidb-server has the risk of OOM. Try to kill the memory usage Top1 SQL.", | |
zap.String("sql_text", info.Info), | |
zap.Uint64("server_memory_limit", bt), | |
zap.Uint64("heap_in_use", instanceStats.HeapInuse), | |
zap.Int64("sql_memory_usage", info.MemTracker.BytesConsumed()), | |
logutil.BgLogger().Warn("tidb-server has the risk of OOM. Try to kill the top1 memory consumer", | |
zap.String("sql text", info.Info), | |
zap.Uint64("tidb_server_memory_limit", bt), | |
zap.Uint64("heap inuse", instanceStats.HeapInuse), | |
zap.Int64("sql memory usage", info.MemTracker.BytesConsumed()), |
@@ -119,6 +129,13 @@ func killSessIfNeeded(s *sessionToBeKilled, bt uint64, sm util.SessionManager) { | |||
SessionKillLast.Store(killTime) | |||
IsKilling.Store(true) | |||
GlobalMemoryOpsHistoryManager.recordOne(info, killTime, bt, instanceStats.HeapInuse) | |||
s.lastLogTime = time.Now() | |||
logutil.BgLogger().Warn("tidb-server has the risk of OOM. Try to kill the memory usage Top1 SQL.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logutil.BgLogger().Warn("tidb-server has the risk of OOM. Try to kill the memory usage Top1 SQL.", | |
logutil.BgLogger().Warn("global memory controller tries to kill the top1 memory consumer", |
} | ||
|
||
func killSessIfNeeded(s *sessionToBeKilled, bt uint64, sm util.SessionManager) { | ||
if s.isKilling { | ||
if info, ok := sm.GetProcessInfo(s.sessionID); ok { | ||
if info.Time == s.sqlStartTime { | ||
if time.Since(s.lastLogTime) > 5*time.Second { | ||
logutil.BgLogger().Warn("Memory usage Top1 SQL can't handle the kill signal", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logutil.BgLogger().Warn("Memory usage Top1 SQL can't handle the kill signal", | |
logutil.BgLogger().Warn(fmt.Sprintf("global memory controller failed to kill the top-consumer in %ds", now - killStartTime) , |
zap.String("sql_text", info.Info), | ||
zap.Int64("sql_memory_usage", info.MemTracker.BytesConsumed())) | ||
s.lastLogTime = time.Now() | ||
} | ||
return | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to add a log in lint 107 like "global memory controller killed the top1 memory consumer successfully"
@@ -81,12 +83,20 @@ type sessionToBeKilled struct { | |||
sqlStartTime time.Time | |||
sessionID uint64 | |||
sessionTracker *memory.Tracker | |||
|
|||
lastLogTime time.Time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lastLogTime time.Time | |
killStartTime time.Time | |
lastLogTime time.Time |
/run-build |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 9a6edf0
|
TiDB MergeCI notify🔴 Bad News! New failing [2] after this pr merged.
|
What problem does this PR solve?
Issue Number: close #xxx
Problem Summary:
What is changed and how it works?
Add more logs for debug OOM.
Check List
Tests
Case1: Run the sql and get the following logs.
Case2: Run the sqls and get the following log.
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.