Skip to content

Commit

Permalink
[release-18.0] Throttler: set timeouts on gRPC communication and on t…
Browse files Browse the repository at this point in the history
…opo communication (#14165) (#14167)

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
  • Loading branch information
vitess-bot[bot] authored Oct 11, 2023
1 parent 22f7509 commit d62e890
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions go/vt/vttablet/tabletserver/throttle/throttler.go
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,10 @@ func (throttler *Throttler) Operate(ctx context.Context) {

func (throttler *Throttler) generateTabletHTTPProbeFunction(ctx context.Context, tmClient tmclient.TabletManagerClient, clusterName string, probe *mysql.Probe) (probeFunc func() *mysql.MySQLThrottleMetric) {
return func() *mysql.MySQLThrottleMetric {
// Some reasonable timeout, to ensure we release connections even if they're hanging (otherwise grpc-go keeps polling those connections forever)
ctx, cancel := context.WithTimeout(ctx, 4*mysqlCollectInterval)
defer cancel()

// Hit a tablet's `check-self` via HTTP, and convert its CheckResult JSON output into a MySQLThrottleMetric
mySQLThrottleMetric := mysql.NewMySQLThrottleMetric()
mySQLThrottleMetric.ClusterName = clusterName
Expand Down Expand Up @@ -872,6 +876,9 @@ func (throttler *Throttler) refreshMySQLInventory(ctx context.Context) error {
}
// The primary tablet is also in charge of collecting the shard's metrics
err := func() error {
ctx, cancel := context.WithTimeout(ctx, mysqlRefreshInterval)
defer cancel()

tabletAliases, err := throttler.ts.FindAllTabletAliasesInShard(ctx, throttler.keyspace, throttler.shard)
if err != nil {
return err
Expand Down

0 comments on commit d62e890

Please sign in to comment.