Skip to content
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

Enable PGMQ to run without installing an extension #379

Merged
merged 3 commits into from
Feb 17, 2025

Conversation

axelfontaine
Copy link
Contributor

@axelfontaine axelfontaine commented Feb 9, 2025

This pull request enables the installation of PGMQ using a simple psql command:

psql < pgmq.sql

It does NOT affect the existing functionality, nor does it impact PGMQ's ability to be installed as an extension.

This addresses the following issues directly and inderectly:

To achieve this the following was changed:

  • The pgmq schema gets created if it doesn't already exist
  • The actual implementation of send and send_batch are moved higher up the SQL file so they can be found when referenced by the convenience functions with less arguments
  • A new _extension_exists function is introduced to check the existance of arbitrary extensions
  • The implementation of _ensure_pg_partman_installed has been retrofitted to use the new _extension_exists function.
  • All references to the pgmq extension have been guarded with _extension_exists('pgmq')

…T EXISTS to skip object creation if the conflicting object is one that it already owns."
@ChuckHend
Copy link
Member

This is awesome, thank you for doing this @axelfontaine. I will look it over in the next few days.

@ChuckHend
Copy link
Member

image builds are going to fail for PR coming from an external repo (we still need a better way to configure that in CI), so we can ignore those failures.

@v0idpwn
Copy link
Collaborator

v0idpwn commented Feb 11, 2025

This is great. I think we should have tests run on it, though.

@ChuckHend
Copy link
Member

This is great. I think we should have tests run on it, though.

Tests would be great. At first I was thinking of maybe adding another workflow like the existing extension_upgade.yml, except for the stand-alone mode. Except thinking that through, I'm not sure what upgrading looks like. Do we need to track the current version in some table when in stand-alone mode, then execute the migrate files? I'll think this through a bit more, maybe there is a simpler way.

@axelfontaine
Copy link
Contributor Author

@ChuckHend Versioning is not something PGMQ should be concerned with. I use Flyway, but other similar tools will also do the job.

Upgrading means copying the PGMQ upgrade script into one's project and giving it the next version according to Flyway's (or whatever other tool's) naming convention.

Or simply applying it manually using psql.

PGMQ should exclusively deal with queueing. Let other specialized tools handle the versioning.

@ChuckHend
Copy link
Member

Understood. I was thinking of this from the perspective of providing a similar experience to what pgmq has as a Postgres extension, but as stand-alone functionality. It is helpful for me, when troubleshooting, to know which version of the pgmq project folks are running, and versioning is already part of our release process. We don't need to block this PR on versioning though.

I do think we need to have some sort of test in place for executing the migration sql files for stand-alone pgmq though, so that we don't break it for all the non extension users. @axelfontaine what do you think?

@axelfontaine
Copy link
Contributor Author

axelfontaine commented Feb 13, 2025

It is helpful for me, when troubleshooting, to know which version of the pgmq project folks are running, and versioning is already part of our release process.

This can be tackled by providing a pgmq.version() function that returns a hardcoded string with the version. Simple and effective, without getting tangled up in the complexity web of a full migration solution. I worked on Flyway for 10 years before selling it in 2019. Trust me, I know what I am talking about 😉

I do think we need to have some sort of test in place for executing the migration sql files for stand-alone pgmq though, so that we don't break it for all the non extension users. @axelfontaine what do you think?

Agreed. I actually think all tests should be decoupled from GHA and also easily runnable locally at least on Linux, but ideally on all platforms (Win/Mac/Linux). I see that as being separate from this PR as well though.

Copy link
Member

@ChuckHend ChuckHend left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can confirm this did not break any existing functionality. I also ran the python and Rust client tests against this branch.

@ChuckHend ChuckHend merged commit 87530ed into tembo-io:main Feb 17, 2025
18 of 22 checks passed
@ChuckHend ChuckHend mentioned this pull request Feb 18, 2025
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.

3 participants