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
213 stars 16 forks source link

Fixed broken condition in the check_worker_is_up function and bump to 0.7.2 #100

Closed TheOtherBrian1 closed 11 months ago

TheOtherBrian1 commented 1 year ago

What kind of change does this PR introduce?

Bug fix:

A commit for worker.c altered its "is active" response message from "pg_net worker" to "pg_net " VERSION " worker".

However, the net.check_worker_is_up() function in pg_net.sql hasn't been revised to accommodate this change. Consequently, it inaccurately concludes that the worker is always inactive. I've adjusted its test condition to align with the updated format.

What is the current behavior?

Even when the worker is active, net.check_worker_is_up() returns:

"ERROR: the pg_net background worker is not up"

What is the new behavior?

By updating the comparison in net.check_worker_is_up() to support versioning, the function is able to properly detect when the worker is active.

Old Comparison:

... where backend_type = 'pg_net worker')

New Comparison:

... where backend_type ~ 'pg_net \d+(\.\d+){0,2} worker')

Additional context

This pull request was informed by an error discussed in issue 98. The issuer utilized the net.check_worker_is_up function for debugging purposes. They observed that the function produced inaccurate outcomes:

  • The query SELECT net.check_worker_is_up() generated an error: "ERROR: the pg_net background worker is not up"

  • Manually querying SELECT * from pg_stat_activity displayed a running worker, but the reported backend_type was "pg_net 0.7.1 worker," whereas the function expected "pg_net worker."

steve-chavez commented 1 year ago

@TheOtherBrian1 Sorry for the late reply. The change looks good, but I'd like to bring back the test suite first. I'll do a PR and then we can rebase here.

soedirgo commented 1 year ago

Btw this needs a version update and a migration script, since the function definition changed. Example PR: https://github.com/supabase/pg_net/pull/83/files

I've also seen another PR that's missing a version upgrade: https://github.com/supabase/pg_net/pull/93

steve-chavez commented 1 year ago

@TheOtherBrian1 Rebasing should make the tests green now. Just merged https://github.com/supabase/pg_net/pull/102

TheOtherBrian1 commented 1 year ago

@steve-chavez There might be something wrong with the GitHub action variables. The tests gave the following error:

ERROR: extension "pg_net" has no installation script nor update path for version "0.7.2"

steve-chavez commented 1 year ago

There might be something wrong with the GitHub action variables. The tests gave the following error: ERROR: extension "pg_net" has no installation script nor update path for version "0.7.2"

@TheOtherBrian1 Are you able to reproduce the above locally?

steve-chavez commented 11 months ago

Thanks for your work here @TheOtherBrian1.

I've merged https://github.com/supabase/pg_net/pull/105, which should supersede this PR.

We'll also make a new release on https://github.com/supabase/pg_net/pull/109.