Skip to content

Commit d5d7fa1

Browse files
d-csclaude
andcommitted
fix(run-ops split): route idempotent-run waitpoint block and batch-service prisma to the resolved store
- Block the idempotent parent run's waitpoint via the residency-resolved dedup client instead of the fallback prisma, so the write lands on the store that owns the parent run. - Pass the caller-provided _prisma into WithRunEngine so a custom store isn't silently overridden by the module singleton. - Throw when a run-backed alert's environment can't be resolved instead of marking it SENT, so a transient replica miss doesn't permanently suppress the alert. - Pin splitEnabled:false in the waitpoint passthrough test so it exercises single-DB behaviour rather than relying on ksuid residency. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 6027677 commit d5d7fa1

4 files changed

Lines changed: 23 additions & 17 deletions

File tree

apps/webapp/app/runEngine/concerns/idempotencyKeys.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ export class IdempotencyKeyConcern {
287287
: undefined,
288288
projectId: request.environment.projectId,
289289
organizationId: request.environment.organizationId,
290-
tx: this.prisma,
290+
tx: dedupClient,
291291
});
292292
}
293293
);

apps/webapp/app/runEngine/services/batchTrigger.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class RunEngineBatchTriggerService extends WithRunEngine {
7171
protected readonly _prisma: PrismaClientOrTransaction = prisma,
7272
engine?: RunEngine
7373
) {
74-
super({ prisma, engine });
74+
super({ prisma: _prisma, engine });
7575

7676
// Eric note: We need to force sequential processing because when doing parallel, we end up with high-contention on the parent run lock
7777
// becuase we are triggering a lot of runs at once, and each one is trying to lock the parent run.

apps/webapp/app/v3/services/alerts/deliverAlert.server.ts

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -190,26 +190,31 @@ export class DeliverAlertService extends BaseService {
190190
const env = await this.#controlPlaneResolver.resolveAuthenticatedEnv(
191191
resolvedTaskRun.runtimeEnvironmentId
192192
);
193+
194+
if (!env) {
195+
throw new Error(
196+
`Could not resolve environment ${resolvedTaskRun.runtimeEnvironmentId} for alert ${alertId}`
197+
);
198+
}
199+
193200
const lockedWorker = await this.#controlPlaneResolver.resolveRunLockedWorker({
194201
lockedById: resolvedTaskRun.lockedById,
195202
lockedToVersionId: resolvedTaskRun.lockedToVersionId,
196203
});
197204

198-
if (env) {
199-
taskRun = {
200-
...resolvedTaskRun,
201-
runtimeEnvironment: { type: env.type, branchName: env.branchName },
202-
lockedBy: lockedWorker?.lockedBy
203-
? {
204-
filePath: lockedWorker.lockedBy.filePath,
205-
exportName: lockedWorker.lockedBy.exportName,
206-
}
207-
: null,
208-
lockedToVersion: lockedWorker?.lockedToVersion
209-
? { version: lockedWorker.lockedToVersion.version }
210-
: null,
211-
};
212-
}
205+
taskRun = {
206+
...resolvedTaskRun,
207+
runtimeEnvironment: { type: env.type, branchName: env.branchName },
208+
lockedBy: lockedWorker?.lockedBy
209+
? {
210+
filePath: lockedWorker.lockedBy.filePath,
211+
exportName: lockedWorker.lockedBy.exportName,
212+
}
213+
: null,
214+
lockedToVersion: lockedWorker?.lockedToVersion
215+
? { version: lockedWorker.lockedToVersion.version }
216+
: null,
217+
};
213218
}
214219
}
215220

apps/webapp/test/resolveWaitpointThroughReadThrough.readthrough.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ describe("resolveWaitpointThroughReadThrough (hetero PG14 legacy + dedicated run
230230
environmentId: environment.id,
231231
read: read(id, environment.id),
232232
deps: {
233+
splitEnabled: false,
233234
newClient: single.handle,
234235
legacyReplica: legacy.handle,
235236
},

0 commit comments

Comments
 (0)