-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Use a throttled logger for exceeded memory warnings #15424
Use a throttled logger for exceeded memory warnings #15424
Conversation
Signed-off-by: Manan Gupta <[email protected]>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
go/vt/vtgate/executor.go
Outdated
@@ -231,7 +234,7 @@ func (e *Executor) Execute(ctx context.Context, mysqlCtx vtgateservice.MySQLConn | |||
if err != nil { | |||
piiSafeSQL = logStats.StmtType | |||
} | |||
log.Warningf("%q exceeds warning threshold of max memory rows: %v. Actual memory rows: %v", piiSafeSQL, warnMemoryRows, len(result.Rows)) | |||
exceedMemoryRowsLogger.Warningf("%q exceeds warning threshold of max memory rows: %v. Actual memory rows: %v", piiSafeSQL, warnMemoryRows, len(result.Rows)) |
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.
Does this throttle only on the exact matching len(result.Rows)
or also on different lengths? And should it only throttle on exactly the same or should we also throttle if it's a slightly different value?
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 feels like the throttler will throttle all max memory warning regardless of the query. I think it would be more useful if we could throttle based on the query we are receiving rather than just the error.
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.
Right now it will throttle all log messages that are generated by this line. That is, it might be a different query, or it might be a different number of rows. It will only print one message a minute.
I agree that it will be nice to print one message per distinct query. That will need writing a new kind of ThrottledLogger. I don't know if that is worth it. If we believe it is, then let's do it.
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.
On second thought, maybe we should just throttle like before and focus on making sure that this is returned as a warning to the client. With mysql clients, that should be pretty easy. What do we do for grpc clients?
Currently working on this PR to add a per-query throttler |
ThrottledQueryLogger
for exceeded memory warnings
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #15424 +/- ##
==========================================
- Coverage 67.41% 65.64% -1.78%
==========================================
Files 1560 1563 +3
Lines 192752 194405 +1653
==========================================
- Hits 129952 127621 -2331
- Misses 62800 66784 +3984 ☔ View full report in Codecov by Sentry. |
warningMsg := fmt.Sprintf("%q exceeds warning threshold of max memory rows: %v. Actual memory rows: %v", piiSafeSQL, warnMemoryRows, len(result.Rows)) | ||
exceedMemoryRowsLogger.Warningf(sql, warningMsg) | ||
safeSession.RecordWarning(&querypb.QueryWarning{ | ||
Code: uint32(sqlerror.EROutOfMemory), |
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.
Not sure if EROutOfMemory
is appropriate, we can also remove the Code
altogether
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.
Should be fine, because the warning we return to the client is descriptive.
Signed-off-by: Florent Poinsard <[email protected]>
3f88408
to
1b6c139
Compare
ThrottledQueryLogger
for exceeded memory warnings
Validated the change with a local test by setting
|
Signed-off-by: Florent Poinsard <[email protected]>
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.
LGTM!
Just a note that we abandoned this because it seemed like too much work for log throttling. |
Description
This PR fixes the issue described in #15423.
We now create a throttled logger and use that to log the warnings for exceeding memory row count.
Related Issue(s)
Checklist
Deployment Notes