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

release-24.3: roachtest: disable rate limiters in mixedversion #137528

Merged
merged 2 commits into from
Dec 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -209,6 +209,11 @@ var (
// would *not* make the tenant auto upgrade.
tenantSupportsAutoUpgradeVersion = clusterupgrade.MustParseVersion("v24.2.0-alpha.00000000")

// updateTenantResourceLimitsDeprecatedArgsVersion is the lowest version
// after which the "as_of" and "as_of_consumed_tokens" arguments were removed when
// using the `tenant_name` overload.
updateTenantResourceLimitsDeprecatedArgsVersion = clusterupgrade.MustParseVersion("v24.2.1")

// Catch divergences between `stepFunc` and `Run`'s signature in
// `singleStepProtocol` at compile time.
_ = func() stepFunc {
4 changes: 4 additions & 0 deletions pkg/cmd/roachtest/roachtestutil/mixedversion/planner.go
Original file line number Diff line number Diff line change
@@ -627,6 +627,10 @@ func (p *testPlanner) tenantSetupSteps(v *clusterupgrade.Version) []testStep {
virtualClusterName: p.tenantName(),
systemVisible: true,
}))

steps = append(steps, p.newSingleStepWithContext(setupContext, disableRateLimitersStep{
virtualClusterName: p.tenantName(),
}))
}

if shouldGrantCapabilities {
57 changes: 57 additions & 0 deletions pkg/cmd/roachtest/roachtestutil/mixedversion/steps.go
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ package mixedversion
import (
"context"
"fmt"
"math"
"math/rand"
"strings"
"time"
@@ -547,6 +548,62 @@ func (s deleteAllTenantsVersionOverrideStep) Run(
return h.System.Exec(rng, stmt, 0, "version")
}

// disableRateLimitersStep disables both the KV and the tenant(SQL) rate limiter
// for the given virtual cluster. This step is necessary for separate process
// tenants to avoid rate limiting which can cause tests to hang and fail.
//
// N.B. This step is not needed for shared process tenants as they already opt out
// of both rate limiters. Shared process tenants are by default not subject to the
// tenant rate limiter, as they create a `noopTenantSideCostController`. Shared process
// tenants are automatically granted all tenant capabilities as of v24.1 which includes
// exemption from the kv rate limiter. For older versions, the mvt framework already
// handles granting said capabilities (see: TenantsAndSystemAlignedSettingsVersion).
type disableRateLimitersStep struct {
virtualClusterName string
}

func (s disableRateLimitersStep) Background() shouldStop { return nil }

func (s disableRateLimitersStep) Description() string {
return fmt.Sprintf("disable KV and tenant(SQL) rate limiter on %s tenant", s.virtualClusterName)
}

func (s disableRateLimitersStep) Run(
ctx context.Context, l *logger.Logger, rng *rand.Rand, h *Helper,
) error {
// Disable the KV rate limiter.
stmt := fmt.Sprintf(
"ALTER TENANT %q GRANT CAPABILITY exempt_from_rate_limiting = true",
s.virtualClusterName,
)
if err := h.System.Exec(rng, stmt); err != nil {
return err
}

const (
availableTokens = math.MaxFloat64
refillRate = math.MaxFloat64
maxBurstTokens = 0 // 0 disables the limit.
)

// Disable the tenant rate limiter. Unlike the KV rate limiter, there is no way
// to outright disable the tenant rate limiter. Instead, we instead set the tenant's
// resource limits to an arbitrarily high value.
stmt = fmt.Sprintf(
"SELECT crdb_internal.update_tenant_resource_limits('%s', %v, %v, %d, now(), 0);",
s.virtualClusterName, availableTokens, refillRate, maxBurstTokens,
)

if h.System.FromVersion.AtLeast(updateTenantResourceLimitsDeprecatedArgsVersion) {
stmt = fmt.Sprintf(
"SELECT crdb_internal.update_tenant_resource_limits('%s', %v, %v, %d);",
s.virtualClusterName, availableTokens, refillRate, maxBurstTokens,
)
}

return h.System.Exec(rng, stmt)
}

// nodesRunningAtLeast returns a list of nodes running a system or
// tenant virtual cluster in a version that is guaranteed to be at
// least `minVersion`. It assumes that the caller made sure that there
Loading