Files
multica/server/cmd/migrate
Jiayuan Zhangandmultica-agent 5bf10d485c MUL-6582: add durable scheduled Plugin hooks (#7448)
* MUL-6582 feat(plugins): add durable scheduled hooks

Co-authored-by: multica-agent <[email protected]>

* MUL-6582: add schedule-pulse example plugin

Ship a real scheduled plugin that records each unique delivery_id in
workspace storage, so a host retry does not look like a second pulse.
The cmd/server test installs this example manifest and drives two
scheduler replicas through a dropped first attempt.

Co-authored-by: multica-agent <[email protected]>

* MUL-6582 fix(migrations): make schedule indexes retry-safe

Co-authored-by: multica-agent <[email protected]>

---------

Co-authored-by: multica-agent <[email protected]>
2026-08-23 17:37:21 +08:00
..

Migration runner operations

Recover the comment content search index

Migration 371 keeps exactly one comment-content search index per environment: idx_comment_content_bigm when pg_bigm is usable, otherwise the portable idx_comment_content_trgm fallback. A conditionally skipped migration is still recorded in schema_migrations, so rerunning migrate up does not recreate the fallback if the selected bigram index is later dropped or becomes invalid.

First check whether either index is live, ready, and valid:

SELECT indexrelid::regclass AS index_name, indisvalid, indisready, indislive
FROM pg_index
WHERE indexrelid IN (
    to_regclass('idx_comment_content_bigm'),
    to_regclass('idx_comment_content_trgm')
);

If neither index is usable, restore the portable fallback before serving search traffic. Run each statement separately and outside a transaction so the concurrent index build is valid:

CREATE EXTENSION IF NOT EXISTS pg_trgm;
DROP INDEX CONCURRENTLY IF EXISTS idx_comment_content_trgm;
CREATE INDEX CONCURRENTLY idx_comment_content_trgm
    ON comment USING gin (LOWER(content) gin_trgm_ops);

Verify that idx_comment_content_trgm reports all three flags as true before resuming traffic. If idx_comment_content_bigm is repaired later, keep the fallback until the bigram index also reports all three flags as true and has the exact migration 036 shape: a non-unique, non-partial GIN index on LOWER(content) using the pg_bigm-owned gin_bigm_ops operator class. Only then can the fallback be dropped with DROP INDEX CONCURRENTLY during a maintenance window.