Skip to content

fix(db): make replica_heartbeat migration 26 idempotent - #3890

Open
Chessing234 wants to merge 3 commits into
block:mainfrom
Chessing234:fix/replica-heartbeat-migration-idempotent
Open

fix(db): make replica_heartbeat migration 26 idempotent#3890
Chessing234 wants to merge 3 commits into
block:mainfrom
Chessing234:fix/replica-heartbeat-migration-idempotent

Conversation

@Chessing234

Copy link
Copy Markdown
Contributor

Summary

  • Make migration 0026 (replica_heartbeat) idempotent with CREATE TABLE IF NOT EXISTS and ON CONFLICT DO NOTHING inserts so a relay can recover when DDL committed but the _sqlx_migrations ledger row was lost during Postgres failover.
  • Refresh the stored sqlx checksum on brownfield relays that already applied version 26, after verifying the heartbeat table and operator catalog row are present.
  • Mirror the idempotent shape in schema/schema.sql.

Fixes #3785

Test plan

  • cargo test -p buzz-db migration
  • Boot a relay against a database with replica_heartbeat present but no version-26 ledger row and confirm migrations succeed

Made with Cursor

Use IF NOT EXISTS and ON CONFLICT DO NOTHING so migration 26 can safely
re-run after an in-doubt commit leaves the table but not the ledger row.

Signed-off-by: Taksh <takshkothari09@gmail.com>
Brownfield relays already on version 26 need the updated sqlx checksum
before startup; verify the heartbeat table is complete before refreshing.

Signed-off-by: Taksh <takshkothari09@gmail.com>
Keep this PR scoped to replica_heartbeat idempotency only.

Signed-off-by: Taksh <takshkothari09@gmail.com>
@Chessing234
Chessing234 requested a review from a team as a code owner July 31, 2026 10:29
@Chessing234

Copy link
Copy Markdown
Contributor Author

@tlongwell-block @wesbillman @wpfleger96 mind taking a look when you get a chance?

@Chessing234
Chessing234 force-pushed the fix/replica-heartbeat-migration-idempotent branch from 78c1bcf to 61e986d Compare August 5, 2026 10:35
@Chessing234

Copy link
Copy Markdown
Contributor Author

@wpfleger96 migration 26 idempotency fix — keeps re-runs from failing. ok to merge?

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.

Migration 26 (replica_heartbeat) isn't idempotent — in-doubt commit after Postgres failover permanently strands relay pod boot

1 participant