Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(server): index unfinished work during startup recovery #20302

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

Showing 4 changed files with 61 additions and 8 deletions (loading 1).

x
0 of 4 viewed, 4 left
43 additions and 0 deletionsapps/server/src/orchestration-v2/ProjectionStore.test.tsModified
View file
@@ -3158,6 +3158,49 @@
+ it.effect("selects runtime recovery candidates without scanning historical runs", () =>
+ Effect.gen(function* () {
+ const store = yield* ProjectionStore.ProjectionStoreV2;
+ const sql = yield* SqlClient.SqlClient;
+ yield* addRolledBackRecoveryCandidate("indexed-candidates");
+ const { statements, tracer } = traceSqlStatements();
+ yield* store.getRecoveryThreadIds("runtime").pipe(Effect.withTracer(tracer));
+ const statement = statements.find((query) => query.includes("WITH pending_provider_threads"));
+ assert.isDefined(statement);
+ const plan = yield* sql.unsafe<{ readonly detail: string }>(
+ `EXPLAIN QUERY PLAN ${statement}`,
+ );
+ const runScans = plan.filter((row) =>
+ /(?:SCAN|SEARCH) orchestration_v2_projection_runs /.test(row.detail),
+ );
+ assert.isNotEmpty(runScans);
+ for (const { detail } of runScans) assert.include(detail, "runs_recovery_idx");
+ }),
+ );
+​
+ it.effect("recovers provider threads without walking finished turn items", () =>
+ Effect.gen(function* () {
+ const store = yield* ProjectionStore.ProjectionStoreV2;
+ const sql = yield* SqlClient.SqlClient;
+ const threadId = yield* addRolledBackRecoveryCandidate("indexed-runtime");
+ const { statements, tracer } = traceSqlStatements();