Skip to content

TTL not casting properly #269

Description

@TheOtherBrian1

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

pg_net isn't casting interval values properly. The pg_net.ttl GUC is used in the following function:

uint64 delete_expired_responses(char *ttl, int batch_size) {
  if (del_response_plan == NULL) {
    SPIPlanPtr tmp = SPI_prepare("\
        WITH\
        rows AS (\
          SELECT ctid\
          FROM net._http_response\
          WHERE created < now() - $1\
          ORDER BY created\
          LIMIT $2\
        )\
        DELETE FROM net._http_response r\
        USING rows WHERE r.ctid = rows.ctid",
                                 2, (Oid[]){INTERVALOID, INT4OID});

When the pg_net.ttl variable is customized to something like:

ALTER SYSTEM SET pg_net.ttl = '1 minute 10 seconds';
SELECT net.worker_restart();

And then a new request is made:

SELECT net.http_get (
    'https://postman-echo.com/get?foo1=bar1&foo2=bar2'
) AS request_id;

The response table is not cleaned at the new interval.

To Reproduce

Run:

ALTER SYSTEM SET pg_net.ttl = '1 minute 10 seconds';
SELECT net.worker_restart();

Make a new request:

SELECT net.http_get (
    'https://postman-echo.com/get?foo1=bar1&foo2=bar2'
) AS request_id;

Wait 70s to see if it has cleared.

Expected behavior

New pg_net.ttl interval values should work as long as they follow proper PG formatting.

System information

  • PG_NET: 0.20.3
  • Supabase PG: 17.6.1.141

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions