From 2fd7a2b2872103916cefa37002165ca6d8a4a483 Mon Sep 17 00:00:00 2001 From: David-Angel <37879322+David-Angel@users.noreply.github.com> Date: Thu, 19 Jan 2023 10:26:08 -0600 Subject: [PATCH] Update start.sh This is a temporary solution for this issue: https://github.com/CrunchyData/postgres-operator/issues/3477 It turns off hugepages in the "postgresql.conf.sample" sample file. --- bin/postgres_common/postgres/start.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bin/postgres_common/postgres/start.sh b/bin/postgres_common/postgres/start.sh index 9d62a3491..809282aec 100755 --- a/bin/postgres_common/postgres/start.sh +++ b/bin/postgres_common/postgres/start.sh @@ -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