Skip to content

Commit 6d1b8fb

Browse files
d-csclaude
andcommitted
chore(run-engine): harden retry-window test against cold connects, distinguish fallback failure logs
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 0cbaddc commit 6d1b8fb

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

internal-packages/run-engine/src/engine/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1956,8 +1956,7 @@ export class RunEngine {
19561956
if (useReplica && e instanceof ExecutionSnapshotNotFoundError) {
19571957
// Replica lag: the runner learned this snapshot id from the writer before the
19581958
// replica caught up. Give the replica one jittered retry, then serve from the
1959-
// writer; only count/warn if a retry succeeds (a permanent miss is a real error,
1960-
// not lag).
1959+
// writer; a miss on the writer too is a real error, not lag.
19611960
const { minMs, maxMs } = this.snapshotsSinceReplicaRetryDelay;
19621961
if (maxMs > 0) {
19631962
await setTimeout(minMs + Math.random() * Math.max(0, maxMs - minMs));
@@ -1974,7 +1973,7 @@ export class RunEngine {
19741973
: replicaRetryError,
19751974
runId,
19761975
snapshotId,
1977-
retriedFromReplica: true,
1976+
failedDuring: "replica_retry",
19781977
});
19791978
return null;
19801979
}
@@ -1995,7 +1994,7 @@ export class RunEngine {
19951994
message: retryError instanceof Error ? retryError.message : retryError,
19961995
runId,
19971996
snapshotId,
1998-
retriedFromReplica: true,
1997+
failedDuring: "primary_fallback",
19991998
});
20001999
return null;
20012000
}

internal-packages/run-engine/src/engine/tests/getSnapshotsSince.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,10 @@ describe("RunEngine getSnapshotsSince", () => {
989989

990990
const firstSnapshot = allSnapshots[0];
991991

992+
// Warm the replica connection so the engine's first attempt is a fast point
993+
// read - a cold Prisma connect could outlast the 100ms seeding window below.
994+
await schemaOnlyPrisma.$queryRaw`SELECT 1`;
995+
992996
// Kick off the poll against the still-empty replica, then seed the replica
993997
// well before the ~400ms jittered retry fires - simulating the replica
994998
// catching up while the engine waits.

0 commit comments

Comments
 (0)