Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
125324: logictestccl: deflake TestTenantLogic_jobs r=rafiss a=rafiss

By adding a row into the table before dropping it, we can ensure that the schema change GC job will not complete immediately. It needs to wait for the table data to be removed according to the gc.ttl.

While we're here, mark a status string as safe for non-redaction.

fixes cockroachdb#125212
Release note: None

Co-authored-by: Rafi Shamim <[email protected]>
  • Loading branch information
craig[bot] and rafiss committed Jun 7, 2024
2 parents 6032d53 + a6f53a8 commit f94be0c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
13 changes: 8 additions & 5 deletions pkg/jobs/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,17 +162,20 @@ func init() {
// Status represents the status of a job in the system.jobs table.
type Status string

// SafeFormat implements redact.SafeFormatter.
func (s Status) SafeFormat(sp redact.SafePrinter, verb rune) {
sp.SafeString(redact.SafeString(s))
}
// SafeValue implements redact.SafeValue.
func (s Status) SafeValue() {}

var _ redact.SafeFormatter = Status("")
var _ redact.SafeValue = Status("")

// RunningStatus represents the more detailed status of a running job in
// the system.jobs table.
type RunningStatus string

// SafeValue implements redact.SafeValue.
func (s RunningStatus) SafeValue() {}

var _ redact.SafeValue = RunningStatus("")

const (
// StatusPending is `for jobs that have been created but on which work has
// not yet started.
Expand Down
22 changes: 16 additions & 6 deletions pkg/sql/logictest/testdata/logic_test/jobs
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,17 @@ SELECT count(*) FROM [SHOW AUTOMATIC JOBS] WHERE job_type = 'POLL JOBS STATS' AN

subtest control_job_priv

skip 125212

user testuser

statement ok
CREATE TABLE t_control_job_priv(x INT);
CREATE TABLE t_control_job_priv(x INT)

# Add a row into the table so that the GC job does not complete immediately;
# it must wait for the table data gc.ttl before removing the descriptor.
statement ok
INSERT INTO t_control_job_priv VALUES (1)

statement ok
DROP TABLE t_control_job_priv

let $job_id
Expand Down Expand Up @@ -303,12 +308,17 @@ subtest end

subtest control_job_priv_inherited

skip 125212

user testuser

statement ok
CREATE TABLE t_control_job_priv_inherited(x INT);
CREATE TABLE t_control_job_priv_inherited(x INT)

# Add a row into the table so that the GC job does not complete immediately;
# it must wait for the table data gc.ttl before removing the descriptor.
statement ok
INSERT INTO t_control_job_priv_inherited VALUES (1)

statement ok
DROP TABLE t_control_job_priv_inherited

let $job_id
Expand Down
4 changes: 4 additions & 0 deletions pkg/testutils/lint/passes/redactcheck/redactcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ func runAnalyzer(pass *analysis.Pass) (interface{}, error) {
"sz": {},
"timing": {},
},
"github.com/cockroachdb/cockroach/pkg/jobs": {
"RunningStatus": {},
"Status": {},
},
"github.com/cockroachdb/cockroach/pkg/jobs/jobspb": {
"Type": {},
},
Expand Down

0 comments on commit f94be0c

Please sign in to comment.