{"record":{"id":"79d54cf5d3f2a7d7","repo":"santifer/career-ops","slug":"concurrent-reservation-test-flaked-e-message-retrying-once","errorCode":null,"errorMessage":"concurrent reservation test flaked (${e.message}). Retrying once...","messagePattern":"concurrent reservation test flaked \\((.+?)\\)\\. Retrying once\\.\\.\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"test-all.mjs","lineNumber":10152,"sourceCode":"        let stdout = '';\n        child.stdout.on('data', chunk => { stdout += chunk; });\n        child.on('close', () => resolve(stdout.trim()));\n      });\n      const [rangeX, rangeY] = await Promise.all([spawnReserve(), spawnReserve()]);\n      const toNums = r => {\n        const [s, e] = r.split('-').map(Number);\n        return Array.from({ length: e - s + 1 }, (_, i) => s + i);\n      };\n      const overlap = toNums(rangeX).filter(n => toNums(rangeY).includes(n));\n      if (rangeX && rangeY && overlap.length === 0) {\n        pass(`concurrent --count 4 reservations are disjoint (${rangeX} vs ${rangeY})`);\n      } else {\n        throw new Error(`concurrent ranges overlap: ${rangeX} vs ${rangeY} share [${overlap}]`);\n      }\n      break;\n    } catch (e) {\n      if (reserveRetries > 0) {\n        warn(`concurrent reservation test flaked (${e.message}). Retrying once...`);\n        reserveRetries -= 1;\n      } else {\n        fail(`concurrent reservation test failed: ${e.message}`);\n        break;\n      }\n    } finally {\n      rmSync(concTmp, { recursive: true, force: true });\n    }\n  }\n\n  // --release with a range deletes every sentinel in it.\n  const reserveRunFail = (args, dir) => {\n    try {\n      execFileSync(NODE, [RESERVE, ...args], {\n        encoding: 'utf-8',\n        stdio: ['pipe', 'pipe', 'pipe'],\n        env: { ...process.env, CAREER_OPS_REPORTS_DIR: dir, CAREER_OPS_TRACKER: join(dir, 'applications.md') },\n      });","sourceCodeStart":10134,"sourceCodeEnd":10170,"githubUrl":"https://github.com/santifer/career-ops/blob/e7abd431fce9348a95261acac9e0c14779c35df8/test-all.mjs#L10134-L10170","documentation":"test-all.mjs stress-tests reserve-report-num.mjs by spawning concurrent reservations and asserting the returned ranges never overlap. Because concurrent file-based allocation can transiently collide, the test wraps the assertion in a retry loop: the first failure logs this warning and retries once; only a second consecutive failure is recorded as a real test failure.","triggerScenarios":"Two concurrent reservation workers return ranges X and Y sharing an overlap, or another assertion inside the try throws — on the first attempt while reserveRetries > 0, producing this warning; a second failure calls fail().","commonSituations":"Heavily loaded CI runners slowing atomic claim/lock timing, filesystems with weak locking semantics (some network mounts), or a genuine regression in reserve-report-num.mjs's claim-and-release logic (would fail both attempts).","solutions":["If it flakes once and passes on retry, ignore it — that is the designed behavior for timing-sensitive concurrency.","If it fails consistently, debug reserve-report-num.mjs's atomic claim path (sentinels, locks, GC of stale sentinels) with the overlapping ranges from the error message.","Reduce external load or run the concurrency tests on a local filesystem rather than a network mount.","Increase retries locally while bisecting, but do not paper over a deterministic overlap."],"exampleFix":"// before (diagnosis step)\nnode reserve-report-num.mjs --count 4 & node reserve-report-num.mjs --count 4 & wait\n// after (compare the two printed ranges; overlap => bug in claim logic, not a flake)","handlingStrategy":"retry","validationCode":"// pre-flight: ensure the allocator works serially before stressing it\nif (run('node', ['reserve-report-num.mjs', '--count', '1']) === null) fail('allocator broken; skip concurrency stress');","typeGuard":null,"tryCatchPattern":"try { assertNoOverlap(rangeX, rangeY); } catch (e) { if (retries-- > 0) warn(`flaked (${e.message}), retrying`); else fail(e.message); }","preventionTips":["Use local (non-NFS) filesystems for lock-sensitive tests","Reserve report numbers immediately before spawning parallel workers","Keep CI runners from sharing one working tree across shards","Expect one flake-and-retry on loaded machines; investigate only repeat failures"],"tags":["concurrency","flaky-test","race-condition","test-runner"],"backgroundTag":"flaky-concurrency-test","analyzedSha":"e7abd431fce9348a95261acac9e0c14779c35df8","analyzedAt":"2026-09-16T06:35:29.214Z","contentChangedAt":"2026-09-16T06:35:29.214Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}