Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(server): return freed database pages to the filesystem #29811

Closedjuliusmarmingewants to merge 5 commits intot3/prune-projected-events fromt3/reclaim-freed-pagesopened View on GitHub

Showing 7 changed files with 41 additions and 1 deletion (loading 4).

x
0 of 7 viewed, 7 left
28 additions and 0 deletionsapps/server/src/orchestration-v2/ThreadSearch.test.tsModified
View file
@@ -24,6 +24,7 @@
import * as ProjectionStore from "./ProjectionStore.ts";
import * as ProjectStore from "./ProjectStore.ts";
import * as ThreadSearch from "./ThreadSearch.ts";
+import { MESSAGE_SEARCH_REBUILD_PENDING } from "./messageSearchIndex.ts";
​
const layerTest = Layer.mergeAll(
ThreadSearch.layer,
@@ -217,6 +218,33 @@
}).pipe(Effect.provide(layerTest)),
​
+it.effect("ThreadSearch scans instead of trusting the index while a rebuild is pending", () =>
+ Effect.gen(function* () {
+ const projections = yield* ProjectionStore.ProjectionStoreV2;
+ const search = yield* ThreadSearch.ThreadSearch;
+ const sql = yield* SqlClient.SqlClient;
+ const project = ProjectId.make("project:pending-rebuild");
+ const threadId = ThreadId.make("thread:pending-rebuild");
+ yield* createProject(project);
+ yield* Effect.forEach(
+ [thread(threadId, project), message(threadId, "kept", "user", "Review the vacuum notes")],
+ projections.apply,
+ { discard: true },
+ );
+ // A VACUUM renumbered rowids and the rebuild after it failed: the index is stale.
+ yield* sql`INSERT INTO orchestration_v2_message_search (orchestration_v2_message_search) VALUES ('delete-all')`;
+ yield* sql`
+ INSERT INTO orchestration_v2_projection_metadata (