Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
137055: loq: clear LeadEpoch when re-writing the RangeDescriptor r=iskettaneh a=iskettaneh

If the fortified leader is removed from the RangeDescriptor, SupportFor() will return epoch=0. This will fire an assertion since supportFor epochs should never regress.
This commit changes the LoQ behaviour where it resets the LeadEpoch when rewriting the ReplicaDescriptor.

Fixes: #136908

Release note: None

137137: roachtest: use updated update_tenant_resource_limits signature in 24.2.1+ r=srosenberg a=DarrylWong

The function signature of update_tenant_resource_limits was changed in v24.2.1 to deprecate the args "as_of" and "as_of_consumed_tokens". Since serverless currently only uses the `tenant_id` overload and not the `tenant_name` overload like we do in mixedversion, the args were removed completely from the latter.

This breaks backwards compatibility so this change selectively omits the removed args if the version is 24.2.1+.

Fixes: none
Epic: none
Release note: none

Co-authored-by: Ibrahim Kettaneh <[email protected]>
Co-authored-by: DarrylWong <[email protected]>
  • Loading branch information
3 people committed Dec 10, 2024
3 parents 2ebc611 + 4bd1fbc + e439d73 commit 57273c7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
5 changes: 5 additions & 0 deletions pkg/cmd/roachtest/roachtestutil/mixedversion/mixedversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,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 {
Expand Down
7 changes: 7 additions & 0 deletions pkg/cmd/roachtest/roachtestutil/mixedversion/steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,13 @@ func (s disableRateLimitersStep) Run(
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)
}

Expand Down
13 changes: 13 additions & 0 deletions pkg/kv/kvserver/loqrecovery/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,19 @@ func applyReplicaUpdate(
return PrepareReplicaReport{}, errors.Wrap(err, "updating MVCCStats")
}

// Update the HardState to clear the LeadEpoch, as otherwise we may risk
// seeing an epoch regression in raft. See #136908 for more details.
hs, err := sl.LoadHardState(ctx, readWriter)
if err != nil {
return PrepareReplicaReport{}, errors.Wrap(err, "loading HardState")
}

hs.LeadEpoch = 0

if err := sl.SetHardState(ctx, readWriter, hs); err != nil {
return PrepareReplicaReport{}, errors.Wrap(err, "setting HardState")
}

return report, nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/kv/kvserver/loqrecovery/server_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ func TestRetrieveApplyStatus(t *testing.T) {

// We currently don't clear out the LeadEpoch field when recovering from a
// loss of quorum, so we can't run with leader leases on in this test.
tc, _, _ := prepTestCluster(ctx, t, 5, true /* disableLeaderLease */)
tc, _, _ := prepTestCluster(ctx, t, 5, false /* disableLeaderLease */)
defer tc.Stopper().Stop(ctx)

// Use scratch range to ensure we have a range that loses quorum.
Expand Down

0 comments on commit 57273c7

Please sign in to comment.