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

Handle user referencing private tables #44

Closed
soedirgo opened this issue Oct 6, 2021 · 4 comments
Closed

Handle user referencing private tables #44

soedirgo opened this issue Oct 6, 2021 · 4 comments

Comments

@soedirgo
Copy link
Member

soedirgo commented Oct 6, 2021

IIRC, this issue happened because a user created a foreign key to our queue pk

pg_net/sql/pg_net.sql

Lines 11 to 12 in 5ff8b6b

create table net.http_request_queue(
id bigserial primary key,

Then the TTL would not work because doing DELETEs failed, this would also kill the worker on every restart.

Maybe the correct behavior in this case is to warn instead of crashing - though dying might also be good to avoid having excessive rows in the queue.

Originally posted by @steve-chavez in #43 (comment)

@soedirgo
Copy link
Member Author

soedirgo commented Oct 6, 2021

One small win: rename http_request_queue to _http_request_queue.

This is a private API, so when a user interacts with it, all bets are off. As far as I'm concerned, this is working as intended.

So the improvement to be gained here is on UX of user errors.

Maybe the correct behavior in this case is to warn instead of crashing

I'm not sure how to go about warning the user that the DELETEs failed. Can you clarify?

@steve-chavez
Copy link
Member

Maybe the correct behavior in this case is to warn instead of crashing
I'm not sure how to go about warning the user that the DELETEs failed. Can you clarify?

Ah, my ideas where not clear when I mentioned that(they were not directly related to DELETEs).

But I was thinking that we could have a guc like pg_net.is_worker_on=true and when this is false(worker down) calling all the functions(like net.http_get or net.http_post) would fail. That would prevent having a lot of http requests on the queue.

@steve-chavez
Copy link
Member

One small win: rename http_request_queue to _http_request_queue.

I agree. Also, right now the worker crashes/restarts forever when there's a TTL failure - it should only die once and pg_net functions should refuse to work when the worker is down.

@steve-chavez
Copy link
Member

Another simple way is to just remove the PKs of the tables. This should also help with stability in the meantime as inserts will be faster.

steve-chavez added a commit to steve-chavez/pg_net that referenced this issue Sep 1, 2022
To remove the possibility of them being used as FKs

Fixes supabase#44
@steve-chavez steve-chavez mentioned this issue Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants