Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: postgresql-cfbot/postgresql
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: cf/5570~1
Choose a base ref
...
head repository: postgresql-cfbot/postgresql
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: cf/5570
Choose a head ref
  • 4 commits
  • 5 files changed
  • 2 contributors

Commits on Apr 25, 2025

  1. Adds a helper for places that shell out to system()

    We need to call system() in a few places, and to do so safely we need
    some pre/post-fork logic. This encapsulates that logic into a single
    System helper function. The main reason to do this is that in a follow
    up commit we want to add even more logic pre and post-fork.
    JelteF authored and Commitfest Bot committed Apr 25, 2025
    Configuration menu
    Copy the full SHA
    df02bb9 View commit details
    Browse the repository at this point in the history
  2. Bump postmaster soft open file limit (RLIMIT_NOFILE) when necessary

    The default open file limit of 1024 on Linux is extremely low. The
    reason that this hasn't changed change is because doing so would break
    legacy programs that use the select(2) system call in hard to debug
    ways. So instead programs that want to opt-in to a higher open file
    limit are expected to bump their soft limit to their hard limit on
    startup. Details on this are very well explained in a blogpost by the
    systemd author[1]. There's also a similar change done by the Go
    language[2].
    
    This starts bumping postmaster its soft open file limit when we realize
    that we'll run into the soft limit with the requested
    max_files_per_process GUC. We do so by slightly changing the meaning of
    the max_files_per_process GUC. The actual (not publicly exposed) limit
    is max_safe_fds, previously this would be set to:
    max_files_per_process - already_open_files - NUM_RESERVED_FDS
    After this change we now try to set max_safe_fds to
    max_files_per_process if the system allows that. This is deemed more
    natural to understand for users, because now the limit of files that
    they can open is actually what they configured in max_files_per_process.
    
    Adding this infrastructure to change RLIMIT_NOFILE when needed is
    especially useful for the AIO work that Andres is doing, because
    io_uring consumes a lot of file descriptors. Even without looking at AIO
    there is a large number of reports from people that require changing
    their soft file limit before starting Postgres, sometimes falling back
    to lowering max_files_per_process when they fail to do so[3-8]. It's
    also not all that strange to fail at setting the soft open file limit
    because there are multiple places where one can configure such limits
    and usually only one of them is effective (which one depends on how
    Postgres is started). In cloud environments its also often not possible
    for user to change the soft limit, because they don't control the way
    that Postgres is started.
    
    One thing to note is that we temporarily restore the original soft
    limit when shell-ing out to other executables. This is done as a
    precaution in case those executables are using select(2).
    
    [1]: https://0pointer.net/blog/file-descriptor-limits.html
    [2]: golang/go#46279
    [3]: https://serverfault.com/questions/785330/getting-too-many-open-files-error-for-postgres
    [4]: https://serverfault.com/questions/716982/how-to-raise-max-no-of-file-descriptors-for-daemons-running-on-debian-jessie
    [5]: https://www.postgresql.org/message-id/flat/CAKtc8vXh7NvP_qWj8EqqorPY97bvxSaX3h5u7a9PptRFHW5x7g%40mail.gmail.com
    [6]: https://www.postgresql.org/message-id/flat/113ce31b0908120955w77029099i7ececc053084095a%40mail.gmail.com
    [7]: abiosoft/colima#836
    [8]: https://www.postgresql.org/message-id/flat/29663.1007738957%40sss.pgh.pa.us#2079ec9e2d8b251593812a3711bfe9e9
    JelteF authored and Commitfest Bot committed Apr 25, 2025
    Configuration menu
    Copy the full SHA
    f303596 View commit details
    Browse the repository at this point in the history
  3. Reflect the value of max_safe_fds in max_files_per_process

    It is currently hard to figure out if max_safe_fds is significantly
    lower than max_files_per_process. This starts reflecting the value of
    max_safe_fds in max_files_per_process after our limit detection. We
    still want to have two separate variables because for the bootstrap or
    standalone-backend cases their values differ on purpose.
    JelteF authored and Commitfest Bot committed Apr 25, 2025
    Configuration menu
    Copy the full SHA
    914d114 View commit details
    Browse the repository at this point in the history
  4. [CF 5570] v8 - Bump soft open file limit (RLIMIT_NOFILE) to hard limi…

    …t on startup
    
    This branch was automatically generated by a robot using patches from an
    email thread registered at:
    
    https://commitfest.postgresql.org/patch/5570
    
    The branch will be overwritten each time a new patch version is posted to
    the thread, and also periodically to check for bitrot caused by changes
    on the master branch.
    
    Patch(es): https://www.postgresql.org/message-id/[email protected]
    Author(s): Jelte Fennema-Nio
    Commitfest Bot committed Apr 25, 2025
    Configuration menu
    Copy the full SHA
    cd69156 View commit details
    Browse the repository at this point in the history
Loading