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

Wrong 503 Service Unavailable on pg 53400 #3257

Closed
steve-chavez opened this issue Feb 23, 2024 · 1 comment · Fixed by #3383
Closed

Wrong 503 Service Unavailable on pg 53400 #3257

steve-chavez opened this issue Feb 23, 2024 · 1 comment · Fixed by #3383
Labels

Comments

@steve-chavez
Copy link
Member

steve-chavez commented Feb 23, 2024

Problem

Having:

create or replace function temp_file_limit()
returns bigint as $$
  set temp_file_limit to '1MB';
  select COUNT(*) FROM generate_series('-infinity'::TIMESTAMP, 'epoch'::TIMESTAMP, INTERVAL '1 DAY');
$$ language sql security definer;
# got the snippet from https://www.postgresql.org/message-id/flat/CADkLM%3DdDM4TjiiBop4JWKz0jGk-XRX1nAovQd5cmzTODNbCr-g%40mail.gmail.com#17d18bf6206d36b74ff6404661cdc0a8

Generates:

curl localhost:3000/rpc/temp_file_limit -i 
HTTP/1.1 503 Service Unavailable
Transfer-Encoding: chunked
Date: Fri, 23 Feb 2024 22:51:47 GMT
Server: postgrest/12.1 (160caaf)
Retry-After: 0
Content-Type: application/json; charset=utf-8

{"code":"53400","details":null,"hint":null,"message":"temporary file size exceeds temp_file_limit (1024kB)"}

Which is wrong as were' still up:

curl "localhost:3000/rpc/add_them?a=3&b=4"
7

Solution

Turn 53xxx into the 500 status.

(There's 507 Insufficient Storage but it's not accurate in every case)

@wolfgangwalther
Copy link
Member

Might be worth differentiating here, too:

Class 53 — Insufficient Resources
53000 insufficient_resources
53100 disk_full
53200 out_of_memory
53300 too_many_connections
53400 configuration_limit_exceeded

too_many_connections seems more fit for 503 Service Unavailable, imho.

(There's 507 Insufficient Storage but it's not accurate in every case)

That's a WebDAV code, so I don't think it's applicable for us. If it was, it could be 53100.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants