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-23.1: spanconfigsqlwatcher: deflake TestSQLWatcherOnEventError #99826

Merged
merged 1 commit into from
Mar 30, 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
Original file line number Diff line number Diff line change
Expand Up @@ -437,18 +437,18 @@ func TestSQLWatcherOnEventError(t *testing.T) {
tdb.Exec(t, `SET CLUSTER SETTING kv.rangefeed.enabled = true`)
tdb.Exec(t, `SET CLUSTER SETTING kv.closed_timestamp.target_duration = '100ms'`)

noopCheckpointDuration := time.Hour // effectively disable no-op checkpoints
sqlWatcher := spanconfigsqlwatcher.New(
keys.SystemSQLCodec,
ts.ClusterSettings(),
ts.RangeFeedFactory().(*rangefeed.Factory),
1<<20, /* 1 MB, bufferMemLimit */
ts.Stopper(),
noopCheckpointDuration,
time.Second, // doesn't matter
&spanconfig.TestingKnobs{
SQLWatcherOnEventInterceptor: func() error {
return errors.New("boom")
},
SQLWatcherSkipNoopCheckpoints: true,
},
)

Expand Down
3 changes: 2 additions & 1 deletion pkg/spanconfig/spanconfigsqlwatcher/sqlwatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ func (s *SQLWatcher) watch(
if err != nil {
return err
}
if len(sqlUpdates) == 0 && !checkpointNoops.ShouldProcess(timeutil.Now()) {
if len(sqlUpdates) == 0 &&
(!checkpointNoops.ShouldProcess(timeutil.Now()) || s.knobs.SQLWatcherSkipNoopCheckpoints) {
continue
}
if err := handler(ctx, sqlUpdates, combinedFrontierTS); err != nil {
Expand Down
4 changes: 4 additions & 0 deletions pkg/spanconfig/testing_knobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ type TestingKnobs struct {
// often the SQLWatcher checkpoints noops.
SQLWatcherCheckpointNoopsEveryDurationOverride time.Duration

// SQLWatcherSkipNoopCheckpoints allows tests to skip no-op checkpoints
// entirely.
SQLWatcherSkipNoopCheckpoints bool

// SplitterStepLogger is used to capture internal steps the splitter is
// making, for debugging and test-readability purposes.
SplitterStepLogger func(string)
Expand Down