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

[feature] Serve 4xx in response to requests during DB restart #2738

Closed
mirabilos opened this issue Mar 9, 2024 · 2 comments
Closed

[feature] Serve 4xx in response to requests during DB restart #2738

mirabilos opened this issue Mar 9, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@mirabilos
Copy link
Contributor

Describe the bug with a clear and concise description of what the bug is.

During a PostgreSQL restart (e.g. due to a system security upgrade), requests are given a 500 instead of a 4xx code to try again:

timestamp="2024-03-09T20:53:25.124Z" func=server.glob..func1.Logger.func13.1 level=ERROR latency="356.15µs" userAgent="http.rb/5.1.1 (Mastodon/4.3.0-nightly.2024-02-23; +https://mastodon.social/)" method=POST statusCode=500 path=/users/XXX/inbox clientIP=X.X.X.X pubKeyID=https://mastodon.social/users/XXX#main-key errors="Error #01: PostInboxScheme: error authenticating post inbox: AuthenticatePostInbox: could not fetch receiving account XXX: FATAL: terminating connection due to administrator command (SQLSTATE 57P01)\n" requestID=0kqft94e040007tkjmbg msg="Internal Server Error: wrote 54B"

- and -

X.X.X.X - - [09/Mar/2024:20:53:25 +0000] TLSv1.3:TLS_AES_256_GCM_SHA384:IPv4"toot.XXX.org" "POST /users/XXX/inbox HTTP/1.1" 500 54 "-" "http.rb/5.1.1 (Mastodon/4.3.0-nightly.2024-02-23; +https://mastodon.social/)"

What's your GoToSocial Version?

0.13.1-SNAPSHOT+git-4b0eefb 🦥

GoToSocial Arch

amd64 binary

What happened?

No response

What you expected to happen?

The absence of a DB is handled gracefully; clients are given a 4xx error code to make them retry later.

How to reproduce it?

No response

Anything else we need to know?

Yes, I should probably stop GtS before upgrading PostgreSQL. I had not thought of it.

@mirabilos mirabilos added the bug Something isn't working label Mar 9, 2024
@tsmethurst
Copy link
Contributor

tsmethurst commented Mar 10, 2024

This is a whole thing that would require significant additional code to implement for not much benefit, so I'm not really keen on doing it.

We'd have to consider things like how GtS should know that it's a temporary database issue and not a permanent one, how long GtS should report to clients that they should wait before trying again, etc.

Besides, most remote instance softwares (including GtS) will probably retry later on a 5xx anyways, since Service Unavailable is 503.

I'm gonna close this as "won't implement".

EDIT: I also changed the title to reflect that this is a feature request; it's not really a bug to serve Internal Server Error when the DB has gone missing.

@tsmethurst tsmethurst closed this as not planned Won't fix, can't repro, duplicate, stale Mar 10, 2024
@tsmethurst tsmethurst changed the title [bug] 500 on requests during DB restart [feature] Serve 4xx in response to requests during DB restart Mar 10, 2024
@mirabilos
Copy link
Contributor Author

mirabilos commented Mar 10, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants