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

server: sync on SQL setting overrides in testserver tenant init #110789

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions pkg/server/settingswatcher/settings_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ type SettingsWatcher struct {
// testingWatcherKnobs allows the client to inject testing knobs into
// the underlying rangefeedcache.Watcher.
testingWatcherKnobs *rangefeedcache.TestingKnobs

// rfc provides access to the underlying rangefeedcache.Watcher for
// testing.
rfc *rangefeedcache.Watcher
}

// Storage is used to write a snapshot of KVs out to disk for use upon restart.
Expand Down Expand Up @@ -216,6 +220,7 @@ func (s *SettingsWatcher) Start(ctx context.Context) error {
},
s.testingWatcherKnobs,
)
s.rfc = c

// Kick off the rangefeedcache which will retry until the stopper stops.
if err := rangefeedcache.Start(ctx, s.stopper, c, func(err error) {
Expand Down Expand Up @@ -243,6 +248,12 @@ func (s *SettingsWatcher) Start(ctx context.Context) error {
}
}

func (w *SettingsWatcher) TestingRestart() {
if w.rfc != nil {
w.rfc.TestingRestart()
}
}

func (s *SettingsWatcher) handleKV(
ctx context.Context, kv *kvpb.RangeFeedValue,
) rangefeedbuffer.Event {
Expand Down
11 changes: 11 additions & 0 deletions pkg/server/tenantsettingswatcher/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ type Watcher struct {
// startCh is closed once the rangefeed starts.
startCh chan struct{}
startErr error

// rfc provides access to the underlying rangefeedcache.Watcher for
// testing.
rfc *rangefeedcache.Watcher
}

// New constructs a new Watcher.
Expand Down Expand Up @@ -182,6 +186,7 @@ func (w *Watcher) startRangeFeed(
onUpdate,
nil, /* knobs */
)
w.rfc = c

// Kick off the rangefeedcache which will retry until the stopper stops.
if err := rangefeedcache.Start(ctx, w.stopper, c, onError); err != nil {
Expand Down Expand Up @@ -215,6 +220,12 @@ func (w *Watcher) WaitForStart(ctx context.Context) error {
}
}

func (w *Watcher) TestingRestart() {
if w.rfc != nil {
w.rfc.TestingRestart()
}
}

// GetTenantOverrides returns the current overrides for the given tenant, and a
// channel that will be closed when the overrides for this tenant change.
//
Expand Down
4 changes: 4 additions & 0 deletions pkg/server/testserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,10 @@ func (ts *testServer) waitForTenantReadinessImpl(
// waiting out the closed timestamp interval required to see new updates.
ts.node.tenantInfoWatcher.TestingRestart()

// Ditto for cluster settings and setting overrides.
ts.sqlServer.settingsWatcher.TestingRestart()
ts.node.tenantSettingsWatcher.TestingRestart()

log.Infof(ctx, "waiting for rangefeed to catch up with record for tenant %v", tenantID)

// Wait for the watcher to handle the complete update from the initial scan
Expand Down