supabase / pg_net

A PostgreSQL extension that enables asynchronous (non-blocking) HTTP/HTTPS requests with SQL
https://supabase.github.io/pg_net
Apache License 2.0
218 stars 17 forks source link

To 0.5 #65

Closed steve-chavez closed 2 years ago

steve-chavez commented 2 years ago

Small improvements to make pg_net a bit more stable.

Closes https://github.com/supabase/pg_net/issues/61 and https://github.com/supabase/pg_net/issues/44.

Also reducing unnecessary work done by pg_net to address cases where there is high amount of requests - ref(slack link)

soedirgo commented 2 years ago

Btw supabase_functions.hooks has hooks_response_id_fkey which depends on net.http_request_queue_pkey. Can that be handled in a migration?

soedirgo commented 2 years ago

Some issues with the 0.4 -> 0.5 upgrade script:

steve-chavez commented 2 years ago

Edit: Nevermind, I managed to reproduce it on the dashboard, I'll just add CASCADE to the script.

dropping pkey constraint

Current queue doesn't have a FK

https://github.com/supabase/pg_net/blob/deed7125e30c455eafd1b9a324a50c8e0fd2e961/sql/pg_net.sql#L42-L43

This was removed on https://github.com/supabase/pg_net/commit/8538d83f7e24b4a77d2e7618a22f2070499fe49a#diff-539e81249472b5ef91e28038ee011b645c8885f37ed6679e34d4483e23f4d390L46-R43

Already included on a previous script

https://github.com/supabase/pg_net/blob/deed7125e30c455eafd1b9a324a50c8e0fd2e961/sql/pg_net--0.2--0.3.sql#L7

How are you testing the upgrade script? I can't reproduce the error

steve-chavez commented 2 years ago

_check_worker_is_up rename: return type should be void instead of trigger - might need to drop + create the function

:white_check_mark:

drop index

Added IF EXISTS

set unlogged

These now work.

steve-chavez commented 2 years ago

I created a new supabase instance(has pg_net 0.2), enabled a webhook and did:

alter extension pg_net update to '0.3';
alter extension pg_net update to '0.4';
alter extension pg_net update to '0.5'; -- had to manually download pg_net--0.4--0.5.sql to /var/lib/postgresql/extension

And all of them ran successfully. Although I had to fix pg_net--0.2--0.3.sql(included on the latest commit).


It would have been good to have pgtap testing for migrations but doesn't seem worth it for now(not sure what pgx will change).