Skip to content

Commit

Permalink
roachtest: make crdb crash on span-use-after-Finish
Browse files Browse the repository at this point in the history
This patch makes roachtest pass an env var to crdb asking it to panic on
mis-use of tracing spans. I've been battling such bugs, which become
more problematic as I'm trying to introduce span reuse. In production
we'll probably continue tolerating such bugs for the time being, but I
want tests to yell. Unit tests are already running with this
use-after-Finish detection, and so far so good. I've done a manual run
of all the roachtests in this configuration and nothing crashed, so I
don't expect a tragedy.

Release note: None
  • Loading branch information
andreimatei committed Dec 20, 2021
1 parent 8b00b91 commit 84ff073
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion pkg/cmd/roachtest/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1835,6 +1835,23 @@ func (c *clusterImpl) StartE(ctx context.Context, opts ...option.Option) error {
}
}
}

// Set some env vars. The first two also the default for `roachprod start`,
// but we have to add them so that the third one doesn't wipe them out.
if !argExists(args, "COCKROACH_ENABLE_RPC_COMPRESSION") {
// RPC compressions costs around 5% on kv95, so we disable it. It might help
// when moving snapshots around, though.
args = append(args, "--env=COCKROACH_ENABLE_RPC_COMPRESSION=false")
}
if !argExists(args, "COCKROACH_UI_RELEASE_NOTES_SIGNUP_DISMISSED") {
// Get rid of an annoying popup in the UI.
args = append(args, "--env=COCKROACH_UI_RELEASE_NOTES_SIGNUP_DISMISSED=true")
}
if !argExists(args, "COCKROACH_CRASH_ON_SPAN_USE_AFTER_FINISH") {
// Panic on span use-after-Finish, so we catch such bugs.
args = append(args, "--env=COCKROACH_CRASH_ON_SPAN_USE_AFTER_FINISH=true")
}

if err := execCmd(ctx, c.l, args...); err != nil {
return err
}
Expand Down Expand Up @@ -1876,7 +1893,7 @@ func (c *clusterImpl) Start(ctx context.Context, opts ...option.Option) {

func argExists(args []string, target string) bool {
for _, arg := range args {
if arg == target || strings.HasPrefix(arg, target+"=") {
if arg == target || strings.HasPrefix(arg, target+"=") || strings.HasPrefix(arg, "--env="+target+"=") {
return true
}
}
Expand Down

0 comments on commit 84ff073

Please sign in to comment.