Skip to content

Commit 90ae675

Browse files
craig[bot]yuzefovich
andcommitted
Merge #149637
149637: sqlccl: log cancelled stmts in TestExplainGist r=yuzefovich a=yuzefovich We just saw a test failure that wasn't reproducible by simply rerunning the test with the seed that was reported on the issue. This is the case since we have some non-determinism in sqlsmith that we haven't fully fleshed out. This test is aware of the non-determinism, so it attempts to keep track of the successful stmts which are printed out on a test failure, but in this case this was also insufficient. The query that hit an internal error attempts to reference a column that isn't in the CREATE TABLE, so it must have been added as a schema change, but we don't see it in the log of successful statements. TestExplainGist executes all stmts with 0.1s statement timeout (because initially it was envisioned as the stress of plan-gist logic, so we wanted to have some change in the DB state, but we didn't care much whether all changes would actually apply), so many schema changes are probably canceled before they can complete. This commit makes it so that we now also track all such cancelled statements which we print out in the commented out form on a test failure. Additionally, this commit skips a couple of known test failures that have reproductions to reduce the noise. Informs: #149552. Epic: None Release note: None Co-authored-by: Yahor Yuzefovich <[email protected]>
2 parents 2a6e468 + c9e0e49 commit 90ae675

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

pkg/ccl/testccl/sqlccl/explain_test.go

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,23 @@ func TestExplainGist(t *testing.T) {
160160

161161
// Given that statement timeout might apply differently between test
162162
// runs with the same seed (e.g. because of different CPU load), we'll
163-
// accumulate all successful statements for ease of reproduction.
164-
var successfulStmts strings.Builder
165-
logStmt := func(stmt string) {
166-
successfulStmts.WriteString(stmt)
167-
successfulStmts.WriteString(";\n")
163+
// accumulate all statements for ease of reproduction.
164+
var stmts strings.Builder
165+
logStmt := func(stmt string, successful bool) {
166+
if !successful {
167+
// Comment out the canceled stmt since its effects might not
168+
// have applied, but we still might need to know it for
169+
// reproduction.
170+
//
171+
// Also replace newline characters with tabs so that it takes
172+
// only a single line.
173+
stmt = "-- cancelled:\t" + strings.ReplaceAll(stmt, "\n", "\t")
174+
}
175+
stmts.WriteString(stmt)
176+
stmts.WriteString(";\n")
168177
}
169178
for _, stmt := range setup {
170-
logStmt(stmt)
179+
logStmt(stmt, true /* successful */)
171180
}
172181

173182
smither, err := sqlsmith.NewSmither(sqlDB, rng, sqlsmith.SimpleNames())
@@ -190,15 +199,17 @@ func TestExplainGist(t *testing.T) {
190199
if err != nil && strings.Contains(err.Error(), "internal error") {
191200
// Ignore all errors except the internal ones.
192201
for _, knownErr := range []string{
193-
"expected equivalence dependants to be its closure", // #119045
202+
"expected equivalence dependants to be its closure", // #119045
203+
"argument expression has type RECORD, need type USER DEFINED RECORD", // #139910
204+
"not in index", // #148405
194205
} {
195206
if strings.Contains(err.Error(), knownErr) {
196207
// Don't fail the test on a set of known errors.
197208
return
198209
}
199210
}
200-
t.Log(successfulStmts.String())
201-
t.Fatalf("%v: %s", err, stmt)
211+
t.Log(stmts.String())
212+
t.Fatalf("%v:\n%s;", err, stmt)
202213
}
203214
}
204215

@@ -288,11 +299,12 @@ func TestExplainGist(t *testing.T) {
288299
case err = <-errCh:
289300
if err != nil {
290301
checkErr(err, stmt)
302+
logStmt(stmt, false /* successful */)
291303
} else {
292-
logStmt(stmt)
304+
logStmt(stmt, true /* successful */)
293305
}
294306
case <-time.After(time.Minute):
295-
t.Log(successfulStmts.String())
307+
t.Log(stmts.String())
296308
sl := allstacks.Get()
297309
t.Logf("stacks:\n\n%s", sl)
298310
t.Fatalf("stmt wasn't canceled by statement_timeout of 0.1s - ran at least for 1m: %s", stmt)

0 commit comments

Comments
 (0)