-
Notifications
You must be signed in to change notification settings - Fork 321
fix(reset): ensure pgmq extension is fully rebuilt during remote resets #4471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ing-sequence errors On preview branch resets, migrations that call pgmq.create(...) could fail with: ERROR: relation "pgmq.q_<queue>_msg_id_seq" does not exist Root cause: reset left the DB in a partial extension state. This change ensures that, during remote resets, we drop and recreate the pgmq extension (DROP ... CASCADE and CREATE ... IF NOT EXISTS) with a bounded retry before applying migrations. This puts extension-managed objects into a consistent state and prevents the sequence race. Notes: - This is scoped to the remote reset flow. - If the remote Postgres does not allow CREATE/DROP EXTENSION or lacks pgmq files, CREATE EXTENSION will fail and the reset will abort; this is expected and requires platform intervention.
Pull Request Test Coverage Report for Build 19625585658Details
💛 - Coveralls |
|
You should enable the pgmq extension from your migration files. For eg. create extension if not exists pgmq;
select pgmq.create('my_queue'); |
|
thanks @sweatybridge for the heads-up! I haven’t added the migration yet but I’ll include the pgmq extension setup: CREATE EXTENSION IF NOT EXISTS pgmq; I’ll push the update shortly. |
|
Cool, all extension related setup should be enabled through user created migration files. I will probably close this PR if you can confirm that the above comment works. |
|
@sweatybridge unfortunately adding create extension in the migrations is not enough. it will still fail after a reset. @7ttp what was the outcome for you? |
|
i tested it again just to be sure, adding |
|
@ToJen @sweatybridge I’m working on the fixes now. I’ll clean up the gofmt formatting, add the missing migration so the recommendation is covered, and update the PR to align with the feedback. I’ll push the updates shortly. |
|
@sweatybridge Could you take a look at this when you have a moment? |
|
I don't think it's the CLI's responsibility to customise user's migrations for any specific extensions. So I will go ahead and close this PR. I will follow up on the original issue to resolve any errors you are facing #4492 |
Related issue: #4492
🐛 Root cause
Preview-branch resets can leave the
pgmqextension in a partial / inconsistent state, where some extension-managed objects (tables or sequences) are missing.When migrations later execute
pgmq.create(...), the extension expects these objects to exist and fails with missing-relation errors.✅ What this change does
During remote resets only, this PR:
pgmqextension existsDROP EXTENSION IF EXISTS pgmq CASCADECREATE EXTENSION IF NOT EXISTS pgmqdown.ResetAll(...)migration flowThis ensures the PGMQ extension is always in a known-good, consistent state before migrations run, eliminating missing-sequence errors.
📌 Notes
🔧 What kind of change does this PR introduce?
Bug fix
🚨 Current behavior
Preview-branch resets may leave the PGMQ extension in a partial state, causing migrations such as:
to fail with missing-relation errors.
More details: #4492
🎉 New behavior
Preview-branch resets now consistently rebuild the PGMQ extension, ensuring all
pgmq.create(...)migrations run successfully without errors.📎 Additional context