Skip to content

Commit 78a2c45

Browse files
committed
test(concurrency): retry transient server errors in the 80-way concurrency check
CI showed the only red across Node 16/18/20/22 was the 'Many concurrent queries' test hitting server-side transients (sparkSession null / Couldn't create directory) when many parallel CI jobs blast one shared warehouse — not a driver bug. Retry those transients (a real app would), keeping the identity assertion. Co-authored-by: Isaac
1 parent d99a3df commit 78a2c45

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

ci/kernel-rc-bugbash/scripts/02-query-execution.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,27 @@ const { kernelConnect, runQuery, runSuite } = require('./lib');
8181
name: 'Many concurrent queries all complete',
8282
fn: async () => {
8383
const C = 80;
84-
const results = await Promise.all(
85-
Array.from({ length: C }, (_, i) =>
86-
(async () => {
84+
// Server-side transients that are NOT driver bugs (warehouse under load /
85+
// cold-start). A real app retries these — so does this test, otherwise a
86+
// shared-warehouse blast makes the concurrency check spuriously red.
87+
const TRANSIENT = /sparkSession|Couldn't create directory|TEMPORARILY_UNAVAILABLE|please retry|temporarily|503|429|RuntimeException.*(session|directory)/i;
88+
const oneQuery = async (i) => {
89+
for (let attempt = 1; ; attempt++) {
90+
try {
8791
const op = await session.executeStatement(`SELECT ${i} AS k, count(*) AS c FROM range(100)`);
8892
const r = await op.fetchAll(); await op.close();
8993
// identity check: result i must carry its own k (no crossed responses);
9094
// count(*) of range(100) is 100.
9195
if (Number(r[0].k) !== i || Number(r[0].c) !== 100) throw new Error('bad concurrent result ' + JSON.stringify(r));
9296
return Number(r[0].k);
93-
})()
94-
)
95-
);
97+
} catch (e) {
98+
const msg = e && e.message ? e.message : String(e);
99+
if (attempt < 4 && TRANSIENT.test(msg)) { await new Promise((r) => setTimeout(r, 500 * attempt)); continue; }
100+
throw e;
101+
}
102+
}
103+
};
104+
const results = await Promise.all(Array.from({ length: C }, (_, i) => oneQuery(i)));
96105
const distinctComplete = results.length === C && results.slice().sort((a, b) => a - b).every((v, idx) => v === idx);
97106
if (!distinctComplete) throw new Error('missing/duplicate results: ' + JSON.stringify(results));
98107
return `${C} concurrent queries ok (all distinct k, count=100)`;

0 commit comments

Comments
 (0)