-
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
Tablet throttler: starvation fix and consolidation of logic. #15398
Tablet throttler: starvation fix and consolidation of logic. #15398
Conversation
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
…centCheckTickerValue. Use recentCheckRateLimiter Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[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
|
@@ -148,20 +148,19 @@ func (check *ThrottlerCheck) Check(ctx context.Context, appName string, storeTyp | |||
} | |||
|
|||
checkResult = check.checkAppMetricResult(ctx, appName, storeType, storeName, metricResultFunc, flags) | |||
check.throttler.lastCheckTimeNano.Store(time.Now().UnixNano()) |
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.
Removed from check.,go
. Delegated to, and consolidated in checkStore()
in throttler.go
.
|
||
check.throttler.markRecentApp(appName, remoteAddr) | ||
}(checkResult.StatusCode) | ||
if !throttlerapp.VitessName.Equals(appName) { |
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.
No metrics for "vitess"
app.
Temprarily converting to |
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #15398 +/- ##
==========================================
- Coverage 67.41% 65.65% -1.77%
==========================================
Files 1560 1562 +2
Lines 192752 194366 +1614
==========================================
- Hits 129952 127611 -2341
- Misses 62800 66755 +3955 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Shlomi Noach <[email protected]>
@@ -724,15 +755,42 @@ func (throttler *Throttler) Operate(ctx context.Context, wg *sync.WaitGroup) { | |||
case <-mysqlCollectTicker.C: | |||
if throttler.IsOpen() { | |||
// frequent | |||
// Always collect self metrics: |
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.
Now that this PR fixes the dormant issue, we also notice that any throttler should be collecting their own already-probed metrics. This comes at nearly no-cost. dormancy was made for the PRIMARY to not overwhelm network traffic when not needed, whilst collecting metrics from the replicas.
Upon adding b58bac6, I realize this PR now solves a different starvation issue, perhaps even more dominant than the one it was meant to solve. Will open a new issue to describe it. |
Signed-off-by: Shlomi Noach <[email protected]>
2nd starvation issue: #15433 |
Description
This PR addresses a starvation scenario in the tablet throttler. The scenario actually doesn't take place, due to an unintentional change. We fix the unintentional change & we fix the starvation scenario.
We also consolidate two different measurements of "last check" or "recent check":
recentCheckValue
lastCheckTimeNano
They are superfluous, because both serve to answer a similar question: "when was this throttler last checked?"
lastCheckTimeNano
was updated incheck.go
at every check, and that's also where the aforementioned unintentional behavior takes place: this value should not be updated when the app is"vitess"
. Right now inmain
this value does get updated when the app is"vitess"
, which means the throttler's self-checks keep that value always recent. In turn, this prevents the throttler from going into dormant mode.We introduce a new, single tracker for the checks, in the form of
recentCheckRateLimiter
.RateLimiter
now not only produces ticks, and not only rate limits some action, but can also tell us the logical clock diff since last action invocation.Using this, we can easily determine:
1min
Starvation prevention through
PRIMARY
stimulationThe fix to the starvation scenario is for the replica to proactively let the
PRIMARY
know that it has been checked. ThePRIMARY
still gets that information from the replicas when probing them. But now also, the replica invokes aCheckThrottler()
directly on thePRIMARY
with"throttler-stimulator"
app name. This "stimulates" thePRIMARY
, as it sees that it has just been checked, and therefore immediately renews heartbeat lease.However, the replica does not overload the
PRIMARY
with these stimulations. Stimulations are rate limited to exactly dormant period (1min
at this time).Unit tests
We add unit tests to validate:
"vitess"
app checks does not affect "recently checked" state, neither orPRIMARY
nor on replicas."throttler-stimulator"
affects "recently checked" state and causes heartbeat renewals.CheckThrottler
onPRIMARY
with"throttler-stimulator"
app name.Related Issue(s)
#15397
Checklist
Deployment Notes