Repository navigation
fix(pgmq): fix drop_queue overloading bug #2433
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
Merged
+115
−25
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3b0d572
fix(pgmq): resolve drop_queue overloading bug
brainrake abb8b58
test(pgmq): add drop_queue overload regression test
brainrake 6e84f47
test(pgmq): minimize drop_queue overload test
brainrake d7c9f1b
test(pgmq): update expected-output snapshots for drop_queue fix
brainrake 0b5dce5
test(pgmq): fix z_multigres-orioledb-17 snapshot (missed variant)
brainrake 9964a27
Merge branch 'develop' into pgmq-drop-queue-overload-develop
brainrake ca21a0d
Merge branch 'develop' into pgmq-drop-queue-overload-develop
brainrake ef488bb
Merge branch 'develop' into pgmq-drop-queue-overload-develop
brainrake 2d6a1d8
chore(pgmq): shorten drop_queue comment to one line
brainrake f9688ad
fix(pgmq): keep drop_queue(text, boolean) off the extension
brainrake 2f92da0
test(pgmq): sync drop-queue-overload test with the split-function fix
brainrake b3210b6
fix(pgmq): check to_regprocedure before detaching drop_queue overloads
brainrake bea0f61
Merge branch 'develop' into pgmq-drop-queue-overload-develop
brainrake 144f4b2
Merge branch 'develop' into pgmq-drop-queue-overload-develop
brainrake File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
ansible/files/postgresql_extension_custom_scripts/pgmq/before-create.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| -- clear a leftover drop_queue(text, boolean) compat shim from a prior | ||
| -- install: it isn't an extension member, so DROP EXTENSION never removes it, | ||
| -- and pgmq's own install script would otherwise collide with it | ||
| drop function if exists pgmq.drop_queue(text, boolean); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| { self, pkgs }: | ||
| let | ||
| pname = "pgmq"; | ||
| inherit (pkgs) lib; | ||
| system = pkgs.pkgsLinux.stdenv.hostPlatform.system; | ||
| testLib = import ./lib.nix { inherit self pkgs; }; | ||
|
|
||
| installedExtension = self.legacyPackages.${system}."psql_15".exts."${pname}"; | ||
| versions = installedExtension.versions; | ||
| in | ||
| pkgs.testers.runNixOSTest { | ||
| name = "pgmq-drop-queue-overload"; | ||
| nodes.server = | ||
| { ... }: | ||
| { | ||
| imports = [ | ||
| (testLib.makeSupabaseTestConfig { | ||
| majorVersion = "15"; | ||
| }) | ||
| ]; | ||
| }; | ||
| testScript = | ||
| { ... }: | ||
| let | ||
| versionList = lib.concatStringsSep ", " (map (v: ''"${v}"'') versions); | ||
| in | ||
| '' | ||
| versions = [${versionList}] | ||
|
|
||
| def sql(query): | ||
| return server.succeed( | ||
| "psql -U supabase_admin -d postgres -t -A -F',' -c \"" + query.replace('"', '\\"') + "\"" | ||
| ).strip() | ||
|
|
||
| def drop_queue_overloads(): | ||
| # owned flag first: pg_get_function_identity_arguments() can itself | ||
| # contain a comma ("queue_name text, partitioned boolean"), so put the | ||
| # single-char flag first and split on the first comma only. | ||
| out = sql( | ||
| "select (d.objid is not null), pg_get_function_identity_arguments(p.oid) " | ||
| "from pg_proc p " | ||
| "left join pg_depend d on d.objid = p.oid and d.deptype = 'e' " | ||
| " and d.refobjid = (select oid from pg_extension where extname = 'pgmq') " | ||
| "where p.pronamespace = 'pgmq'::regnamespace and p.proname = 'drop_queue' " | ||
| "order by 2;" | ||
| ) | ||
| return [line.split(",", 1) for line in out.splitlines() if line] | ||
|
|
||
| # every calling convention drop_queue has ever supported still works | ||
| def check_callers(qname): | ||
| sql(f"select pgmq.create('{qname}_a'); select pgmq.drop_queue('{qname}_a');") | ||
| sql(f"select pgmq.create('{qname}_b'); select pgmq.drop_queue('{qname}_b', false);") | ||
| # WRONG flag on purpose (queue isn't partitioned) - must still | ||
| # succeed, safely ignored in favour of pgmq.meta | ||
| sql(f"select pgmq.create('{qname}_c'); select pgmq.drop_queue('{qname}_c', true);") | ||
| sql( | ||
| f"select pgmq.create('{qname}_d'); " | ||
| f"select pgmq.drop_queue(queue_name => '{qname}_d', partitioned => true);" | ||
| ) | ||
|
|
||
| start_all() | ||
| server.wait_for_unit("supabase-db-init.service") | ||
|
|
||
| # fresh install of each pinned version: check the overload split, then the callers | ||
| for version in versions: | ||
| with subtest(f"install pgmq {version}"): | ||
| server.succeed("psql -U supabase_admin -d postgres -c 'DROP EXTENSION IF EXISTS pgmq;'") | ||
| server.succeed( | ||
| f"psql -U supabase_admin -d postgres -c \"CREATE EXTENSION pgmq WITH VERSION '{version}' CASCADE;\"" | ||
| ) | ||
|
|
||
| overloads = drop_queue_overloads() | ||
| print(f"[{version}] drop_queue overloads: {overloads}") | ||
| assert overloads == [ | ||
| ["t", "queue_name text"], | ||
| ["f", "queue_name text, partitioned boolean"], | ||
| ], ( | ||
| f"[{version}] expected one extension-owned drop_queue(text) plus " | ||
| f"an unattached drop_queue(text, boolean) compat shim, got: {overloads}" | ||
| ) | ||
|
|
||
| check_callers(f"q_{version.replace('.', '_')}") | ||
| ''; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.