You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 91fdcbb
Browse filesBrowse the repository at this point in the historyBrowse files
@@ -14,12 +15,14 @@ import { getWorkspaceKnowledgeBases } from '@/lib/knowledge/service'
14
15
15
16
/**
16
17
* A small KB page must not count the rest of its workspace or other tenants before applying
17
-
* its limit. Real query plans catch this even when warm caches hide it from a timing test.
18
+
* its limit, and many bases must not read the documents other tenants share a token with. Real query plans catch this even when warm caches hide it from a timing test.
18
19
* The same read must retain ACL/lifecycle filtering, empty bases, and keyset continuity.
-- A workspace's live file list, most recently modified first: the file browser's default sort.
2
+
-- 0442 indexed the upload order, but no index served this one, so each list read every live file
3
+
-- of the workspace and sorted them, which for a large workspace runs from disk and reaches the
4
+
-- statement timeout.
5
+
--
6
+
-- The predicate and the heap-only owner checks are 0442's, for the same reasons; the key is the
7
+
-- (updated_at, id) keyset the list orders and resumes on, kept as narrow.
8
+
--
9
+
-- Replay-safety: as 0442. The build is CONCURRENTLY below an embedded COMMIT, and a replay moves
10
+
-- only an INVALID index left by a failed build aside to be dropped, keeping a valid one.
11
+
DO $$
12
+
BEGIN
13
+
IF EXISTS (
14
+
SELECT1FROM pg_index WHERE indexrelid = to_regclass('workspace_files_workspace_active_updated_idx_failed')
15
+
AND (indisvalid OR indrelid <> to_regclass('workspace_files'))
16
+
) THEN
17
+
RAISE EXCEPTION 'Refusing to drop unexpected recovery index workspace_files_workspace_active_updated_idx_failed';
18
+
END IF;
19
+
IF EXISTS (
20
+
SELECT1FROM pg_index WHERE indexrelid = to_regclass('workspace_files_workspace_active_updated_idx')
21
+
AND indrelid = to_regclass('workspace_files') AND NOT indisvalid
22
+
) THEN
23
+
ALTERINDEX"workspace_files_workspace_active_updated_idx" RENAME TO "workspace_files_workspace_active_updated_idx_failed";
24
+
END IF;
25
+
END $$;--> statement-breakpoint
26
+
COMMIT;--> statement-breakpoint
27
+
SET lock_timeout =0;--> statement-breakpoint
28
+
DROPINDEX CONCURRENTLY IF EXISTS "workspace_files_workspace_active_updated_idx_failed";--> statement-breakpoint
29
+
CREATEINDEXCONCURRENTLY IF NOT EXISTS "workspace_files_workspace_active_updated_idx"ON"workspace_files" USING btree ("workspace_id","updated_at","id") WHERE"workspace_files"."deleted_at" IS NULLAND"workspace_files"."context"='workspace'AND"workspace_files"."workspace_id"IS NOT NULL;--> statement-breakpoint
0 commit comments