Skip to content

Commit

Permalink
roachtest: wait for propagation of tenant cluster settings
Browse files Browse the repository at this point in the history
Fixes #137503.

This commit updates the setTenantSetting utility to wait for the
propagation of the tenant cluster settings to each SQL gateway before
returning. This avoids races where the tenant cluster settings are not
yet propagated to the SQL gateway when the test randomly chooses a
gateway and tries to use it.

Release note: None
  • Loading branch information
nvanbenschoten committed Dec 20, 2024
1 parent 3b46aff commit a376278
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions pkg/cmd/roachtest/tests/mixed_version_change_replicas.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,20 +348,27 @@ func setTenantSetting(
return errors.Wrapf(err, "failed to set %s", name)
}

return testutils.SucceedsSoonError(func() error {
var currentValue bool
if err := h.QueryRow(r, fmt.Sprintf("SHOW CLUSTER SETTING %s", name)).Scan(&currentValue); err != nil {
return errors.Wrapf(err, "failed to retrieve setting %s", name)
}
// Wait for the setting to be visible to all nodes in the tenant.
for _, n := range h.Tenant.Descriptor.Nodes {
db := h.Tenant.Connect(n)
if err := testutils.SucceedsSoonError(func() error {
var currentValue bool
if err := db.QueryRow(fmt.Sprintf("SHOW CLUSTER SETTING %s", name)).Scan(&currentValue); err != nil {
return errors.Wrapf(err, "failed to retrieve setting %s", name)
}

if currentValue != value {
err := fmt.Errorf(
"waiting for setting %s: current (%t) != expected (%t)", name, currentValue, value,
)
l.Printf("%v", err)
return err
}

if currentValue != value {
err := fmt.Errorf(
"waiting for setting %s: current (%t) != expected (%t)", name, currentValue, value,
)
l.Printf("%v", err)
return nil
}); err != nil {
return err
}

return nil
})
}
return nil
}

0 comments on commit a376278

Please sign in to comment.