Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release-24.1: opt: make max-stack opt tester option more reliable #134436

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions pkg/sql/opt/testutils/opttester/opt_tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"sort"
"strconv"
"strings"
"sync"
"testing"
"text/tabwriter"
"time"
Expand Down Expand Up @@ -607,8 +608,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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/opt/xform/testdata/rules/select
Original file line number Diff line number Diff line change
Expand Up @@ -2819,7 +2819,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,
Expand Down