Skip to content

Commit 07e5902

Browse files
committed
sql: harden recent change about DO block recursion
This commit reduces the max depth of recursion when evaluating routines with `tail-call-optimization-enabled=false` (recently added in 7b879ef) from 10k to 100. We've just seen a few cases where TestRandomSyntaxSQLSmith failed because DO block didn't respect context cancellation within 5s. I've manually tried it out a few times, and things worked, so my hypothesis is that extremely deep stacks (that are produced with the TCO disabled) is the root cause for slow cancellation, so let's just error out sooner. This commit also brings back the skip of DO blocks in TestComposeCompare (thinking there is that we should stabilize them in other tests first). Release note: None
1 parent 738c039 commit 07e5902

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

pkg/compose/compare/compare/compare_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,13 @@ func TestCompare(t *testing.T) {
7979
}
8080
configs := map[string]testConfig{
8181
"mutators": {
82-
setup: sqlsmith.Setups[sqlsmith.RandTableSetupName],
83-
opts: []sqlsmith.SmitherOption{sqlsmith.CompareMode()},
82+
setup: sqlsmith.Setups[sqlsmith.RandTableSetupName],
83+
opts: []sqlsmith.SmitherOption{
84+
sqlsmith.CompareMode(),
85+
// TODO(yuzefovich): perhaps allow DO blocks again after they
86+
// have been stabilized in other tests.
87+
sqlsmith.DisableDoBlocks(),
88+
},
8489
ignoreSQLErrors: true,
8590
conns: []testConn{
8691
{

pkg/sql/routine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func (p *planner) EvalRoutineExpr(
163163
if routineDepthValue := ctx.Value(routineDepthKey{}); routineDepthValue != nil {
164164
routineDepth = routineDepthValue.(int)
165165
}
166-
const maxDepth = 10000
166+
const maxDepth = 100
167167
if routineDepth > maxDepth {
168168
return nil, pgerror.Newf(pgcode.ProgramLimitExceeded,
169169
"routine reached recursion depth limit: %d (probably infinite loop)", maxDepth)

0 commit comments

Comments
 (0)