Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): V2 event writes no longer fail when another process commits mid-transaction #14365

Closedsaphid(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/14365/headopened View on GitHub

Showing 3 changed files with 120 additions and 7 deletions.

x
0 of 3 viewed, 3 left
15 additions and 7 deletionsapps/server/src/orchestration-v2/EventSink.tsModified
View file
@@ -23,6 +23,7 @@
​
import { replayAndBufferProjectedLiveEvents } from "./LiveStreamBudget.ts";
import type { UnsequencedProjectEvent } from "../persistence/Services/OrchestrationEventStore.ts";
+import { withWriteTransaction } from "./writeTransaction.ts";
import { projectDomainEventForWire } from "./WireProjection.ts";
​
import * as CommandReceiptStore from "./CommandReceiptStore.ts";
@@ -332,7 +333,8 @@
"orchestration_v2.thread_id": input.events[0]?.threadId ?? null,
});
​
- const storedEvents = yield* sql.withTransaction(
+ const storedEvents = yield* withWriteTransaction(
+ sql,
Effect.gen(function* () {
const normalized = yield* normalizeEvents(
input.guardPendingUserInputCancellations === true
@@ -365,7 +367,8 @@
"orchestration_v2.thread_id": input.threadId,
});
​
- const result = yield* sql.withTransaction(
+ const result = yield* withWriteTransaction(
+ sql,
Effect.gen(function* () {
const rows = yield* sql<{
readonly status: string;