Skip to content

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

Merged
deepthi merged 5 commits intovitessio:masterfrom
planetscale:vttablet-throttle-feature-flag
Oct 5, 2020
Merged

vttablet throttler feature flag: -enable-lag-throttler#6815
deepthi merged 5 commits intovitessio:masterfrom
planetscale:vttablet-throttle-feature-flag

Conversation

@shlomi-noach
Copy link
Copy Markdown
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>
-init_tablet_type $tablet_type \
-health_check_interval 5s \
-heartbeat_enable \
-heartbeat_interval 250ms \
Copy link
Copy Markdown
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.

-enable_semi_sync \
-enable_replication_reporter \
-heartbeat_enable \
-heartbeat_interval 250ms \
Copy link
Copy Markdown
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.

}
if rt.forceHeartbeat {
rt.hw.Open()
}
Copy link
Copy Markdown
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
Copy Markdown
Collaborator

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
Copy Markdown
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.

throttler.shard = shard
go throttler.Operate(context.Background())
if throttler.env.Config().EnableLagThrottler {
go throttler.Operate(context.Background())
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

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

// 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
Copy Markdown
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
Copy Markdown
Contributor Author

This branch is incorporated inside #6547

@shlomi-noach
Copy link
Copy Markdown
Contributor Author

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

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
Copy Markdown
Collaborator

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
func (w *heartbeatWriter) enableWrites(enable bool) {
if w.ticks == nil {
return
}
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

3 participants