Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PG17 support #1014

Merged
merged 12 commits into from
Sep 26, 2024
20 changes: 2 additions & 18 deletions delivery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ pipeline:
- id: push-spilo-ecr
env:
BASE_IMAGE: container-registry.zalando.net/library/ubuntu-22.04
PGVERSION: 16
PGVERSION: 17
MULTI_ARCH_REGISTRY: container-registry-test.zalando.net/acid
type: script
requires_human_approval: true
when:
- event: push
branch: master
branch: feature/postgresql-17
timeout: 10h
vm_config:
type: linux
Expand All @@ -33,19 +33,3 @@ pipeline:
-t "$ECR_TEST_IMAGE" \
--push .
cdp-promote-image "$ECR_TEST_IMAGE"

- id: tag-spilo
depends_on: [push-spilo-ecr]
type: script
requires_human_approval: true
when:
event: push
branch: master
commands:
- desc: Tag release spilo image
cmd: |
PATRONIVERSION=$(sed -n 's/^ENV PATRONIVERSION=\([1-9][0-9]*\.[0-9]*\).*$/\1/p' postgres-appliance/Dockerfile)
COUNTER=$(git tag | sed -n "s/^$PATRONIVERSION-p//p" | sort -un | tail -n1)
TAG="$PATRONIVERSION-p$((COUNTER+1))"

git gh-tag "$TAG"
17 changes: 9 additions & 8 deletions postgres-appliance/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG BASE_IMAGE=ubuntu:22.04
ARG PGVERSION=16
ARG TIMESCALEDB="2.11.2 2.14.2"
ARG PGVERSION=17
ARG TIMESCALEDB="2.14.2"
ARG DEMO=false
ARG COMPRESS=false
ARG ADDITIONAL_LOCALES=
Expand Down Expand Up @@ -48,21 +48,22 @@ ARG TIMESCALEDB
ARG TIMESCALEDB_APACHE_ONLY=true
ARG TIMESCALEDB_TOOLKIT=true
ARG COMPRESS
ARG PGOLDVERSIONS="12 13 14 15"
ARG PGOLDVERSIONS="13 14 15 16"
ARG WITH_PERL=false

ARG DEB_PG_SUPPORTED_VERSIONS="$PGOLDVERSIONS $PGVERSION"

# Install PostgreSQL, extensions and contribs
ENV POSTGIS_VERSION=3.4 \
BG_MON_COMMIT=ef60961eff92672b1e21f5260dc1211367da6f1f \
PG_AUTH_MON_COMMIT=3d010e5959285c32b155e8064c9c9b57869aeca7 \
PG_MON_COMMIT=a6c5982368edd876edbee01e51b91e7387071e21 \
SET_USER=REL4_0_1 \
BG_MON_COMMIT=7f5887218790b263fe3f42f85f4ddc9c8400b154 \
PG_AUTH_MON_COMMIT=fe099eef7662cbc85b0b79191f47f52f1e96b779 \
PG_MON_COMMIT=ead1de70794ed62ca1e34d4022f6165ff36e9a91 \
SET_USER=REL4_1_0 \
PLPROFILER=REL4_2_4 \
idanovinda marked this conversation as resolved.
Show resolved Hide resolved
PG_PROFILE=4.6 \
PAM_OAUTH2=v1.0.1 \
PG_PERMISSIONS_COMMIT=314b9359e3d77c0b2ef7dbbde97fa4be80e31925
PG_PERMISSIONS_COMMIT=f4b7c18676fa64236a1c8e28d34a35764e4a70e2 \
PG_STAT_KCACHE_COMMIT=97305e929294bb968d3b861b636650cc397764cd

WORKDIR /builddeps
RUN bash base.sh
Expand Down
61 changes: 38 additions & 23 deletions postgres-appliance/build_scripts/base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ curl -sL "https://github.com/zalando-pg/pg_auth_mon/archive/$PG_AUTH_MON_COMMIT.
curl -sL "https://github.com/cybertec-postgresql/pg_permissions/archive/$PG_PERMISSIONS_COMMIT.tar.gz" | tar xz
curl -sL "https://github.com/zubkov-andrei/pg_profile/archive/$PG_PROFILE.tar.gz" | tar xz
git clone -b "$SET_USER" https://github.com/pgaudit/set_user.git
curl -sL "https://github.com/powa-team/pg_stat_kcache/archive/$PG_STAT_KCACHE_COMMIT.tar.gz" | tar xz # pg17 support is not released
git clone https://github.com/timescale/timescaledb.git

apt-get install -y \
Expand All @@ -82,22 +83,25 @@ for version in $DEB_PG_SUPPORTED_VERSIONS; do
"postgresql-${version}-hll"
"postgresql-${version}-hypopg"
"postgresql-${version}-plproxy"
"postgresql-${version}-partman"
"postgresql-${version}-pgaudit"
"postgresql-${version}-pldebugger"
"postgresql-${version}-pglogical"
"postgresql-${version}-pglogical-ticker"
"postgresql-${version}-plpgsql-check"
"postgresql-${version}-pg-checksums"
"postgresql-${version}-pgl-ddl-deploy"
"postgresql-${version}-pgq-node"
"postgresql-${version}-postgis-${POSTGIS_VERSION%.*}"
"postgresql-${version}-postgis-${POSTGIS_VERSION%.*}-scripts"
"postgresql-${version}-repack"
"postgresql-${version}-wal2json"
"postgresql-${version}-decoderbufs"
"postgresql-${version}-pllua"
"postgresql-${version}-pgvector")

if [ "$version" != "17" ]; then
EXTRAS+=("postgresql-${version}-partman"
"postgresql-${version}-pglogical"
"postgresql-${version}-pglogical-ticker"
"postgresql-${version}-pg-checksums"
"postgresql-${version}-pgl-ddl-deploy"
"postgresql-${version}-postgis-${POSTGIS_VERSION%.*}"
"postgresql-${version}-postgis-${POSTGIS_VERSION%.*}-scripts"
"postgresql-${version}-repack"
"postgresql-${version}-decoderbufs")
fi

if [ "$WITH_PERL" = "true" ]; then
EXTRAS+=("postgresql-plperl-${version}")
Expand All @@ -113,26 +117,27 @@ for version in $DEB_PG_SUPPORTED_VERSIONS; do
"postgresql-plpython3-${version}" \
"postgresql-server-dev-${version}" \
"postgresql-${version}-pgq3" \
"postgresql-${version}-pg-stat-kcache" \
"${EXTRAS[@]}"

# Install 3rd party stuff

# use subshell to avoid having to cd back (SC2103)
(
cd timescaledb
for v in $TIMESCALEDB; do
git checkout "$v"
sed -i "s/VERSION 3.11/VERSION 3.10/" CMakeLists.txt
if BUILD_FORCE_REMOVE=true ./bootstrap -DREGRESS_CHECKS=OFF -DWARNINGS_AS_ERRORS=OFF \
-DTAP_CHECKS=OFF -DPG_CONFIG="/usr/lib/postgresql/$version/bin/pg_config" \
-DAPACHE_ONLY="$TIMESCALEDB_APACHE_ONLY" -DSEND_TELEMETRY_DEFAULT=NO; then
make -C build install
strip /usr/lib/postgresql/"$version"/lib/timescaledb*.so
fi
git reset --hard
git clean -f -d
done
if [ "$version" != "17" ]; then
for v in $TIMESCALEDB; do
git checkout "$v"
sed -i "s/VERSION 3.11/VERSION 3.10/" CMakeLists.txt
if BUILD_FORCE_REMOVE=true ./bootstrap -DREGRESS_CHECKS=OFF -DWARNINGS_AS_ERRORS=OFF \
-DTAP_CHECKS=OFF -DPG_CONFIG="/usr/lib/postgresql/$version/bin/pg_config" \
-DAPACHE_ONLY="$TIMESCALEDB_APACHE_ONLY" -DSEND_TELEMETRY_DEFAULT=NO; then
make -C build install
strip /usr/lib/postgresql/"$version"/lib/timescaledb*.so
fi
git reset --hard
git clean -f -d
done
fi
)

if [ "${TIMESCALEDB_APACHE_ONLY}" != "true" ] && [ "${TIMESCALEDB_TOOLKIT}" = "true" ]; then
Expand All @@ -153,14 +158,18 @@ for version in $DEB_PG_SUPPORTED_VERSIONS; do

EXTRA_EXTENSIONS=()
if [ "$DEMO" != "true" ]; then
EXTRA_EXTENSIONS+=("plprofiler" "pg_mon-${PG_MON_COMMIT}")
EXTRA_EXTENSIONS+=("pg_mon-${PG_MON_COMMIT}")
if [ "$version" != "17" ]; then
EXTRA_EXTENSIONS+=("plprofiler")
fi
fi

for n in bg_mon-${BG_MON_COMMIT} \
pg_auth_mon-${PG_AUTH_MON_COMMIT} \
set_user \
pg_permissions-${PG_PERMISSIONS_COMMIT} \
pg_profile-${PG_PROFILE} \
pg_stat_kcache-${PG_STAT_KCACHE_COMMIT} \
"${EXTRA_EXTENSIONS[@]}"; do
make -C "$n" USE_PGXS=1 clean install-strip
done
Expand All @@ -177,6 +186,9 @@ done

if [ "$DEMO" != "true" ]; then
for version in $DEB_PG_SUPPORTED_VERSIONS; do
if [ "$version" = "17" ]; then
continue
fi
# create postgis symlinks to make it possible to perform update
ln -s "postgis-${POSTGIS_VERSION%.*}.so" "/usr/lib/postgresql/${version}/lib/postgis-2.5.so"
done
Expand Down Expand Up @@ -258,6 +270,9 @@ if [ "$DEMO" != "true" ]; then
# relink files with the same name and content across different major versions
started=0
for v2 in $(find /usr/share/postgresql -type d -mindepth 1 -maxdepth 1 | sort -Vr); do
if [ "${v2##*/}" = "17" ]; then
continue
fi
if [ "$v1" = "$v2" ]; then
started=1
elif [ $started = 1 ]; then
Expand Down
2 changes: 1 addition & 1 deletion postgres-appliance/major_upgrade/pg_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def pg_upgrade(self, check=False):
def prepare_new_pgdata(self, version):
from spilo_commons import append_extensions

locale = self.query('SHOW lc_collate')[0][0]
locale = self.query("SELECT datcollate FROM pg_database WHERE datname='template1';")[0][0]
encoding = self.query('SHOW server_encoding')[0][0]
initdb_config = [{'locale': locale}, {'encoding': encoding}]
if self.query("SELECT current_setting('data_checksums')::bool")[0][0]:
Expand Down
6 changes: 5 additions & 1 deletion postgres-appliance/scripts/post_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1
export PGOPTIONS="-c synchronous_commit=local -c search_path=pg_catalog"

PGVER=$(psql -d "$2" -XtAc "SELECT pg_catalog.current_setting('server_version_num')::int/10000")
RESET_ARGS="oid, oid, bigint"
if [ "$PGVER" -lt 17 ]; then
RESET_ARGS="oid, oid, bigint"
else
RESET_ARGS="oid, oid, bigint, bool"
fi

(echo "\set ON_ERROR_STOP on"
echo "DO \$\$
Expand Down
6 changes: 3 additions & 3 deletions postgres-appliance/scripts/spilo_commons.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
# (min_version, max_version, shared_preload_libraries, extwlist.extensions)
extensions = {
'timescaledb': (9.6, 16, True, True),
'pg_cron': (9.5, 16, True, False),
'pg_stat_kcache': (9.4, 16, True, False),
'pg_cron': (9.5, 17, True, False),
'pg_stat_kcache': (9.4, 17, True, False),
'pg_partman': (9.4, 16, False, True)
}
if os.environ.get('ENABLE_PG_MON') == 'true':
extensions['pg_mon'] = (11, 16, True, False)
extensions['pg_mon'] = (11, 17, True, False)


def adjust_extensions(old, version, extwlist=False):
Expand Down
2 changes: 1 addition & 1 deletion postgres-appliance/tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ services:
postgresql:
parameters:
shared_buffers: 32MB
PGVERSION: '12'
PGVERSION: '13'
# Just to test upgrade with clone. Without CLONE_SCOPE they don't work
CLONE_WAL_S3_BUCKET: *bucket
CLONE_AWS_ACCESS_KEY_ID: *access_key
Expand Down
Loading
Loading