Skip to content

Commit 1094449

Browse files
sklein94cesmarvin
authored andcommitted
Merge branch 'release/v14.17-1'
2 parents 778768b + 5900a92 commit 1094449

File tree

4 files changed

+57
-5
lines changed

4 files changed

+57
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [v14.17-1] - 2025-03-04
11+
### Changed
12+
- [#44] Execute necessary migration for all databases in post-upgrade script
13+
1014
## [v14.15-2] - 2025-02-21
1115
### Changed
1216
- [#47] Do not restrict access via `pg_hba.conf` in multinode anymore because network policies do that.

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ RUN set -x -o errexit \
1818
FROM registry.cloudogu.com/official/base:3.21.0-1
1919

2020
LABEL NAME="official/postgresql" \
21-
VERSION="14.15-2" \
21+
VERSION="14.17-1" \
2222
maintainer="[email protected]"
2323

2424
ENV LANG=en_US.utf8 \
2525
PGDATA=/var/lib/postgresql \
26-
POSTGRESQL_VERSION=14.15-r0
26+
POSTGRESQL_VERSION=14.17-r0
2727

2828
RUN set -x -o errexit \
2929
&& set -o nounset \

dogu.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"Name": "official/postgresql",
3-
"Version": "14.15-2",
3+
"Version": "14.17-1",
44
"DisplayName": "PostgreSQL",
55
"Description": "PostgreSQL Database.",
66
"Url": "https://www.postgresql.org/",

resources/post-upgrade.sh

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,59 @@ function migrateConstraintsOnPartitionedTables() {
113113
# set config key so migration is only done once
114114
doguctl config migrated_database_constraints true
115115
}
116-
migrateConstraintsOnPartitionedTables
116+
117+
# see https://www.postgresql.org/docs/14/release-14-12.html#:~:text=Restrict%20visibility%20of,WITH%20ALLOW_CONNECTIONS%20false%3B for more information
118+
function restrictStatVisibility() {
119+
if [ ! -f /usr/share/postgresql/fix-CVE-2024-4317.sql ]; then
120+
return 0
121+
fi
122+
123+
while ! pg_isready >/dev/null; do
124+
# Postgres is not ready yet to accept connections
125+
sleep 0.1
126+
done
127+
# temporarily accept connections on template0
128+
psql -U postgres -c "ALTER DATABASE template0 WITH ALLOW_CONNECTIONS true;"
129+
130+
# get all tables
131+
psql -U postgres -c "SELECT d.datname as \"Name\" FROM pg_catalog.pg_database d;" -X > databases
132+
# there are four lines of sql result information (two at the start, two at the end)
133+
for i in $(seq 3 $(($(wc -l < databases) - 2 ))); do
134+
DATABASE_NAME=$(sed "${i}!d" databases | xargs)
135+
psql -U postgres -d "${DATABASE_NAME}" -c "\i /usr/share/postgresql/fix-CVE-2024-4317.sql"
136+
done
137+
138+
# disable connections on template0
139+
psql -U postgres -c "ALTER DATABASE template0 WITH ALLOW_CONNECTIONS false;"
140+
141+
doguctl config restricted_stat_visibility true
142+
}
143+
144+
function reindexAllDatabases() {
145+
while ! pg_isready >/dev/null; do
146+
# Postgres is not ready yet to accept connections
147+
sleep 0.1
148+
done
149+
reindexdb -U postgres --verbose --all
150+
}
151+
152+
if [[ $(doguctl config --default "false" restricted_stat_visibility) != "true" ]] ; then
153+
# Postgres 14.12 (Dogu Version 14.15-2) fixed an issue with the visibility of hidden statistics
154+
# since this fix comes after the version was released, always execute it if it was not executed before
155+
echo "Postgresql stats might be visible outside of their intended scope. Restricting stat visibility..."
156+
restrictStatVisibility
157+
fi
158+
159+
if [ "${FROM_VERSION}" = "${TO_VERSION}" ]; then
160+
echo "FROM and TO versions are the same; Exiting..."
161+
exit 0
162+
else
163+
echo "Postgresql version changed. Reindexing all databases..."
164+
reindexAllDatabases
165+
fi
117166

118167
if versionXLessOrEqualThanY "0.14.15-1" "0.${TO_VERSION}" && [[ $(doguctl config --default "false" migrated_database_constraints) != "true" ]] ; then
119168
# Postgres 14.14 (Dogu Version 14.15.x) fixed an issue with constraints on partitioned tables
120169
# If any partitioned tables have constraints on them, this migration removes and readds them
121170
migrateConstraintsOnPartitionedTables
122171
fi
123-

0 commit comments

Comments
 (0)