Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): turn starts in long threads no longer stall the server #21585

Closedbompus(GitHub profile, opens in a new tab)wants to merge 4 commits intomain fromrefs/pull/21585/headopened View on GitHub

Showing 5 changed files with 53 additions and 1 deletion (loading 2).

x
0 of 5 viewed, 5 left
39 additions and 0 deletionsapps/server/src/orchestration-v2/ProjectionRecovery.test.tsModified
View file
@@ -21,6 +21,7 @@
import * as Effect from "effect/Effect";
import * as Layer from "effect/Layer";
import * as SqlClient from "effect/sql/SqlClient";
+import * as Tracer from "effect/Tracer";
​
import * as SqlitePersistence from "../persistence/Sqlite.ts";
import * as ServerSettings from "../serverSettings.ts";
@@ -369,6 +370,44 @@
}).pipe(Effect.provide(layerTest)),
​
+it.effect("looks up a thread's unfinished turn items without reading its finished history", () =>
+ Effect.gen(function* () {
+ const projections = yield* ProjectionStore.ProjectionStoreV2;
+ const sql = yield* SqlClient.SqlClient;
+ const threadId = yield* createThread("unfinished-item-lookups");
+ yield* createRun(threadId, "running");
+ const statements: Array<string> = [];
+ const tracer = Tracer.make({
+ span(options) {
+ const span = new Tracer.NativeSpan(options);
+ const end = span.end.bind(span);
+ span.end = (endTime, exit) => {
+ end(endTime, exit);
+ const query = span.attributes.get("db.query.text");
+ if (typeof query === "string") statements.push(query);
+ };
+ return span;