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

net._http_response rows do not respect TTL #80

Closed
steve-chavez opened this issue Jan 24, 2023 · 0 comments · Fixed by #81
Closed

net._http_response rows do not respect TTL #80

steve-chavez opened this issue Jan 24, 2023 · 0 comments · Fixed by #81
Labels
bug Something isn't working

Comments

@steve-chavez
Copy link
Member

Problem

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:

pg_net/src/worker.c

Lines 339 to 340 in 639b049

appendStringInfo(&query_insert_response_ok, "\
insert into net._http_response(id, status_code, content, headers, content_type, timed_out) values ($1, $2, $3, $4, $5, $6)");

created timestamptz not null default now()

And this now() is not getting updated. Every new insert uses an "old" now() value.

Solution

Use SetCurrentStatementStartTimestamp() before:

pg_net/src/worker.c

Lines 205 to 206 in 639b049

StartTransactionCommand();
PushActiveSnapshot(GetTransactionSnapshot());

To make now() use the current time.

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

Successfully merging a pull request may close this issue.

1 participant