Skip to content

Commit

Permalink
Merge #70242 #70278
Browse files Browse the repository at this point in the history
70242: democluster: shorten the scheduled jobs initial delay r=dt,knz a=otan

Release note (cli change): cockroach demo will now begin processing
scheduled jobs after 15s, instead of the 2-5min in a production
environment.

70278: logictest: attempt to deflake "disallow full scans" test r=yuzefovich a=yuzefovich

We've seen a couple of flakes on the testing of "disallow full scans"
feature although I couldn't reproduce it manually. In an attempt to
deflake the test, this commit increases the corresponding session
variable as well as injects the stats manually instead of analyzing the
table (to have more tight control over events).

Fixes: #70012.

Release note: None

Co-authored-by: Oliver Tan <[email protected]>
Co-authored-by: Yahor Yuzefovich <[email protected]>
  • Loading branch information
3 people committed Sep 15, 2021
3 parents f278e64 + 2081218 + ee9b47b commit 0fda751
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 5 deletions.
1 change: 1 addition & 0 deletions pkg/cli/democluster/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ go_library(
"//pkg/cli/clierror",
"//pkg/cli/cliflags",
"//pkg/cli/democluster/api",
"//pkg/jobs",
"//pkg/kv/kvserver/liveness/livenesspb",
"//pkg/roachpb:with-mocks",
"//pkg/rpc",
Expand Down
7 changes: 7 additions & 0 deletions pkg/cli/democluster/demo_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/base"
"github.com/cockroachdb/cockroach/pkg/cli/clierror"
"github.com/cockroachdb/cockroach/pkg/cli/cliflags"
"github.com/cockroachdb/cockroach/pkg/jobs"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/liveness/livenesspb"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/rpc"
Expand Down Expand Up @@ -645,6 +646,12 @@ func (demoCtx *Context) testServerArgsForTransientCluster(
Server: &server.TestingKnobs{
StickyEngineRegistry: stickyEngineRegistry,
},
JobsTestingKnobs: &jobs.TestingKnobs{
// Allow the scheduler daemon to start earlier in demo.
SchedulerDaemonInitialScanDelay: func() time.Duration {
return time.Second * 15
},
},
},
}

Expand Down
1 change: 1 addition & 0 deletions pkg/cli/democluster/demo_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ func TestTestServerArgsForTransientCluster(t *testing.T) {
// We cannot compare these.
actual.Stopper = nil
actual.StoreSpecs = nil
actual.Knobs.JobsTestingKnobs = nil

assert.Equal(t, tc.expected, actual)
})
Expand Down
37 changes: 32 additions & 5 deletions pkg/sql/logictest/testdata/logic_test/select
Original file line number Diff line number Diff line change
Expand Up @@ -724,9 +724,11 @@ SELECT * FROM t44132 WHERE c0
true NULL

# Tests for `disallow_full_table_scans`
statement ok
SET CLUSTER SETTING sql.stats.automatic_collection.enabled = false

statement ok
CREATE TABLE t_disallow_scans(a INT, b INT, INDEX b_idx(b));
INSERT INTO t_disallow_scans VALUES (1, 1), (2, 1), (3, 1)

statement ok
SELECT * FROM t_disallow_scans
Expand All @@ -741,11 +743,35 @@ SELECT * FROM t_disallow_scans
statement error pq: query `SELECT \* FROM t_disallow_scans@b_idx` contains a full table/index scan which is explicitly disallowed
SELECT * FROM t_disallow_scans@b_idx

# Disable 'large_full_scan_rows' heuristic and analyze the table in order to
# Disable 'large_full_scan_rows' heuristic and inject the stats in order to
# test 'disallow_full_table_scans' in isolation.
statement ok
SET large_full_scan_rows = 0;
ANALYZE t_disallow_scans

statement ok
ALTER TABLE t_disallow_scans INJECT STATISTICS '[
{
"columns": ["rowid"],
"created_at": "2021-09-15 19:38:46.017315",
"distinct_count": 3,
"null_count": 0,
"row_count": 3
},
{
"columns": ["b"],
"created_at": "2021-09-15 19:38:46.017315",
"distinct_count": 1,
"null_count": 0,
"row_count": 3
},
{
"columns": ["a"],
"created_at": "2021-09-15 19:38:46.017315",
"distinct_count": 3,
"null_count": 0,
"row_count": 3
}
]'

statement error pq: query `SELECT \* FROM t_disallow_scans` contains a full table/index scan which is explicitly disallowed
SELECT * FROM t_disallow_scans
Expand All @@ -762,7 +788,7 @@ SELECT * FROM crdb_internal.jobs

# Tests for 'large_full_scan_rows'.
statement ok
SET large_full_scan_rows = 4
SET large_full_scan_rows = 1000

# These queries succeed because the full table/index scans aren't considered
# "large".
Expand All @@ -784,7 +810,8 @@ SELECT * FROM t_disallow_scans@b_idx
# Cleanup
statement ok
SET disallow_full_table_scans = false;
RESET large_full_scan_rows
RESET large_full_scan_rows;
RESET CLUSTER SETTING sql.stats.automatic_collection.enabled;

# Regression test for #58104.
statement ok
Expand Down

0 comments on commit 0fda751

Please sign in to comment.