Skip to content

Commit

Permalink
Update start.sh
Browse files Browse the repository at this point in the history
This is a temporary solution for this issue:
CrunchyData/postgres-operator#3477

It turns off hugepages in the "postgresql.conf.sample" sample file.
  • Loading branch information
David-Angel authored Jan 19, 2023
1 parent 5e76f45 commit 2fd7a2b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions bin/postgres_common/postgres/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,22 @@ fi
function initdb_logic() {
echo_info "Starting initdb.."

# # # # # # # # # # # # # # # # # # # # # # # # #
# The "initdb" tool uses settings defined in the shared "postgresql.conf.sample" file preventing "huge_pages" from getting configured properly.
# In Kubernetes this causes the pod to crash when huge pages are enabled in the operating system and they are not configured in Kubernetes.
# We must disable huge pages for PostgreSQL as we are required not to use it.
#
# SOLUTION
# Remove the "huge_pages" configuration from "postgresql.conf.sample" as it may or may not exist.
# Add "huge_pages" to the bottom of the page turned off.

# TODO: Set "huge_pages" based on what is passed in via the postgrescluster. It could be in "cat $PATRONI_POSTGRESQL_CONFIG_DIR/postgresql.conf".
# TODO: It is so early in the initialization the configuation may not have made it in yet.

POSTGRESQL_CONF_SAMPLE="$(awk '($1 ~ /huge_pages/ || $1 ~ /#huge_pages/ || $2 ~ /huge_pages/ || $2 ~ /#huge_pages/) { next } { print } END { print "huge_pages = off" }' ${PGROOT}/share/postgresql.conf.sample)"
echo "$POSTGRESQL_CONF_SAMPLE" > ${PGROOT}/share/postgresql.conf.sample
# # # # # # # # # # # # # # # # # # # # # # # # #

cmd="initdb -D $PGDATA "
if [[ -v PG_LOCALE ]]; then
cmd+=" --locale="$PG_LOCALE
Expand Down

0 comments on commit 2fd7a2b

Please sign in to comment.