Skip to content

Commit 34923c6

Browse files
committed
cli: explicitly set disallow_full_table_scans for debug.zips
Fixes: #151183 Release note (bug fix): Fix a bug where debug.zips collected from clusters with disallow_full_table_scans set would have missing system table data.
1 parent f966877 commit 34923c6

File tree

3 files changed

+90
-0
lines changed

3 files changed

+90
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
zip
2+
----
3+
debug zip --concurrency=1 --cpu-profile-duration=0 /dev/null
4+
[cluster] discovering virtual clusters... done
5+
[cluster] creating output file /dev/null... done
6+
[cluster] establishing RPC connection to ...
7+
[cluster] using SQL address: ...
8+
[cluster] requesting data for debug/events... received response... writing JSON output: debug/events.json... done
9+
[cluster] requesting data for debug/rangelog... received response... writing JSON output: debug/rangelog.json... done
10+
[cluster] requesting data for debug/settings... received response... writing JSON output: debug/settings.json... done
11+
[cluster] requesting data for debug/reports/problemranges... received response... writing JSON output: debug/reports/problemranges.json... done
12+
<dumping SQL tables>
13+
[cluster] requesting nodes... received response... writing JSON output: debug/nodes.json... done
14+
[cluster] requesting liveness... received response... writing JSON output: debug/liveness.json... done
15+
[cluster] requesting tenant ranges... received response...
16+
[cluster] requesting tenant ranges: last request failed: rpc error: ...
17+
[cluster] requesting tenant ranges: creating error output: debug/tenant_ranges.err.txt... done
18+
[cluster] collecting the inflight traces for jobs... received response... done
19+
[node 1] node status... writing JSON output: debug/nodes/1/status.json... done
20+
[node 1] using SQL connection URL: postgresql://...
21+
<dumping SQL tables>
22+
[node 1] requesting data for debug/nodes/1/details... received response... writing JSON output: debug/nodes/1/details.json... done
23+
[node 1] requesting data for debug/nodes/1/gossip... received response... writing JSON output: debug/nodes/1/gossip.json... done
24+
[node 1] requesting stacks... received response... writing binary output: debug/nodes/1/stacks.txt... done
25+
[node 1] requesting stacks with labels... received response... writing binary output: debug/nodes/1/stacks_with_labels.txt... done
26+
[node 1] requesting heap profile... received response... writing binary output: debug/nodes/1/heap.pprof... done
27+
[node 1] requesting engine stats... received response... writing binary output: debug/nodes/1/lsm.txt... done
28+
[node 1] requesting heap profile list... received response... done
29+
[node ?] ? heap profiles found
30+
[node 1] requesting goroutine dump list... received response... done
31+
[node ?] ? goroutine dumps found
32+
[node 1] requesting cpu profile list... received response... done
33+
[node ?] ? cpu profiles found
34+
[node 1] requesting execution trace list... received response... done
35+
[node ?] ? execution traces found
36+
[node 1] requesting log files list... received response... done
37+
[node ?] ? log files found
38+
[node 1] requesting ranges... received response... done
39+
[node 1] writing ranges... writing JSON output: debug/nodes/1/ranges.json... done
40+
[cluster] pprof summary script... writing binary output: debug/pprof-summary.sh... done
41+
[cluster] hot range summary script... writing binary output: debug/hot-ranges.sh... done
42+
[cluster] tenant hot range summary script... writing binary output: debug/hot-ranges-tenant.sh... done
43+
[cluster] capture debug zip flags... writing binary output: debug/debug_zip_command_flags.txt... done
44+
[cluster] The generated file /dev/null is corrupt. Please retry debug zip generation. error: zip: not a valid zip file
45+
ERROR: zip: not a valid zip file

pkg/cli/zip.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,12 @@ func (zc *debugZipContext) dumpTableDataForZip(
594594
return err
595595
}
596596

597+
// Many of the table data queries use full scans, so allow them.
598+
err = conn.Exec(ctx, `SET disallow_full_table_scans = off`)
599+
if err != nil {
600+
return err
601+
}
602+
597603
w, err := zc.z.createLocked(name, time.Time{})
598604
if err != nil {
599605
return err

pkg/cli/zip_test.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,45 @@ func TestPartialZip(t *testing.T) {
807807
})
808808
}
809809

810+
// TestZipDisallowFullScans tests that we still can dump full SQL tables for
811+
// debug.zips when the cluster has disallow_full_table_scans enabled.
812+
func TestZipDisallowFullScans(t *testing.T) {
813+
defer leaktest.AfterTest(t)()
814+
defer log.Scope(t).Close(t)
815+
816+
skip.UnderShort(t)
817+
skip.UnderRace(t)
818+
819+
dir, cleanupFn := testutils.TempDir(t)
820+
defer cleanupFn()
821+
822+
c := NewCLITest(TestCLIParams{
823+
StoreSpecs: []base.StoreSpec{{
824+
Path: dir,
825+
}},
826+
})
827+
defer c.Cleanup()
828+
829+
c.RunWithArgs([]string{"sql", "-e", `
830+
SET CLUSTER SETTING sql.defaults.disallow_full_table_scans.enabled = on;
831+
SET CLUSTER SETTING sql.defaults.large_full_scan_rows = 1;
832+
`})
833+
834+
out, err := c.RunWithCapture("debug zip --concurrency=1 --cpu-profile-duration=0 " + os.DevNull)
835+
if err != nil {
836+
t.Fatal(err)
837+
}
838+
839+
// Strip any non-deterministic messages.
840+
out = eraseNonDeterministicZipOutput(out)
841+
842+
// We use datadriven simply to read the golden output file; we don't actually
843+
// run any commands. Using datadriven allows TESTFLAGS=-rewrite.
844+
datadriven.RunTest(t, datapathutils.TestDataPath(t, "zip", "testzip_disallow_full_scans"), func(t *testing.T, td *datadriven.TestData) string {
845+
return out
846+
})
847+
}
848+
810849
// This checks that SQL retry errors are properly handled.
811850
func TestZipRetries(t *testing.T) {
812851
defer leaktest.AfterTest(t)()

0 commit comments

Comments
 (0)