From b7c7deb45948678da1447afcd4129dd025c98f6b Mon Sep 17 00:00:00 2001 From: Rafi Shamim Date: Fri, 17 Nov 2023 18:12:20 -0500 Subject: [PATCH] scexec: don't set running_status on GC job during init The running_status is only supposed to be set while the job is running, so it was a mistake to set it when creating the job. Not setting it also deflakes a test which relies on the running_status to know if the GC has begun (and deleting the data has completed). Release note: None --- pkg/sql/drop_test.go | 11 +++++++++++ pkg/sql/schemachanger/scexec/gc_jobs.go | 2 -- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/sql/drop_test.go b/pkg/sql/drop_test.go index 285470ac2bd3..19581f8e8ca4 100644 --- a/pkg/sql/drop_test.go +++ b/pkg/sql/drop_test.go @@ -417,6 +417,14 @@ func TestDropIndex(t *testing.T) { s, sqlDB, kvDB := serverutils.StartServer(t, params) defer s.Stopper().Stop(context.Background()) + _, err := sqlDB.Exec(`SET CLUSTER SETTING sql.gc_job.wait_for_gc.interval = '1s';`) + require.NoError(t, err) + + // Refresh protected timestamp cache immediately to make MVCC GC queue to + // process GC immediately. + _, err = sqlDB.Exec(`SET CLUSTER SETTING kv.protectedts.poll_interval = '1s';`) + require.NoError(t, err) + // Disable strict GC TTL enforcement because we're going to shove a zero-value // TTL into the system with AddImmediateGCZoneConfig. defer sqltestutils.DisableGCTTLStrictEnforcement(t, sqlDB)() @@ -426,6 +434,9 @@ func TestDropIndex(t *testing.T) { t.Fatal(err) } tableDesc := desctestutils.TestingGetPublicTableDescriptor(kvDB, keys.SystemSQLCodec, "t", "kv") + if _, err := sqltestutils.AddImmediateGCZoneConfig(sqlDB, tableDesc.GetID()); err != nil { + t.Fatal(err) + } tests.CheckKeyCount(t, kvDB, tableDesc.TableSpan(keys.SystemSQLCodec), 3*numRows) idx, err := catalog.MustFindIndexByName(tableDesc, "foo") if err != nil { diff --git a/pkg/sql/schemachanger/scexec/gc_jobs.go b/pkg/sql/schemachanger/scexec/gc_jobs.go index 226746b978a3..f32854cfb227 100644 --- a/pkg/sql/schemachanger/scexec/gc_jobs.go +++ b/pkg/sql/schemachanger/scexec/gc_jobs.go @@ -233,7 +233,6 @@ func createGCJobRecord( descriptorIDs = append(descriptorIDs, details.ParentID) } } - runningStatus := jobs.RunningStatus("waiting for MVCC GC") return jobs.Record{ JobID: id, Description: "GC for " + description, @@ -241,7 +240,6 @@ func createGCJobRecord( DescriptorIDs: descriptorIDs, Details: details, Progress: jobspb.SchemaChangeGCProgress{}, - RunningStatus: runningStatus, NonCancelable: true, } }