Closed steve-chavez closed 1 year ago
When having a TTL of:
show pg_net.ttl; 6 hours
Doing new requests succeed, but their response rows get deleted quickly(after 1 second):
select net.http_get('https://webhook.site/449fddab-5642-4645-9a5e-6c71f7fe9a8e'); select * from net._http_response; -- 0 rows
This is because the worker inserts rows using a now() default value:
now()
https://github.com/supabase/pg_net/blob/639b0498fd1835a59ab763c2a84a1dfe4c3a21dd/src/worker.c#L339-L340 https://github.com/supabase/pg_net/blob/639b0498fd1835a59ab763c2a84a1dfe4c3a21dd/sql/pg_net.sql#L41
And this now() is not getting updated. Every new insert uses an "old" now() value.
Use SetCurrentStatementStartTimestamp() before:
SetCurrentStatementStartTimestamp()
https://github.com/supabase/pg_net/blob/639b0498fd1835a59ab763c2a84a1dfe4c3a21dd/src/worker.c#L205-L206
To make now() use the current time.
Problem
When having a TTL of:
Doing new requests succeed, but their response rows get deleted quickly(after 1 second):
This is because the worker inserts rows using a
now()
default value:https://github.com/supabase/pg_net/blob/639b0498fd1835a59ab763c2a84a1dfe4c3a21dd/src/worker.c#L339-L340 https://github.com/supabase/pg_net/blob/639b0498fd1835a59ab763c2a84a1dfe4c3a21dd/sql/pg_net.sql#L41
And this
now()
is not getting updated. Every new insert uses an "old"now()
value.Solution
Use
SetCurrentStatementStartTimestamp()
before:https://github.com/supabase/pg_net/blob/639b0498fd1835a59ab763c2a84a1dfe4c3a21dd/src/worker.c#L205-L206
To make
now()
use the current time.