fix: admin server dies silently by upgrading warp#5078
Conversation
|
Tried this with https://github.com/PostgREST/postgrest-benchmark and curl localhost:3001/ready -i
## hangs for a while then fails
HTTP/1.1 500 Internal Server Error
Transfer-Encoding: chunked
Date: Mon, 06 Jul 2026 22:24:58 GMT
Server: postgrest/15 (pre-release)
Content-Type: text/plain; charset=utf-8
Something went wrong
# it recovers
curl localhost:3001/ready -i
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Date: Mon, 06 Jul 2026 22:38:51 GMT
Server: postgrest/15 (pre-release) |
6c92895 to
9cce1d6
Compare
|
Going to merge 9cce1d6 on main, seems generally useful. |
Thinking about it, I suppose it is inevitable we implement our own
|
|
@mkleczek It wasn't intended for this situation, but if you use the Now mind you, this hasn't been tested at all, so please take care if you do end up relying on this. Though I've checked the code and using the same counter/flag in two |
@Vlix Do you think Warp could include such an strategy? |
I've looked a bit into "reserving file descriptors", but haven't really found anything on this. Technically, this is already how |
759c8c0 to
e1657a8
Compare
Uses warp main branch yesodweb/wai@ad04121 since there's no release yet.
On second thought, what would that buy us? Currently when we ran out of fds, a request to the Admin server will hang for a while then fail with 5xx, which is acceptable behavior. The only gain would be a faster 5xx response, but I'm not sure if that's worth it. On k8s side you can configure a short timeout for the probe anyway. |
No, now that we don't do a TCP probe in the live check, we would report 200 OK, even when out of fds, wouldn't we? Which is the whole point, we don't want the pod to be suddenly killed under load - that was Michal's argument. So we need to make sure the admin server responds properly, which in turn means it needs to have a reserved file descriptor, otherwise it can't. |
Not exactly, now a response to Admin
So you're saying that Admin needs to respond quickly with a reserved fd when API server is under load otherwise the pod will be killed because of the probe timeout. Let's assume that we had I dunno but this concern of reserved fds seems like a last-ditch effort to me, we're much more constrained by db connections than by fds. Perhaps we should expose a metric like process_open_fds? That way kubernetes could scale out before we ran out of fds? |
Nginx does this for the very same reasons. |
| - git: https://github.com/yesodweb/wai.git | ||
| commit: ad041216b643f69a2a9c87cbf4c2988aa4633dd5 | ||
| subdirs: | ||
| - warp |
There was a problem hiding this comment.
We can not represent these git-fetched dependencies on hackage. That's why we usually say we don't depend on unreleased versions of packages.
That has been (my) feedback consistently for quite some time now, whenever somebody wanted to introduce something like this.
There was a problem hiding this comment.
@Vlix Do you think a new release will come soon in Warp? 🙏
It won't work because we need an fd before we know what
That's a very nuanced discussion. PostgREST is a kind of a connection pooler. It multiplexes requests coming from a lot of In
I thought about it but this metric should already be available in k8s OOTB. |
|
Reserving file descriptors with the current |
From what I read, Nginx opens a couple of Nevertheless, I think for PostgREST it would be enough to have a configurable connection count limit. We can implement it with a custom |
|
Please create an issue in the I can't guarantee this will be implemented, nor if it is, how quickly, but it's an interesting feature. |
Not sure whether it needs to be configurable or whether it could be automatically deduced from the (soft) limit on file descriptors?
Assuming that soft and hard limit on file descriptors are different, it could also be possible to just increase the soft limit in that case. I'm not sure whether that would work for nginx, because IIRC it automatically increases its soft limit to the max available hard limit anyway (?). |
I tried to find a portable way to find out what the fd limit is but I don't think there is any (and I am not talking Windows, just MacOS, FreeBSD, Linux. Looks like configuration variable is simpler.
Right, but it doesn't solve the problem, just moves it.
It doesn't. Nginx has |
Fixes #5012. Uses yesodweb/wai#1084