Skip to content

Commit 2a6a541

Browse files
committed
changefeedccl: deflake TestChangefeedSchemaTTL
Previously, TestChangefeedSchemaTTL started flaking when create_table_with_schema_locked was enabled by default in the test suite. This happened because schema_locked tables can cause historical versions of descriptors to be cached in the lease manager, as the changefeed logic intentionally queries prior versions. As a result, even after the test garbage-collected the descriptors table, these old versions could remain in the in-memory cache, leading to flakes. To address this, this patch adds a canary schema change, which bumps the descriptor's version. When a descriptor's version is bumped, all older cached versions are purged. Fixes: #149167 Release note: None
1 parent 7635297 commit 2a6a541

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pkg/ccl/changefeedccl/changefeed_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7043,6 +7043,7 @@ func TestChangefeedSchemaTTL(t *testing.T) {
70437043
// Create the data table; it will only contain a single row with multiple
70447044
// versions.
70457045
sqlDB.Exec(t, `CREATE TABLE foo (a INT PRIMARY KEY, b STRING)`)
7046+
sqlDB.Exec(t, `CREATE USER joe`)
70467047

70477048
counter := 0
70487049
upsertRow := func() {
@@ -7073,6 +7074,15 @@ func TestChangefeedSchemaTTL(t *testing.T) {
70737074
// table to be deleted, with the middle version being lost to the changefeed.
70747075
forceTableGC(t, s.SystemServer, sqlDB, "system", "descriptor")
70757076

7077+
// Do an unnecessary version bump on the descriptor, which will purge old
7078+
// versions of the descriptor that the lease manager may have cached for
7079+
// historical queries. When schema_locked support is active, the act of
7080+
// detecting polling inside pauseOrResumePolling can cause old versions
7081+
// to be cached. The historical descriptors are cleared everytime a
7082+
// version bump occurs, otherwise this test can flake if the prior versions
7083+
// need to decode a row is already cached.
7084+
waitForSchemaChange(t, sqlDB, "ALTER TABLE foo OWNER TO joe")
7085+
70767086
// Resume our changefeed normally.
70777087
atomic.StoreInt32(&shouldWait, 0)
70787088
resume <- struct{}{}

0 commit comments

Comments
 (0)