Skip to content
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

vttablet throttler feature flag: -enable-lag-throttler #6815

Merged
merged 5 commits into from Oct 5, 2020

Conversation

shlomi-noach
Copy link
Contributor

followup to #6668

This PR introduces -enable-lag-throttler feature flag (bool). By default -enable-lag-throttler is false.

When -enable-lag-throttler=true, the vttablet throttler functionality is activated:

  • throttler will probe mysql servers for lag
  • throttler will aggregate probed data
  • implicitly active heartbeat writer regardless of heartbeat config.

cc @aquarapid

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
@@ -50,8 +50,6 @@ vttablet \
-init_shard $shard \
-init_tablet_type $tablet_type \
-health_check_interval 5s \
-heartbeat_enable \
-heartbeat_interval 250ms \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were committed earlier by mistake.

@@ -47,8 +47,6 @@ vttablet \
-health_check_interval 5s \
-enable_semi_sync \
-enable_replication_reporter \
-heartbeat_enable \
-heartbeat_interval 250ms \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were committed earlier by mistake.

@@ -88,6 +90,9 @@ func (rt *ReplTracker) MakeMaster() {
rt.hr.Close()
rt.hw.Open()
}
if rt.forceHeartbeat {
rt.hw.Open()
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when throttler runs, we need heartbeat writer to run. We do not need the reader because throttler reads directly from _vt.heartbeat table.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note that we could be calling Open and Close twice, but that is fine since they are idempotent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 that was my understanding as well.

@@ -186,7 +186,9 @@ func (throttler *Throttler) initThrottleTabletTypes() {
func (throttler *Throttler) InitDBConfig(keyspace, shard string) {
throttler.keyspace = keyspace
throttler.shard = shard
go throttler.Operate(context.Background())
if throttler.env.Config().EnableLagThrottler {
go throttler.Operate(context.Background())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Operate() is where the throttler does all the hard work. If throttler is not enabled, we skip it altogether.

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
@shlomi-noach
Copy link
Contributor Author

Noteworthy, when the throttler is disabled, the endpoint /throttler/check still serves, and always responds with HTTP 200 OK.

@@ -692,6 +694,9 @@ func (throttler *Throttler) AppRequestMetricResult(ctx context.Context, appName

// Check is the main serving function of the throttler, and returns a check result for this cluster's lag
func (throttler *Throttler) Check(ctx context.Context, appName string, remoteAddr string, flags *CheckFlags) (checkResult *CheckResult) {
if !throttler.env.Config().EnableLagThrottler {
return okMetricCheckResult
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the throttler is disabled, Check() always responds with HTTP 200 OK

@shlomi-noach
Copy link
Contributor Author

This branch is incorporated inside #6547

@shlomi-noach
Copy link
Contributor Author

I'm ready to have this PR reviewed and merged.

@@ -73,6 +73,11 @@ type heartbeatWriter struct {
// newHeartbeatWriter creates a new heartbeatWriter.
func newHeartbeatWriter(env tabletenv.Env, alias topodatapb.TabletAlias) *heartbeatWriter {
config := env.Config()

// config.EnableLagThrottler is a feature flag for the throttler; if throttler runs, then heartbeat must also run
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not clear why the changes in this file are required, but I'll trust the tests :)

@deepthi deepthi merged commit bbd31e2 into vitessio:master Oct 5, 2020
@deepthi deepthi deleted the vttablet-throttle-feature-flag branch October 5, 2020 19:58
@askdba askdba added this to the v8.0 milestone Oct 6, 2020
@@ -182,6 +187,9 @@ func (w *heartbeatWriter) recordError(err error) {

// enableWrites actives or deactives heartbeat writes
func (w *heartbeatWriter) enableWrites(enable bool) {
if w.ticks == nil {
return
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deepthi this change is actually reverting my previous change in the throttler PR. This if statement was originally here.

// config.EnableLagThrottler is a feature flag for the throttler; if throttler runs, then heartbeat must also run
if config.ReplicationTracker.Mode != tabletenv.Heartbeat && !config.EnableLagThrottler {
return &heartbeatWriter{}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deepthi this change is actually reverting my previous change in the throttler PR. This if statement was originally here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(except of course now added && !config.EnableLagThrottler)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants