-
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: post 18 refactoring, race condition fixes, unit & race testing, deprecation of HTTP checks #14181
Tablet throttler: post 18 refactoring, race condition fixes, unit & race testing, deprecation of HTTP checks #14181
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]>
…s); exhaust Operate() channels (mostly for unit tests) Signed-off-by: Shlomi Noach <[email protected]>
…sts); 'select' on ctx.Done() when writing to channels 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
|
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]>
This PR is being marked as stale because it has been open for 30 days with no activity. To rectify, you may do any of the following:
If no action is taken within 7 days, this PR will be closed. |
Request for review 🙏 |
Signed-off-by: Shlomi Noach <[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.
Thanks! ❤️ I only had minor comments/questions/nits so will leave it up to you how to best resolve.
CacheMillis int | ||
QueryInProgress int64 | ||
} | ||
|
||
// Probes maps instances to probe(s) | ||
type Probes map[InstanceKey](*Probe) | ||
// Probes maps tablet aliases to probe(s) |
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 it's worth it or not, but we could use the *topodatapb.TabletAlias
type as the key instead of string. String is fine too, IMO.
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.
Yeah it's a good point. It will be yet another somewhat significant change what with all the tests. I'm happy to give this a go in a followup PR, as this PR is already bloated as it is.
defer requestCancel() | ||
throttlerConfig, err := throttler.readThrottlerConfig(requestCtx) | ||
if err == nil { | ||
log.Errorf("Throttler.retryReadAndApplyThrottlerConfig(): success reading throttler config: %+v", throttlerConfig) |
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.
Shouldn't this be 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.
fixed
for { | ||
if !throttler.IsOpen() { | ||
// Throttler is not open so no need to keep retrying. | ||
log.Errorf("Throttler.retryReadAndApplyThrottlerConfig(): throttler no longer seems to be open, exiting") |
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.
Shouldn't this be INFO or maybe WARNING?
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.
fixed
select { | ||
case <-ctx.Done(): | ||
// Throttler is not open so no need to keep retrying. | ||
log.Errorf("Throttler.retryReadAndApplyThrottlerConfig(): throttler no longer seems to be open, exiting") |
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 feels like WARNING to me.
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.
fixed
if throttler.IsOpen() { | ||
if throttler.tabletTypeFunc() == topodatapb.TabletType_PRIMARY { |
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.
I think it would be slightly more readable if it was if throttler.IsOpen() && throttler.tabletTypeFunc() == topodatapb.TabletType_PRIMARY {
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.
rewritten
probe := probe | ||
go func() { |
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.
IMO it's nicer to pass the value into the groutine function, but this is also fine. Personal pref I suppose, I just find it more clear/deliberate/obvious. Maybe we can just add a comment about the closure issue instead for future readers so they don't delete the line as "unneeded". :-)
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.
rewritten. The one thing I don't like about the pass-the-value-to-goroutine paradigm, is that the value is passed 20 lines of code below. Otherwise I recognize it's the dominant paradigm.
) | ||
|
||
// TestProbesPostDisable runs the throttler for some time, and then investigates the internal throttler maps and values. | ||
// While the therottle is disabled, it is technically safe to iterate those structures. However, `go test -race` disagrees, |
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.
typo: therottle
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.
fixed. I'm now working with a new spellchecker that is not as intrusive as others I've worked with, let's see how it improves my typos rate.
Signed-off-by: Shlomi Noach <[email protected]>
…ace testing, deprecation of HTTP checks (vitessio#14181) Signed-off-by: Shlomi Noach <[email protected]>
Description
Followup to #13341
Addresses and fixes #14180. This PR is quite large and incorporates many changes; some planned in advance, some found while investigating #14164, and some on the go as race detections were added.
To make sense of the changes, most commits in this PR can be considered in isolation:
InstanceKey
type; all probes are now identified by a tablet alias, and all access to tablets is done by tablt alias or tablet reference. Anyhostname:port
access (or information) is gone.Open()
&Close()
. Things that don't need to operate when the throttler isClose()
d now won't.golang
atomic
types.Related Issue(s)
Fixes #14180
It also fixes issue #14178 for post-v18. However, a dedicated PR #14179 fixes #14178 for both post v18 as well as v18, v17, v16 backport.
Checklist