diff --git a/pkg/sql/opt/testutils/opttester/opt_tester.go b/pkg/sql/opt/testutils/opttester/opt_tester.go index 72c819b56de7..f232805da0e9 100644 --- a/pkg/sql/opt/testutils/opttester/opt_tester.go +++ b/pkg/sql/opt/testutils/opttester/opt_tester.go @@ -23,6 +23,7 @@ import ( "sort" "strconv" "strings" + "sync" "testing" "text/tabwriter" "time" @@ -591,8 +592,23 @@ func (ot *OptTester) RunCommand(tb testing.TB, d *datadriven.TestData) string { if ot.Flags.MaxStackBytes > 0 { originalMaxStack := debug.SetMaxStack(ot.Flags.MaxStackBytes) defer debug.SetMaxStack(originalMaxStack) + // Spawn a separate goroutine. A fresh stack makes tests using this + // setting more reliable. + var wg sync.WaitGroup + wg.Add(1) + var res string + go func() { + defer wg.Done() + res = ot.runCommandInternal(tb, d) + }() + wg.Wait() + return res + } else { + return ot.runCommandInternal(tb, d) } +} +func (ot *OptTester) runCommandInternal(tb testing.TB, d *datadriven.TestData) string { switch d.Cmd { case "exec-ddl": testCatalog, ok := ot.catalog.(*testcat.Catalog) diff --git a/pkg/sql/opt/xform/testdata/rules/select b/pkg/sql/opt/xform/testdata/rules/select index 4e5e57bee44c..4b1a2c6bfc73 100644 --- a/pkg/sql/opt/xform/testdata/rules/select +++ b/pkg/sql/opt/xform/testdata/rules/select @@ -2820,7 +2820,7 @@ CREATE TABLE t132669 ( # unnecessary recursion to trigger a stack overflow without having to make the # `IN` list below huge - triggering a stack overflow with Go's default max stack # size requires a list of ~1.6 million elements. -opt max-stack=125KB format=hide-all +opt max-stack=100kB skip-race format=hide-all SELECT * FROM t132669 WHERE a IN ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,