Skip to content

Commit 88a356c

Browse files
authored
Tablet throttler: remove LowPriority logic (#16013)
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
1 parent 8c2ef94 commit 88a356c

File tree

6 files changed

+3
-41
lines changed

6 files changed

+3
-41
lines changed

go/vt/vttablet/tabletmanager/rpc_throttler.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ func (tm *TabletManager) CheckThrottler(ctx context.Context, req *tabletmanagerd
3434
req.AppName = throttlerapp.VitessName.String()
3535
}
3636
flags := &throttle.CheckFlags{
37-
LowPriority: false,
3837
SkipRequestHeartbeats: true,
3938
}
4039
checkResult := tm.QueryServiceControl.CheckThrottler(ctx, req.AppName, flags)

go/vt/vttablet/tabletserver/tabletserver.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1896,7 +1896,6 @@ func (tsv *TabletServer) registerThrottlerCheckHandlers() {
18961896
appName = throttlerapp.DefaultName.String()
18971897
}
18981898
flags := &throttle.CheckFlags{
1899-
LowPriority: (r.URL.Query().Get("p") == "low"),
19001899
SkipRequestHeartbeats: (r.URL.Query().Get("s") == "true"),
19011900
}
19021901
checkResult := tsv.lagThrottler.CheckByType(ctx, appName, remoteAddr, flags, checkType)

go/vt/vttablet/tabletserver/throttle/check.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ var (
6767
type CheckFlags struct {
6868
ReadCheck bool
6969
OverrideThreshold float64
70-
LowPriority bool
7170
OKIfNotExists bool
7271
SkipRequestHeartbeats bool
7372
}
@@ -91,14 +90,6 @@ func NewThrottlerCheck(throttler *Throttler) *ThrottlerCheck {
9190
func (check *ThrottlerCheck) checkAppMetricResult(ctx context.Context, appName string, storeType string, storeName string, metricResultFunc base.MetricResultFunc, flags *CheckFlags) (checkResult *CheckResult) {
9291
// Handle deprioritized app logic
9392
denyApp := false
94-
metricName := fmt.Sprintf("%s/%s", storeType, storeName)
95-
if flags.LowPriority {
96-
if _, exists := check.throttler.nonLowPriorityAppRequestsThrottled.Get(metricName); exists {
97-
// a non-deprioritized app, ie a "normal" app, has recently been throttled.
98-
// This is now a deprioritized app. Deny access to this request.
99-
denyApp = true
100-
}
101-
}
10293
//
10394
metricResult, threshold := check.throttler.AppRequestMetricResult(ctx, appName, metricResultFunc, denyApp)
10495
if flags.OverrideThreshold > 0 {
@@ -125,11 +116,6 @@ func (check *ThrottlerCheck) checkAppMetricResult(ctx context.Context, appName s
125116
// casual throttling
126117
statusCode = http.StatusTooManyRequests // 429
127118
err = base.ErrThresholdExceeded
128-
129-
if !flags.LowPriority && !flags.ReadCheck && throttlerapp.VitessName.Equals(appName) {
130-
// low priority requests will henceforth be denied
131-
go check.throttler.nonLowPriorityAppRequestsThrottled.SetDefault(metricName, true)
132-
}
133119
default:
134120
// all good!
135121
statusCode = http.StatusOK // 200

go/vt/vttablet/tabletserver/throttle/client.go

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,30 +56,14 @@ type Client struct {
5656
lastSuccessfulThrottle int64
5757
}
5858

59-
// NewProductionClient creates a client suitable for foreground/production jobs, which have normal priority.
60-
func NewProductionClient(throttler *Throttler, appName throttlerapp.Name, checkType ThrottleCheckType) *Client {
61-
initThrottleTicker()
62-
return &Client{
63-
throttler: throttler,
64-
appName: appName,
65-
checkType: checkType,
66-
flags: CheckFlags{
67-
LowPriority: false,
68-
},
69-
}
70-
}
71-
72-
// NewBackgroundClient creates a client suitable for background jobs, which have low priority over production traffic,
73-
// e.g. migration, table pruning, vreplication
59+
// NewBackgroundClient creates a client
7460
func NewBackgroundClient(throttler *Throttler, appName throttlerapp.Name, checkType ThrottleCheckType) *Client {
7561
initThrottleTicker()
7662
return &Client{
7763
throttler: throttler,
7864
appName: appName,
7965
checkType: checkType,
80-
flags: CheckFlags{
81-
LowPriority: true,
82-
},
66+
flags: CheckFlags{},
8367
}
8468
}
8569

go/vt/vttablet/tabletserver/throttle/throttler.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ const (
9393
aggregatedMetricsExpiration = 5 * time.Second
9494
recentAppsExpiration = time.Hour * 24
9595

96-
nonDeprioritizedAppMapExpiration = time.Second
97-
9896
dormantPeriod = time.Minute // How long since last check to be considered dormant
9997
DefaultAppThrottleDuration = time.Hour
10098
DefaultThrottleRatio = 1.0
@@ -208,8 +206,7 @@ type Throttler struct {
208206

209207
readSelfThrottleMetric func(context.Context, *mysql.Probe) *mysql.MySQLThrottleMetric // overwritten by unit test
210208

211-
nonLowPriorityAppRequestsThrottled *cache.Cache
212-
httpClient *http.Client
209+
httpClient *http.Client
213210
}
214211

215212
// ThrottlerStatus published some status values from the throttler
@@ -256,7 +253,6 @@ func NewThrottler(env tabletenv.Env, srvTopoServer srvtopo.Server, ts *topo.Serv
256253
throttler.aggregatedMetrics = cache.New(aggregatedMetricsExpiration, 0)
257254
throttler.recentApps = cache.New(recentAppsExpiration, 0)
258255
throttler.metricsHealth = cache.New(cache.NoExpiration, 0)
259-
throttler.nonLowPriorityAppRequestsThrottled = cache.New(nonDeprioritizedAppMapExpiration, 0)
260256

261257
throttler.httpClient = base.SetupHTTPClient(2 * mysqlCollectInterval)
262258
throttler.initThrottleTabletTypes()
@@ -728,7 +724,6 @@ func (throttler *Throttler) Operate(ctx context.Context, wg *sync.WaitGroup) {
728724
primaryStimulatorRateLimiter.Stop()
729725
throttler.aggregatedMetrics.Flush()
730726
throttler.recentApps.Flush()
731-
throttler.nonLowPriorityAppRequestsThrottled.Flush()
732727
wg.Done()
733728
}()
734729
// we do not flush throttler.throttledApps because this is data submitted by the user; the user expects the data to survive a disable+enable

go/vt/vttablet/tabletserver/throttle/throttler_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ func newTestThrottler() *Throttler {
157157
throttler.aggregatedMetrics = cache.New(10*aggregatedMetricsExpiration, 0)
158158
throttler.recentApps = cache.New(recentAppsExpiration, 0)
159159
throttler.metricsHealth = cache.New(cache.NoExpiration, 0)
160-
throttler.nonLowPriorityAppRequestsThrottled = cache.New(nonDeprioritizedAppMapExpiration, 0)
161160
throttler.metricsQuery.Store(metricsQuery)
162161
throttler.initThrottleTabletTypes()
163162
throttler.check = NewThrottlerCheck(throttler)

0 commit comments

Comments
 (0)