Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): thread list reads no longer freeze the server on large databases #19226

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/19226/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Showing 5 changed files with 21 additions and 11 deletions (loading 2).

x
0 of 5 viewed, 5 left
11 additions and 7 deletionsapps/server/src/orchestration-v2/ShellStream.tsModified
View file
@@ -12,6 +12,7 @@
OrchestrationProjectShell as ProjectShellSchema,
OrchestrationV2ThreadShell as ThreadShellSchema,
} from "@t3tools/contracts";
+import * as NodeSqliteClient from "@t3tools/shared/nodeSqliteClient";
import * as Clock from "effect/Clock";
import * as Effect from "effect/Effect";
import * as Schema from "effect/Schema";
@@ -46,13 +47,16 @@
readonly latestSequence: Effect.Effect<number, E4>;
}) =>
Effect.gen(function* () {
- const read = yield* input.sql.withTransaction(
- Effect.all({
- decodeThreads: input.readThreads,
- projects: input.listProjects,
- snapshotSequence: input.latestSequence,
- }),
- );
+ // Read on the reader worker, off the event loop and the writer.
+ const read = yield* input.sql
+ .withTransaction(
+ Effect.all({
+ decodeThreads: input.readThreads,
+ projects: input.listProjects,
+ snapshotSequence: input.latestSequence,
+ }),
+ )
+ .pipe(NodeSqliteClient.readOnly);