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
234 stars 18 forks source link

Noticeable CPU usage when `net._http_response` has high count #70

Closed steve-chavez closed 2 years ago

steve-chavez commented 2 years ago

This will be fixed on https://github.com/supabase/pg_net/pull/68. Opening the issue to make the bug clear.


When having

postgres=# select count(*) from net._http_response;
-[ RECORD 1 ]
count | 50001

postgres=# select count(*) from net.http_request_queue;
-[ RECORD 1 ]
count | 0

Usage stays mostly at 2.6%CPU. Also notice the 6.7% MEM, which indicates there's a memory leak.

Screenshot from 2022-09-12 23-03-34

This is due to this DELETE:

https://github.com/supabase/pg_net/blob/70ea4cd7f30aed2531492c844cd0c4a06ad5afce/src/worker.c#L442-L445

clock_timestamp() generates a full table scan each time it runs.