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

ccl/changefeedccl/cdcevent: Fix flake in TestEventColumnOrderingWithSchemaChanges #137334

Merged
merged 1 commit into from
Dec 12, 2024
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
1 change: 1 addition & 0 deletions pkg/ccl/changefeedccl/cdcevent/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ go_test(
"//pkg/sql/schemachanger/scplan",
"//pkg/sql/sem/eval",
"//pkg/sql/sem/tree",
"//pkg/sql/sqltestutils",
"//pkg/sql/types",
"//pkg/testutils/serverutils",
"//pkg/testutils/skip",
Expand Down
16 changes: 14 additions & 2 deletions pkg/ccl/changefeedccl/cdcevent/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scplan"
"github.com/cockroachdb/cockroach/pkg/sql/sem/eval"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/sqltestutils"
"github.com/cockroachdb/cockroach/pkg/sql/types"
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils"
"github.com/cockroachdb/cockroach/pkg/testutils/skip"
Expand Down Expand Up @@ -595,7 +596,12 @@ func TestEventColumnOrderingWithSchemaChanges(t *testing.T) {
kvserver.RangefeedEnabled.Override(ctx, &l.ClusterSettings().SV, true)
}

// Be aggressive with the SCHEMA CHANGE GC job. For tests involving column
// rewrites, this job must run for the tests to succeed. Its execution
// triggers RangeFeedDeleteRange events.
sqlDB := sqlutils.MakeSQLRunner(db)
defer sqltestutils.DisableGCTTLStrictEnforcement(t, db)()
sqlDB.Exec(t, "SET CLUSTER SETTING jobs.registry.interval.adopt='1s'")

type decodeExpectation struct {
expectUnwatchedErr bool
Expand Down Expand Up @@ -730,8 +736,9 @@ func TestEventColumnOrderingWithSchemaChanges(t *testing.T) {
},
} {
t.Run(tc.testName, func(t *testing.T) {
sqlDB.Exec(t, `
CREATE TABLE foo (
sqlDB.ExecMultiple(t,
`DROP TABLE IF EXISTS foo`,
`CREATE TABLE foo (
i INT,
j INT,
a STRING,
Expand All @@ -748,6 +755,9 @@ func TestEventColumnOrderingWithSchemaChanges(t *testing.T) {
popRow, cleanup := cdctest.MakeRangeFeedValueReaderExtended(t, s.ExecutorConfig(), tableDesc)
defer cleanup()

_, err := sqltestutils.AddImmediateGCZoneConfig(db, tableDesc.GetID())
require.NoError(t, err)

targetType := jobspb.ChangefeedTargetSpecification_EACH_FAMILY
if tc.familyName != "" {
targetType = jobspb.ChangefeedTargetSpecification_COLUMN_FAMILY
Expand All @@ -769,8 +779,10 @@ func TestEventColumnOrderingWithSchemaChanges(t *testing.T) {
require.NoError(t, err)

expectedEvents := len(tc.expectMainFamily) + len(tc.expectECFamily)
log.Infof(ctx, "expectedEvents: %d\n", expectedEvents)
for i := 0; i < expectedEvents; i++ {
v, deleteRange := popRow(t)
log.Infof(ctx, "event[%d]: v=%+v, deleteRange=%+v", i, v, deleteRange)

if deleteRange != nil {
// Should not see a RangeFeedValue and a RangeFeedDeleteRange
Expand Down
Loading