Skip to content

Commit

Permalink
scexec: don't set running_status on GC job during init
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rafiss committed Nov 17, 2023
1 parent d108641 commit b7c7deb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 11 additions & 0 deletions pkg/sql/drop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)()
Expand All @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions pkg/sql/schemachanger/scexec/gc_jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,13 @@ func createGCJobRecord(
descriptorIDs = append(descriptorIDs, details.ParentID)
}
}
runningStatus := jobs.RunningStatus("waiting for MVCC GC")
return jobs.Record{
JobID: id,
Description: "GC for " + description,
Username: userName,
DescriptorIDs: descriptorIDs,
Details: details,
Progress: jobspb.SchemaChangeGCProgress{},
RunningStatus: runningStatus,
NonCancelable: true,
}
}

0 comments on commit b7c7deb

Please sign in to comment.