Skip to content

Network.Socket.accept: resource exhausted (Too many open files) #2042

@steve-chavez

Description

@steve-chavez

(PostgREST v8.0.0.20211102 behind Kong/Nginx)

This happens when there's a good amount of traffic going into PostgREST, then it stops processing any new requests until it's restarted manually.

Nov 23 01:36:27 postgrest[11475]: 23/Nov/2021:01:36:27 +0000: Attempting to connect to the database...
Nov 23 01:36:27 postgrest[11475]: 23/Nov/2021:01:36:27 +0000: Connection successful
Nov 23 01:36:27 postgrest[11475]: 23/Nov/2021:01:36:27 +0000: Config re-loaded
Nov 23 01:36:27 postgrest[11475]: 23/Nov/2021:01:36:27 +0000: Schema cache loaded
Nov 23 03:54:41 postgrest[11475]: Network.Socket.accept: resource exhausted (Too many open files)
Nov 23 03:55:17 postgrest[11475]: 127.0.0.1 - - [23/Nov/2021:03:55:16 +0000] "POST /<redacted> HTTP/1.1" 503
Nov 23 04:13:51 systemd[1]: Stopped PostgREST.
Nov 23 04:13:51 systemd[1]: Started PostgREST.
Nov 23 04:13:51 postgrest[15073]: 23/Nov/2021:04:13:51 +0000: Attempting to connect to the database...
Nov 23 04:13:51 postgrest[15073]: 23/Nov/2021:04:13:51 +0000: Connection successful
Nov 23 04:13:51 postgrest[15073]: 23/Nov/2021:04:13:51 +0000: Listening on port 3000
Nov 23 04:13:51 postgrest[15073]: 23/Nov/2021:04:13:51 +0000: Config re-loaded
Nov 23 04:13:51 postgrest[15073]: 23/Nov/2021:04:13:51 +0000: Listening for notifications on the pgrst channel

Ideally PostgREST should recover or at least die and let systemd restart it.

This is a fix that needs to be done upstream: yesodweb/wai#830.

A patch is already up for review: yesodweb/wai#831

Also, a way to reproduce is mentioned on: yesodweb/wai#825.


Not yet confirmed, but increasing the db-pool size should help since PostgREST wil be able to process more requests without running out of sockets first.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions