-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
*: support global memory control for tidb #37794
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. |
869d21f
to
a5a9053
Compare
6df9ab3
to
5de3bac
Compare
5de3bac
to
b198b25
Compare
@@ -57,6 +58,7 @@ func (eqh *Handle) Run() { | |||
defer ticker.Stop() | |||
sm := eqh.sm.Load().(util.SessionManager) | |||
record := &memoryUsageAlarm{} | |||
serverMemoryQuota := &serverMemoryQuota{} |
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 use an individual goroutine to monitor the global memory status? The expensive_query worker handles too many things
8d80a03
to
9826ae0
Compare
executor/executor_test.go
Outdated
tracker3.Consume(300 << 20) // 300 MB | ||
|
||
test := make([]int, 128<<20) // Keep 1GB HeapInUse | ||
time.Sleep(500 * time.Millisecond) |
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.
What's the purpose of this Sleep?
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.
The check goroutine checks the memory usage every 100ms. The Sleep() make sure that Top1Tracker can be Canceled.
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.
It's better to add some comment for it.
Sleep slows down the test, and 0.5s is long enough for UT
executor/executor_test.go
Outdated
tracker2.Consume(200 << 20) // 200 MB | ||
tracker3.Consume(300 << 20) // 300 MB | ||
|
||
test := make([]int, 128<<20) // Keep 1GB HeapInUse |
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.
This is virtual memory instead of real allocation before you visit the data.
OS will handle the logical -> physical memory address mapping and allocate the physical pages.
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.
This only simulates the situation of heapinuse
growth.
In normally, TiDB will use the memory immediately after allocation.
require.True(t, strings.Contains(r.(string), "Out Of Memory Quota!")) | ||
}) | ||
tracker2.Consume(300 << 20) // Sum 500MB, Not Panic, Waiting t3 cancel finish. | ||
time.Sleep(500 * time.Millisecond) |
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.
It takes time to cancel?
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.
Wait for cancel
Validation: func(s *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { | ||
intVal, err := strconv.ParseUint(normalizedValue, 10, 64) | ||
if err != nil { | ||
return "", err | ||
} | ||
if intVal > 0 && intVal < (512<<20) { // 512 MB | ||
s.StmtCtx.AppendWarning(ErrTruncatedWrongValue.GenWithStackByArgs(TiDBServerMemoryLimit, originalValue)) | ||
intVal = 512 << 20 | ||
} | ||
return strconv.FormatUint(intVal, 10), nil |
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.
Why not set MinValue at line 719?
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.
0 means disable this feature.
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.
OK... I see. This is kind of confusing
0 means disable, while when the value is smaller than 512MB, it's adjusted to 512MB (actual min value)
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 8fea589
|
TiDB MergeCI notify🔴 Bad News! [1] CI still failing after this pr merged.
|
What problem does this PR solve?
Issue Number: ref #37816
Problem Summary:
What is changed and how it works?
tidb_server_memory_limit
andtidb_server_memory_limit_sess_min_size
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.