feat: sequin backfill indexes#4386
Conversation
…indexes Signed-off-by: anilb <epipav@gmail.com>
Signed-off-by: anilb <epipav@gmail.com>
Signed-off-by: anilb <epipav@gmail.com>
PR SummaryMedium Risk Overview For The same pattern is applied to Reviewed by Cursor Bugbot for commit 2f59444. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
|
|
There was a problem hiding this comment.
Pull request overview
Adds Sequin backfill sort indexes for package versions and dependencies.
Changes:
- Adds composite indexes for Sequin cursor-based backfills.
- Uses concurrent index creation to limit write disruption.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: anilb <epipav@gmail.com>
Signed-off-by: anilb <epipav@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
backend/src/osspckgs/migrations/V1784745489__sequin_backfill_sort_column_indexes.sql:11
- Scope the catalog lookup and drop to the target schema.
pg_classcovers every schema, so an invalid same-named index elsewhere can enter this loop; the unqualifiedDROP INDEXmay then resolve to and delete the valid public index instead. Select the namespace and drop a schema-qualified identifier.
SELECT c.relname FROM pg_index i JOIN pg_class c ON c.oid = i.indexrelid
WHERE NOT i.indisvalid AND c.relname ~ '^versions_p[0-9]+_last_synced_at_id_package_id_idx$'
LOOP
EXECUTE format('DROP INDEX IF EXISTS %I', idx);
backend/src/osspckgs/migrations/V1784745489__sequin_backfill_sort_column_indexes.sql:106
- Scope this cleanup to the target schema as well. Because the scan is database-wide but the drop is unqualified, a matching invalid index in another schema can cause PostgreSQL to drop a valid public index with the same name.
SELECT c.relname FROM pg_index i JOIN pg_class c ON c.oid = i.indexrelid
WHERE NOT i.indisvalid AND c.relname ~ '^package_dependencies_p[0-9]+_updated_at_id_depends_on_id_idx$'
LOOP
EXECUTE format('DROP INDEX IF EXISTS %I', idx);
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 2f59444. Configure here.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
backend/src/osspckgs/migrations/V1784745489__sequin_backfill_sort_column_indexes.sql:11
- This retry cleanup uses a non-concurrent
DROP INDEXon a partition that receives live writes. PostgreSQL takes an exclusive table lock for a normal drop, so after any failed concurrent build this migration can queue behind traffic and stall subsequent writes—the exact outage risk the concurrent builds avoid. Use top-levelDROP INDEX CONCURRENTLYstatements for the leaf indexes (they cannot run inside thisDOblock), as established byV1784718694__repos_github_lower_url_guard.sql:14-20.
EXECUTE format('DROP INDEX IF EXISTS %I', idx);
backend/src/osspckgs/migrations/V1784745489__sequin_backfill_sort_column_indexes.sql:106
- The same retry-path locking issue affects the 64
package_dependenciespartitions: a normalDROP INDEXtakes an exclusive table lock and can stall continuous dependency ingestion after a failed build. Move this cleanup to top-levelDROP INDEX CONCURRENTLYstatements before rebuilding each leaf index; PostgreSQL does not allow the concurrent form inside aDOblock.
EXECUTE format('DROP INDEX IF EXISTS %I', idx);
No description provided.