Skip to content

Not honoring hugepages setting during initdb causes DB crash #3477

@howels

Description

@howels

Overview

On an OS where hugepages are enabled, if no hugepages resources are assigned in Kubernetes and the postgres instance is set to hugepages = off in the config then one would assume that the DB would not use hugepages.
However, because the initdb process uses postgresql.conf.sample or postgresql.conf.template instead of the actual specified configuration the applied setting is actually hugepages = try during initdb.
In these case the initdb phase will attempt to allocate hugepages which are available in the OS, but it will be denied access by Kubernetes and fail.

Environment

  • Environment: Rancher RKE2
  • PGO: 5.2
  • RKE2: 1.24/1.25

Steps to Reproduce

Run a DB with no hugepages resources assigned on a OS with hugepages and with hugepages = off set in postgres conf.

Expected

When hugepages are disabled they should not be used, during initdb or otherwise. The inability to specify hugepages forces all DBs to use hugepages on any system where they are enabled, even if the hugepages are intended for other applications and not available to the DB Pods.

Actual

Postgres crashes during initdb after speculatively attempting to access hugepages and being denied by Kubernetes policies.

Additional Information
Issue has persisted for some time and the implementation goes against the spirit of the configuration options provided. Exceedingly awkward workaround such as attempting to mount configmaps over postgresql.conf.sample are not suitable for ongoing long-term usage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions