Skip to content

Reintroduce event changes#767

Merged
dylanjeffers merged 1 commit intomainfrom
claude/review-api-downtime-YlgtH
Apr 16, 2026
Merged

Reintroduce event changes#767
dylanjeffers merged 1 commit intomainfrom
claude/review-api-downtime-YlgtH

Conversation

@dylanjeffers
Copy link
Copy Markdown
Contributor

Re-applies #765 (reverted in #766). The original PR's
ddl/migrations/0195_subscriptions_generic_entity.sql wrapped an
ALTER TABLE plus a non-CONCURRENT CREATE INDEX in BEGIN/COMMIT,
holding ACCESS EXCLUSIVE on subscriptions for the full index
build and causing an API outage.

Migration changes:

  • Replaced 0195 with 0196_subscriptions_generic_entity.sql.
  • Dropped the BEGIN/COMMIT wrapper so CREATE INDEX CONCURRENTLY
    is legal.
  • Switched to CREATE INDEX CONCURRENTLY IF NOT EXISTS so writes
    are not blocked during the build.
  • Removed the no-op UPDATE that scanned the table while holding
    the exclusive lock.
  • All statements use IF NOT EXISTS so prod (where 0195 already
    committed) treats this as a no-op and fresh envs still
    bootstrap correctly.

Trigger change in handle_track.sql:

  • Replaced the per-row LOOP that issued one INSERT per follower
    / saver with a single set-based INSERT ... SELECT ... ON
    CONFLICT DO NOTHING. Avoids slow trigger execution for tracks
    whose contest creator has many followers.

Also added subscriptions_entity_type_entity_id_idx to
sql/01_schema.sql so the cumulative dump matches the live schema.

Re-applies #765 (reverted in #766). The original PR's
ddl/migrations/0195_subscriptions_generic_entity.sql wrapped an
ALTER TABLE plus a non-CONCURRENT CREATE INDEX in BEGIN/COMMIT,
holding ACCESS EXCLUSIVE on subscriptions for the full index
build and causing an API outage.

Migration changes:
- Replaced 0195 with 0196_subscriptions_generic_entity.sql.
- Dropped the BEGIN/COMMIT wrapper so CREATE INDEX CONCURRENTLY
  is legal.
- Switched to CREATE INDEX CONCURRENTLY IF NOT EXISTS so writes
  are not blocked during the build.
- Removed the no-op UPDATE that scanned the table while holding
  the exclusive lock.
- All statements use IF NOT EXISTS so prod (where 0195 already
  committed) treats this as a no-op and fresh envs still
  bootstrap correctly.

Trigger change in handle_track.sql:
- Replaced the per-row LOOP that issued one INSERT per follower
  / saver with a single set-based INSERT ... SELECT ... ON
  CONFLICT DO NOTHING. Avoids slow trigger execution for tracks
  whose contest creator has many followers.

Also added subscriptions_entity_type_entity_id_idx to
sql/01_schema.sql so the cumulative dump matches the live schema.
@dylanjeffers dylanjeffers changed the title claude/review-api-downtime-YlgtH Reintroduce event changes Apr 16, 2026
@dylanjeffers dylanjeffers merged commit c5647da into main Apr 16, 2026
5 checks passed
@dylanjeffers dylanjeffers deleted the claude/review-api-downtime-YlgtH branch April 16, 2026 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants