Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
105741: cli: deflake TestUnavailableZip r=ericharmeling a=ericharmeling

Fixes cockroachdb#102018.
Fixes cockroachdb#102986.

This commit adds lines of the form
`[node n] n log files found` to the
eraseNonDeterministicZipOutput function, and
fixes the regex for logged lines of the form
`log file:` to not match on multiple, distinct
logged lines. Prior to this commit, all logged
lines with the string "log file" were being
modified in the expected output.

Release note: None

106263: sql: fix flaky TestSQLStatsDataDriven r=j82w a=j82w

The logical_plan_sampling_for_explicit_txn is rewritten as a standalone end to end test.
1. Improved readability
2. Easier to debug
3. Avoid race condition when multiple subtests run concurrently
4. Avoid flakes by setting tracing setting

Fixes: cockroachdb#98753
Epic: none
Release note: None

Co-authored-by: Eric Harmeling <eric.harmeling@cockroachlabs.com>
Co-authored-by: j82w <jwilley@cockroachlabs.com>
  • Loading branch information
3 people committed Jul 6, 2023
3 parents 845b23a + 13e605f + 701eff2 commit 7c2bc1d
Show file tree
Hide file tree
Showing 13 changed files with 167 additions and 147 deletions.
18 changes: 9 additions & 9 deletions pkg/cli/testdata/zip/partial1
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ debug zip --concurrency=1 --cpu-profile-duration=0s /dev/null
[node 1] requesting goroutine dump list... received response...
[node 1] requesting goroutine dump list: last request failed: rpc error: ...
[node 1] requesting goroutine dump list: creating error output: debug/nodes/1/goroutines.err.txt... done
[node 1] requesting log file ...
[node 1] 1 log file ...
[node 1] [log file ...
[node 1] requesting log files list... received response... done
[node ?] ? log files found
[node 1] [log file: ...
[node 1] requesting ranges... received response... done
[node 1] writing ranges... writing JSON output: debug/nodes/1/ranges.json... done
[node 2] node status... writing JSON output: debug/nodes/2/status.json... done
Expand Down Expand Up @@ -211,9 +211,9 @@ debug zip --concurrency=1 --cpu-profile-duration=0s /dev/null
[node 2] requesting goroutine dump list... received response...
[node 2] requesting goroutine dump list: last request failed: rpc error: ...
[node 2] requesting goroutine dump list: creating error output: debug/nodes/2/goroutines.err.txt... done
[node 2] requesting log file ...
[node 2] requesting log file ...
[node 2] requesting log file ...
[node 2] requesting log files list... received response...
[node 2] requesting log files list: last request failed: rpc error: ...
[node 2] requesting log files list: creating error output: debug/nodes/2/logs.err.txt... done
[node 2] requesting ranges... received response...
[node 2] requesting ranges: last request failed: rpc error: ...
[node 2] requesting ranges: creating error output: debug/nodes/2/ranges.err.txt... done
Expand Down Expand Up @@ -253,9 +253,9 @@ debug zip --concurrency=1 --cpu-profile-duration=0s /dev/null
[node 3] requesting goroutine dump list... received response...
[node 3] requesting goroutine dump list: last request failed: rpc error: ...
[node 3] requesting goroutine dump list: creating error output: debug/nodes/3/goroutines.err.txt... done
[node 3] requesting log file ...
[node 3] 1 log file ...
[node 3] [log file ...
[node 3] requesting log files list... received response... done
[node ?] ? log files found
[node 3] [log file: ...
[node 3] requesting ranges... received response... done
[node 3] writing ranges... writing JSON output: debug/nodes/3/ranges.json... done
[cluster] pprof summary script... writing binary output: debug/pprof-summary.sh... done
Expand Down
12 changes: 6 additions & 6 deletions pkg/cli/testdata/zip/partial1_excluded
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ debug zip /dev/null --concurrency=1 --exclude-nodes=2 --cpu-profile-duration=0
[node 1] requesting goroutine dump list... received response...
[node 1] requesting goroutine dump list: last request failed: rpc error: ...
[node 1] requesting goroutine dump list: creating error output: debug/nodes/1/goroutines.err.txt... done
[node 1] requesting log file ...
[node 1] 1 log file ...
[node 1] [log file ...
[node 1] requesting log files list... received response... done
[node ?] ? log files found
[node 1] [log file: ...
[node 1] requesting ranges... received response... done
[node 1] writing ranges... writing JSON output: debug/nodes/1/ranges.json... done
[node 2] skipping node... writing binary output: debug/nodes/2.skipped... done
Expand Down Expand Up @@ -156,9 +156,9 @@ debug zip /dev/null --concurrency=1 --exclude-nodes=2 --cpu-profile-duration=0
[node 3] requesting goroutine dump list... received response...
[node 3] requesting goroutine dump list: last request failed: rpc error: ...
[node 3] requesting goroutine dump list: creating error output: debug/nodes/3/goroutines.err.txt... done
[node 3] requesting log file ...
[node 3] 1 log file ...
[node 3] [log file ...
[node 3] requesting log files list... received response... done
[node ?] ? log files found
[node 3] [log file: ...
[node 3] requesting ranges... received response... done
[node 3] writing ranges... writing JSON output: debug/nodes/3/ranges.json... done
[cluster] pprof summary script... writing binary output: debug/pprof-summary.sh... done
Expand Down
12 changes: 6 additions & 6 deletions pkg/cli/testdata/zip/partial2
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ debug zip --concurrency=1 --cpu-profile-duration=0 /dev/null
[node 1] requesting goroutine dump list... received response...
[node 1] requesting goroutine dump list: last request failed: rpc error: ...
[node 1] requesting goroutine dump list: creating error output: debug/nodes/1/goroutines.err.txt... done
[node 1] requesting log file ...
[node 1] 1 log file ...
[node 1] [log file ...
[node 1] requesting log files list... received response... done
[node ?] ? log files found
[node 1] [log file: ...
[node 1] requesting ranges... received response... done
[node 1] writing ranges... writing JSON output: debug/nodes/1/ranges.json... done
[node 3] node status... writing JSON output: debug/nodes/3/status.json... done
Expand Down Expand Up @@ -155,9 +155,9 @@ debug zip --concurrency=1 --cpu-profile-duration=0 /dev/null
[node 3] requesting goroutine dump list... received response...
[node 3] requesting goroutine dump list: last request failed: rpc error: ...
[node 3] requesting goroutine dump list: creating error output: debug/nodes/3/goroutines.err.txt... done
[node 3] requesting log file ...
[node 3] 1 log file ...
[node 3] [log file ...
[node 3] requesting log files list... received response... done
[node ?] ? log files found
[node 3] [log file: ...
[node 3] requesting ranges... received response... done
[node 3] writing ranges... writing JSON output: debug/nodes/3/ranges.json... done
[cluster] pprof summary script... writing binary output: debug/pprof-summary.sh... done
Expand Down
4 changes: 2 additions & 2 deletions pkg/cli/testdata/zip/testzip
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ debug zip --concurrency=1 --cpu-profile-duration=1s /dev/null
[node ?] ? heap profiles found
[node 1] requesting goroutine dump list... received response... done
[node ?] ? goroutine dumps found
[node 1] requesting log file ...
[node 1] 0 log file ...
[node 1] requesting log files list... received response... done
[node ?] ? log files found
[node 1] requesting ranges... received response... done
[node 1] writing ranges... writing JSON output: debug/nodes/1/ranges.json... done
[cluster] pprof summary script... writing binary output: debug/pprof-summary.sh... done
Expand Down
48 changes: 24 additions & 24 deletions pkg/cli/testdata/zip/testzip_concurrent
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,10 @@ zip
[cluster] using SQL address: ...
[cluster] using SQL address: ...
[cluster] using SQL address: ...
[node 1] 1 log file ...
[node 1] [log file ...
[node 1] [log file ...
[node 1] [log file ...
[node 1] [log file ...
[node 1] [log file: ...
[node 1] [log file: ...
[node 1] [log file: ...
[node 1] [log file: ...
[node 1] node status...
[node 1] node status: done
[node 1] node status: writing JSON output: debug/nodes/1/status.json...
Expand Down Expand Up @@ -273,9 +272,9 @@ zip
[node 1] requesting heap profile: done
[node 1] requesting heap profile: received response...
[node 1] requesting heap profile: writing binary output: debug/nodes/1/heap.pprof...
[node 1] requesting log file ...
[node 1] requesting log file ...
[node 1] requesting log file ...
[node 1] requesting log files list...
[node 1] requesting log files list: done
[node 1] requesting log files list: received response...
[node 1] requesting ranges...
[node 1] requesting ranges: done
[node 1] requesting ranges: received response...
Expand Down Expand Up @@ -357,11 +356,10 @@ zip
[node 1] writing ranges...
[node 1] writing ranges: done
[node 1] writing ranges: writing JSON output: debug/nodes/1/ranges.json...
[node 2] 1 log file ...
[node 2] [log file ...
[node 2] [log file ...
[node 2] [log file ...
[node 2] [log file ...
[node 2] [log file: ...
[node 2] [log file: ...
[node 2] [log file: ...
[node 2] [log file: ...
[node 2] node status...
[node 2] node status: done
[node 2] node status: writing JSON output: debug/nodes/2/status.json...
Expand Down Expand Up @@ -391,9 +389,9 @@ zip
[node 2] requesting heap profile: done
[node 2] requesting heap profile: received response...
[node 2] requesting heap profile: writing binary output: debug/nodes/2/heap.pprof...
[node 2] requesting log file ...
[node 2] requesting log file ...
[node 2] requesting log file ...
[node 2] requesting log files list...
[node 2] requesting log files list: done
[node 2] requesting log files list: received response...
[node 2] requesting ranges...
[node 2] requesting ranges: done
[node 2] requesting ranges: received response...
Expand Down Expand Up @@ -475,11 +473,10 @@ zip
[node 2] writing ranges...
[node 2] writing ranges: done
[node 2] writing ranges: writing JSON output: debug/nodes/2/ranges.json...
[node 3] 1 log file ...
[node 3] [log file ...
[node 3] [log file ...
[node 3] [log file ...
[node 3] [log file ...
[node 3] [log file: ...
[node 3] [log file: ...
[node 3] [log file: ...
[node 3] [log file: ...
[node 3] node status...
[node 3] node status: done
[node 3] node status: writing JSON output: debug/nodes/3/status.json...
Expand Down Expand Up @@ -509,9 +506,9 @@ zip
[node 3] requesting heap profile: done
[node 3] requesting heap profile: received response...
[node 3] requesting heap profile: writing binary output: debug/nodes/3/heap.pprof...
[node 3] requesting log file ...
[node 3] requesting log file ...
[node 3] requesting log file ...
[node 3] requesting log files list...
[node 3] requesting log files list: done
[node 3] requesting log files list: received response...
[node 3] requesting ranges...
[node 3] requesting ranges: done
[node 3] requesting ranges: received response...
Expand Down Expand Up @@ -593,4 +590,7 @@ zip
[node 3] writing ranges...
[node 3] writing ranges: done
[node 3] writing ranges: writing JSON output: debug/nodes/3/ranges.json...
[node ?] ? log files found
[node ?] ? log files found
[node ?] ? log files found
debug zip --timeout=30s --cpu-profile-duration=0s /dev/null
4 changes: 2 additions & 2 deletions pkg/cli/testdata/zip/testzip_external_process_virtualization
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ debug zip --concurrency=1 --cpu-profile-duration=1s /dev/null
[node ?] ? heap profiles found
[node 1] requesting goroutine dump list... received response... done
[node ?] ? goroutine dumps found
[node 1] requesting log file ...
[node 1] 0 log file ...
[node 1] requesting log files list... received response... done
[node ?] ? log files found
[node 1] requesting ranges... received response...
[node 1] requesting ranges: last request failed: rpc error: ...
[node 1] requesting ranges: creating error output: debug/nodes/1/ranges.err.txt... done
Expand Down
4 changes: 2 additions & 2 deletions pkg/cli/testdata/zip/testzip_include_range_info
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ debug zip --concurrency=1 --cpu-profile-duration=1s --include-range-info /dev/nu
[node ?] ? heap profiles found
[node 1] requesting goroutine dump list... received response... done
[node ?] ? goroutine dumps found
[node 1] requesting log file ...
[node 1] 0 log file ...
[node 1] requesting log files list... received response... done
[node ?] ? log files found
[node 1] requesting ranges... received response... done
[node 1] writing ranges... writing JSON output: debug/nodes/1/ranges.json... done
[cluster] pprof summary script... writing binary output: debug/pprof-summary.sh... done
Expand Down
8 changes: 4 additions & 4 deletions pkg/cli/testdata/zip/testzip_shared_process_virtualization
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ debug zip --concurrency=1 --cpu-profile-duration=1s /dev/null
[node ?] ? heap profiles found
[node 1] requesting goroutine dump list... received response... done
[node ?] ? goroutine dumps found
[node 1] requesting log file ...
[node 1] 0 log file ...
[node 1] requesting log files list... received response... done
[node ?] ? log files found
[node 1] requesting ranges... received response... done
[node 1] writing ranges... writing JSON output: debug/nodes/1/ranges.json... done
[cluster] pprof summary script... writing binary output: debug/pprof-summary.sh... done
Expand Down Expand Up @@ -270,8 +270,8 @@ debug zip --concurrency=1 --cpu-profile-duration=1s /dev/null
[node 1] requesting goroutine dump list... received response...
[node 1] requesting goroutine dump list: last request failed: rpc error: ...
[node 1] requesting goroutine dump list: creating error output: debug/virtual/test-tenant/nodes/1/goroutines.err.txt... done
[node 1] requesting log file ...
[node 1] 0 log file ...
[node 1] requesting log files list... received response... done
[node ?] ? log files found
[node 1] requesting ranges... received response...
[node 1] requesting ranges: last request failed: rpc error: ...
[node 1] requesting ranges: creating error output: debug/virtual/test-tenant/nodes/1/ranges.err.txt... done
Expand Down
6 changes: 3 additions & 3 deletions pkg/cli/testdata/zip/unavailable
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,9 @@ debug zip --concurrency=1 --cpu-profile-duration=0 /dev/null --timeout=.5s
[node 1] requesting goroutine dump list... received response...
[node 1] requesting goroutine dump list: last request failed: ...
[node 1] requesting goroutine dump list: creating error output: debug/nodes/1/goroutines.err.txt... done
[node 1] requesting log file ...
[node 1] 1 log file ...
[node 1] [log file ...
[node 1] requesting log files list... received response... done
[node ?] ? log files found
[node 1] [log file: ...
[node 1] requesting ranges... received response... done
[node 1] writing ranges... writing JSON output: debug/nodes/1/ranges.json... done
[cluster] pprof summary script... writing binary output: debug/pprof-summary.sh... done
Expand Down
6 changes: 4 additions & 2 deletions pkg/cli/zip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,8 @@ func eraseNonDeterministicZipOutput(out string) string {
out = re.ReplaceAllString(out, `postgresql://...`)
re = regexp.MustCompile(`(?m)SQL address: .*$`)
out = re.ReplaceAllString(out, `SQL address: ...`)
re = regexp.MustCompile(`(?m)log file.*$`)
out = re.ReplaceAllString(out, `log file ...`)
re = regexp.MustCompile(`(?m)log file:.*$`)
out = re.ReplaceAllString(out, `log file: ...`)
re = regexp.MustCompile(`(?m)RPC connection to .*$`)
out = re.ReplaceAllString(out, `RPC connection to ...`)
re = regexp.MustCompile(`(?m)dial tcp .*$`)
Expand All @@ -395,6 +395,8 @@ func eraseNonDeterministicZipOutput(out string) string {
out = re.ReplaceAllString(out, `[node ?] ? heap profiles found`)
re = regexp.MustCompile(`(?m)^\[node \d+\] \d+ goroutine dumps found$`)
out = re.ReplaceAllString(out, `[node ?] ? goroutine dumps found`)
re = regexp.MustCompile(`(?m)^\[node \d+\] \d+ log files found$`)
out = re.ReplaceAllString(out, `[node ?] ? log files found`)
re = regexp.MustCompile(`(?m)^\[node \d+\] retrieving (memprof|memstats).*$` + "\n")
out = re.ReplaceAllString(out, ``)
re = regexp.MustCompile(`(?m)^\[node \d+\] writing profile.*$` + "\n")
Expand Down
1 change: 1 addition & 0 deletions pkg/sql/sqlstats/persistedsqlstats/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ go_test(
"//pkg/util/stop",
"//pkg/util/syncutil",
"//pkg/util/timeutil",
"//pkg/util/uuid",
"@com_github_cockroachdb_datadriven//:datadriven",
"@com_github_cockroachdb_errors//:errors",
"@com_github_stretchr_testify//require",
Expand Down
Loading

0 comments on commit 7c2bc1d

Please sign in to comment.