fix: recover empty planning rounds in large graphs (#676)

This commit is contained in:
renaesop authored and BaaRai committed 2026-11-30 03:16:35 +01:00
1 parent 5e1b6186bc
commit 4d03d3412b
35 files changed
+2146 -59

No files matched your search

+12
View File
@@ -0,0 +1,12 @@
-- Read-only: verify the database/schema and inspect existing indexes.
SELECT current_database(), current_schema(),
to_regclass('exploration_nodes') AS target_table;
SELECT i.indexrelid::regclass AS index_name,
i.indisvalid,
i.indisready,
pg_size_pretty(pg_relation_size(i.indexrelid)) AS index_size,
pg_get_indexdef(i.indexrelid) AS definition
FROM pg_index i
WHERE i.indrelid = to_regclass('exploration_nodes')
ORDER BY i.indexrelid::regclass::text;
@@ -0,0 +1,20 @@
-- PostgreSQL 16; run against the intended ARTEX database/schema.
-- Standalone migration: autocommit ON. Do not wrap in BEGIN or use psql -1.
-- Before and after execution, run inspect-planning-index.sql.
-- Deliberately no IF NOT EXISTS: a matching name does not prove a valid,
-- equivalent index. Investigate an existing or INVALID index before retrying.
-- The predicate matches db/planner_focus.go: PlanningContinuations.
CREATE INDEX CONCURRENTLY idx_expnodes_planning_continuations
ON exploration_nodes (exploration_id, id DESC)
WHERE kind = 'fact'
AND state = 'confirmed'
AND (
(
COALESCE(payload->>'outcome', '') NOT IN ('verified', 'negative')
AND length(btrim(COALESCE(payload->>'checkpoint', ''))) > 0
)
OR (
payload->>'outcome' = 'blocked'
AND length(btrim(COALESCE(payload->>'revisit_condition', ''))) > 0
)
);
@@ -0,0 +1,3 @@
-- Standalone rollback; autocommit ON, outside a transaction.
-- Verify the intended database/schema and index definition before executing.
DROP INDEX CONCURRENTLY idx_expnodes_planning_continuations;