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

function pgmq.send_batch(unknown, jsonb[], unknown) is not unique\nHINT: Could not choose a best candidate function. You might need to add explicit type casts. #364

Open
markbalazon opened this issue Dec 19, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@markbalazon
Copy link

Hey, pulled the latest docker image and now I'm getting this error when calling send_batch()

function pgmq.send_batch(unknown, jsonb[], unknown) is not unique\nHINT:  Could not choose a best candidate function. You might need to add explicit type casts.

FWIW i was not receiving this error before i pulled the latest docker image.

@ChuckHend ChuckHend added the bug Something isn't working label Dec 19, 2024
@ChuckHend
Copy link
Member

ChuckHend commented Dec 19, 2024

Related, #362

We're working on a fix.

@ChuckHend
Copy link
Member

In the meantime, quay.io/tembo/pg17-pgmq:v1.4.5 is still available.

@ChuckHend
Copy link
Member

ChuckHend commented Dec 19, 2024

@markbalazon could you confirm the exact SQL that you are executing?

I'm able to reproduce that error on v1.5.0 with the following SQL, but it works on v1.4.5. Would be helpful to see exactly which type parameters is giving you the error.

\dx pgmq
                                 List of installed extensions
 Name | Version | Schema |                             Description                             
------+---------+--------+---------------------------------------------------------------------
 pgmq | 1.5.0   | pgmq   | A lightweight message queue. Like AWS SQS and RSMQ but on Postgres.
(1 row)

SELECT pgmq.send_batch(
    'batch_queue',
    ARRAY['{"hello": "world_0"}', '{"hello": "world_1"}']::jsonb[], '0'
);
ERROR:  function pgmq.send_batch(unknown, jsonb[], unknown) is not unique
LINE 1: SELECT pgmq.send_batch(
               ^
HINT:  Could not choose a best candidate function. You might need to add explicit type casts.
\dx pgmq
                                 List of installed extensions
 Name | Version | Schema |                             Description                             
------+---------+--------+---------------------------------------------------------------------
 pgmq | 1.4.5   | pgmq   | A lightweight message queue. Like AWS SQS and RSMQ but on Postgres.
(1 row)

SELECT pgmq.send_batch(
    'batch_queue',
    ARRAY['{"hello": "world_0"}', '{"hello": "world_1"}']::jsonb[], '0'
);
 send_batch 
------------
         1
         2
(2 rows)

If this is the problem you're having, then it looks like send_batch() (delay parameter specifically) became ambiguous in v1.5.0. When there was just a single function, Postgres was able to cast the delay parameter from string to integer and it worked fine. Now delay has both integer and timestamp, so it seems like anything thats passing in a string will have issues.

@ChuckHend
Copy link
Member

@markbalazon - if ☝️ is exactly your issue, I think the quickest fix for you would be to explicitly type the delay parameter.

This should work on v1.5.0.

SELECT pgmq.send_batch('batch_queue', ARRAY['{"hello": "world_0"}', '{"hello": "world_1"}']::jsonb[], 0);

The new features in released v1.5.0 were not meant to be breaking changes.

@markbalazon
Copy link
Author

Hi! thank you for your quick response. I'm using the python client like so: queue.send_batch(queue="my_queue", messages=messages) where messages is a list[dict[str, str]]. I can confirm that pulling v1.4.5 works.

For v1.5.0, do i need to specify the delay param in the client library as well?

@ChuckHend
Copy link
Member

Thanks @markbalazon - I think we can fix your issue by patching the python client. I'll work on getting a patch out for you in #365

@ChuckHend
Copy link
Member

@markbalazon , tembo-pgmq-python v0.9.2 was released. Can you confirm whether this resolves your issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants