Skip to content

Commit 7867564

Browse files
authored
Add pg17 and remove pg12 in trigger (#1059)
1 parent 40ccd24 commit 7867564

File tree

9 files changed

+194
-110
lines changed

9 files changed

+194
-110
lines changed

delivery.yaml

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ allow_concurrent_steps: true
33

44
build_env: &BUILD_ENV
55
BASE_IMAGE: container-registry.zalando.net/library/ubuntu-22.04
6-
PGVERSION: 16
6+
PGVERSION: 17
77
MULTI_ARCH_REGISTRY: container-registry-test.zalando.net/acid
88

99
pipeline:
@@ -33,6 +33,8 @@ pipeline:
3333
docker buildx build --platform "linux/amd64" \
3434
--build-arg PGVERSION="$PGVERSION" \
3535
--build-arg BASE_IMAGE="$BASE_IMAGE" \
36+
--build-arg PGOLDVERSIONS="14 15 16" \
37+
--build-arg TIMESCALEDB="2.17.2" \
3638
-t "$ECR_TEST_IMAGE" \
3739
--push .
3840
@@ -61,6 +63,8 @@ pipeline:
6163
docker buildx build --platform "linux/amd64,linux/arm64" \
6264
--build-arg PGVERSION="$PGVERSION" \
6365
--build-arg BASE_IMAGE="$BASE_IMAGE" \
66+
--build-arg PGOLDVERSIONS="14 15 16" \
67+
--build-arg TIMESCALEDB="2.17.2" \
6468
-t "$ECR_TEST_IMAGE" \
6569
--push .
6670
cdp-promote-image "$ECR_TEST_IMAGE"
@@ -91,6 +95,8 @@ pipeline:
9195
docker buildx build --platform "linux/amd64,linux/arm64" \
9296
--build-arg PGVERSION="$PGVERSION" \
9397
--build-arg BASE_IMAGE="$BASE_IMAGE" \
98+
--build-arg PGOLDVERSIONS="14 15 16" \
99+
--build-arg TIMESCALEDB="2.17.2" \
94100
-t "$ECR_TEST_IMAGE" \
95101
--push .
96102
cdp-promote-image "$ECR_TEST_IMAGE"

postgres-appliance/Dockerfile

+11-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ARG BASE_IMAGE=ubuntu:22.04
2-
ARG PGVERSION=16
3-
ARG TIMESCALEDB="2.11.2 2.14.2"
2+
ARG PGVERSION=17
3+
ARG TIMESCALEDB="2.15.3 2.17.2"
44
ARG DEMO=false
55
ARG COMPRESS=false
66
ARG ADDITIONAL_LOCALES=
@@ -48,21 +48,21 @@ ARG TIMESCALEDB
4848
ARG TIMESCALEDB_APACHE_ONLY=true
4949
ARG TIMESCALEDB_TOOLKIT=true
5050
ARG COMPRESS
51-
ARG PGOLDVERSIONS="12 13 14 15"
51+
ARG PGOLDVERSIONS="13 14 15 16"
5252
ARG WITH_PERL=false
5353

5454
ARG DEB_PG_SUPPORTED_VERSIONS="$PGOLDVERSIONS $PGVERSION"
5555

5656
# Install PostgreSQL, extensions and contribs
5757
ENV POSTGIS_VERSION=3.5 \
58-
BG_MON_COMMIT=ef60961eff92672b1e21f5260dc1211367da6f1f \
59-
PG_AUTH_MON_COMMIT=3d010e5959285c32b155e8064c9c9b57869aeca7 \
60-
PG_MON_COMMIT=a6c5982368edd876edbee01e51b91e7387071e21 \
61-
SET_USER=REL4_0_1 \
62-
PLPROFILER=REL4_2_4 \
63-
PG_PROFILE=4.6 \
58+
BG_MON_COMMIT=7f5887218790b263fe3f42f85f4ddc9c8400b154 \
59+
PG_AUTH_MON_COMMIT=fe099eef7662cbc85b0b79191f47f52f1e96b779 \
60+
PG_MON_COMMIT=ead1de70794ed62ca1e34d4022f6165ff36e9a91 \
61+
SET_USER=REL4_1_0 \
62+
PLPROFILER=REL4_2_5 \
63+
PG_PROFILE=4.7 \
6464
PAM_OAUTH2=v1.0.1 \
65-
PG_PERMISSIONS_COMMIT=314b9359e3d77c0b2ef7dbbde97fa4be80e31925
65+
PG_PERMISSIONS_COMMIT=f4b7c18676fa64236a1c8e28d34a35764e4a70e2
6666

6767
WORKDIR /builddeps
6868
RUN bash base.sh
@@ -73,7 +73,7 @@ COPY --from=dependencies-builder /builddeps/wal-g /usr/local/bin/
7373
COPY build_scripts/patroni_wale.sh build_scripts/compress_build.sh /builddeps/
7474

7575
# Install patroni and wal-e
76-
ENV PATRONIVERSION=3.3.3
76+
ENV PATRONIVERSION=3.3.4
7777
ENV WALE_VERSION=1.1.1
7878

7979
WORKDIR /
@@ -92,7 +92,6 @@ FROM builder-${COMPRESS}
9292
LABEL maintainer="Team ACID @ Zalando <[email protected]>"
9393

9494
ARG PGVERSION
95-
ARG TIMESCALEDB
9695
ARG DEMO
9796
ARG COMPRESS
9897

@@ -102,7 +101,6 @@ ENV LC_ALL=en_US.utf-8 \
102101
PATH=$PATH:/usr/lib/postgresql/$PGVERSION/bin \
103102
PGHOME=/home/postgres \
104103
RW_DIR=/run \
105-
TIMESCALEDB=$TIMESCALEDB \
106104
DEMO=$DEMO
107105

108106
ENV WALE_ENV_DIR=$RW_DIR/etc/wal-e.d/env \

postgres-appliance/build_scripts/base.sh

+20-26
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ curl -sL "https://github.com/zalando-pg/pg_auth_mon/archive/$PG_AUTH_MON_COMMIT.
5656
curl -sL "https://github.com/cybertec-postgresql/pg_permissions/archive/$PG_PERMISSIONS_COMMIT.tar.gz" | tar xz
5757
curl -sL "https://github.com/zubkov-andrei/pg_profile/archive/$PG_PROFILE.tar.gz" | tar xz
5858
git clone -b "$SET_USER" https://github.com/pgaudit/set_user.git
59-
git clone https://github.com/timescale/timescaledb.git
6059

6160
apt-get install -y \
6261
postgresql-common \
@@ -81,8 +80,8 @@ for version in $DEB_PG_SUPPORTED_VERSIONS; do
8180
"postgresql-${version}-first-last-agg"
8281
"postgresql-${version}-hll"
8382
"postgresql-${version}-hypopg"
84-
"postgresql-${version}-plproxy"
8583
"postgresql-${version}-partman"
84+
"postgresql-${version}-plproxy"
8685
"postgresql-${version}-pgaudit"
8786
"postgresql-${version}-pldebugger"
8887
"postgresql-${version}-pglogical"
@@ -105,6 +104,12 @@ for version in $DEB_PG_SUPPORTED_VERSIONS; do
105104

106105
fi
107106

107+
if [ "${TIMESCALEDB_APACHE_ONLY}" = "true" ]; then
108+
EXTRAS+=("timescaledb-2-oss-postgresql-${version}")
109+
else
110+
EXTRAS+=("timescaledb-2-postgresql-${version}")
111+
fi
112+
108113
# Install PostgreSQL binaries, contrib, plproxy and multiple pl's
109114
apt-get install --allow-downgrades -y \
110115
"postgresql-${version}-cron" \
@@ -116,39 +121,28 @@ for version in $DEB_PG_SUPPORTED_VERSIONS; do
116121
"postgresql-${version}-pg-stat-kcache" \
117122
"${EXTRAS[@]}"
118123

119-
# Install 3rd party stuff
124+
# Clean up timescaledb versions except the highest compatible version
125+
exclude_patterns=()
126+
exclude_patterns_tsl=()
127+
for ts_version in ${TIMESCALEDB}; do
128+
exclude_patterns+=(! -name timescaledb-"${ts_version}".so)
129+
exclude_patterns_tsl+=(! -name timescaledb-tsl-"${ts_version}".so)
130+
done
131+
find /usr/lib/postgresql/"${version}"/lib/ -name 'timescaledb-2.*.so' "${exclude_patterns[@]}" -delete;
120132

121-
# use subshell to avoid having to cd back (SC2103)
122-
(
123-
cd timescaledb
124-
for v in $TIMESCALEDB; do
125-
git checkout "$v"
126-
sed -i "s/VERSION 3.11/VERSION 3.10/" CMakeLists.txt
127-
if BUILD_FORCE_REMOVE=true ./bootstrap -DREGRESS_CHECKS=OFF -DWARNINGS_AS_ERRORS=OFF \
128-
-DTAP_CHECKS=OFF -DPG_CONFIG="/usr/lib/postgresql/$version/bin/pg_config" \
129-
-DAPACHE_ONLY="$TIMESCALEDB_APACHE_ONLY" -DSEND_TELEMETRY_DEFAULT=NO; then
130-
make -C build install
131-
strip /usr/lib/postgresql/"$version"/lib/timescaledb*.so
132-
fi
133-
git reset --hard
134-
git clean -f -d
135-
done
136-
)
133+
if [ "${TIMESCALEDB_APACHE_ONLY}" != "true" ]; then
134+
find /usr/lib/postgresql/"${version}"/lib/ -name 'timescaledb-tsl-2.*.so' "${exclude_patterns_tsl[@]}" -delete;
135+
fi
137136

138-
if [ "${TIMESCALEDB_APACHE_ONLY}" != "true" ] && [ "${TIMESCALEDB_TOOLKIT}" = "true" ]; then
139-
__versionCodename=$(sed </etc/os-release -ne 's/^VERSION_CODENAME=//p')
140-
echo "deb [signed-by=/usr/share/keyrings/timescale_E7391C94080429FF.gpg] https://packagecloud.io/timescale/timescaledb/ubuntu/ ${__versionCodename} main" | tee /etc/apt/sources.list.d/timescaledb.list
141-
curl -L https://packagecloud.io/timescale/timescaledb/gpgkey | gpg --dearmor > /usr/share/keyrings/timescale_E7391C94080429FF.gpg
137+
# Install 3rd party stuff
142138

139+
if [ "${TIMESCALEDB_APACHE_ONLY}" != "true" ] && [ "${TIMESCALEDB_TOOLKIT}" = "true" ]; then
143140
apt-get update
144141
if [ "$(apt-cache search --names-only "^timescaledb-toolkit-postgresql-${version}$" | wc -l)" -eq 1 ]; then
145142
apt-get install "timescaledb-toolkit-postgresql-$version"
146143
else
147144
echo "Skipping timescaledb-toolkit-postgresql-$version as it's not found in the repository"
148145
fi
149-
150-
rm /etc/apt/sources.list.d/timescaledb.list
151-
rm /usr/share/keyrings/timescale_E7391C94080429FF.gpg
152146
fi
153147

154148
EXTRA_EXTENSIONS=()

postgres-appliance/build_scripts/prepare.sh

+4
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ for t in deb deb-src; do
4040
done
4141
curl -s -o - https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg
4242

43+
# add TimescaleDB repository
44+
echo "deb [signed-by=/etc/apt/keyrings/timescale_timescaledb-archive-keyring.gpg] https://packagecloud.io/timescale/timescaledb/ubuntu/ ${DISTRIB_CODENAME} main" | tee /etc/apt/sources.list.d/timescaledb.list
45+
curl -fsSL https://packagecloud.io/timescale/timescaledb/gpgkey | gpg --dearmor | tee /etc/apt/keyrings/timescale_timescaledb-archive-keyring.gpg > /dev/null
46+
4347
# Clean up
4448
apt-get purge -y libcap2-bin
4549
apt-get autoremove -y

postgres-appliance/major_upgrade/pg_upgrade.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def pg_upgrade(self, check=False):
204204
def prepare_new_pgdata(self, version):
205205
from spilo_commons import append_extensions
206206

207-
locale = self.query('SHOW lc_collate')[0][0]
207+
locale = self.query("SELECT datcollate FROM pg_database WHERE datname='template1';")[0][0]
208208
encoding = self.query('SHOW server_encoding')[0][0]
209209
initdb_config = [{'locale': locale}, {'encoding': encoding}]
210210
if self.query("SELECT current_setting('data_checksums')::bool")[0][0]:

postgres-appliance/scripts/post_init.sh

+87-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1
55
export PGOPTIONS="-c synchronous_commit=local -c search_path=pg_catalog"
66

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

1014
(echo "\set ON_ERROR_STOP on"
1115
echo "DO \$\$
@@ -213,6 +217,88 @@ while IFS= read -r db_name; do
213217
UPGRADE_TIMESCALEDB=$(echo -e "SELECT NULL;\nSELECT default_version != installed_version FROM pg_catalog.pg_available_extensions WHERE name = 'timescaledb'" | psql -tAX -d "${db_name}" 2> /dev/null | tail -n 1)
214218
if [ "$UPGRADE_TIMESCALEDB" = "t" ]; then
215219
echo "ALTER EXTENSION timescaledb UPDATE;"
220+
IS_VERSION_BELOW_215=$(echo -e "SELECT (installed_version < '2.15')::bool FROM pg_catalog.pg_available_extensions WHERE name = 'timescaledb'" | psql -tAX -d "${db_name}" 2> /dev/null | tail -n 1)
221+
if [ "$IS_VERSION_BELOW_215" = "t" ]; then
222+
echo """
223+
-- Fix compressed hypertables with FOREIGN KEY constraints that were created with TimescaleDB versions before 2.15.0
224+
CREATE OR REPLACE FUNCTION pg_temp.constraint_columns(regclass, int2[]) RETURNS text[] AS
225+
$$
226+
SELECT array_agg(attname) FROM unnest($2) un(attnum) LEFT JOIN pg_attribute att ON att.attrelid=$1 AND att.attnum = un.attnum;
227+
$$ LANGUAGE SQL SET search_path TO pg_catalog, pg_temp;
228+
DO $$
229+
DECLARE
230+
ht_id int;
231+
ht regclass;
232+
chunk regclass;
233+
con_oid oid;
234+
con_frelid regclass;
235+
con_name text;
236+
con_columns text[];
237+
chunk_id int;
238+
239+
BEGIN
240+
241+
-- iterate over all hypertables that have foreign key constraints
242+
FOR ht_id, ht in
243+
SELECT
244+
ht.id,
245+
format('%I.%I',ht.schema_name,ht.table_name)::regclass
246+
FROM _timescaledb_catalog.hypertable ht
247+
WHERE
248+
EXISTS (
249+
SELECT FROM pg_constraint con
250+
WHERE
251+
con.contype='f' AND
252+
con.conrelid=format('%I.%I',ht.schema_name,ht.table_name)::regclass
253+
)
254+
LOOP
255+
RAISE NOTICE 'Hypertable % has foreign key constraint', ht;
256+
257+
-- iterate over all foreign key constraints on the hypertable
258+
-- and check that they are present on every chunk
259+
FOR con_oid, con_frelid, con_name, con_columns IN
260+
SELECT con.oid, con.confrelid, con.conname, pg_temp.constraint_columns(con.conrelid,con.conkey)
261+
FROM pg_constraint con
262+
WHERE
263+
con.contype='f' AND
264+
con.conrelid=ht
265+
LOOP
266+
RAISE NOTICE 'Checking constraint % %', con_name, con_columns;
267+
-- check that the foreign key constraint is present on the chunk
268+
269+
FOR chunk_id, chunk IN
270+
SELECT
271+
ch.id,
272+
format('%I.%I',ch.schema_name,ch.table_name)::regclass
273+
FROM _timescaledb_catalog.chunk ch
274+
WHERE
275+
ch.hypertable_id=ht_id
276+
LOOP
277+
RAISE NOTICE 'Checking chunk %', chunk;
278+
IF NOT EXISTS (
279+
SELECT FROM pg_constraint con
280+
WHERE
281+
con.contype='f' AND
282+
con.conrelid=chunk AND
283+
con.confrelid=con_frelid AND
284+
pg_temp.constraint_columns(con.conrelid,con.conkey) = con_columns
285+
) THEN
286+
RAISE WARNING 'Restoring constraint % on chunk %', con_name, chunk;
287+
PERFORM _timescaledb_functions.constraint_clone(con_oid, chunk);
288+
INSERT INTO _timescaledb_catalog.chunk_constraint(chunk_id, dimension_slice_id, constraint_name, hypertable_constraint_name) VALUES (chunk_id, NULL, con_name, con_name);
289+
END IF;
290+
291+
END LOOP;
292+
END LOOP;
293+
294+
END LOOP;
295+
296+
END
297+
$$;
298+
299+
DROP FUNCTION pg_temp.constraint_columns(regclass, int2[]);
300+
"""
301+
fi
216302
fi
217303
UPGRADE_TIMESCALEDB_TOOLKIT=$(echo -e "SELECT NULL;\nSELECT default_version != installed_version FROM pg_catalog.pg_available_extensions WHERE name = 'timescaledb_toolkit'" | psql -tAX -d "${db_name}" 2> /dev/null | tail -n 1)
218304
if [ "$UPGRADE_TIMESCALEDB_TOOLKIT" = "t" ]; then

postgres-appliance/scripts/spilo_commons.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212

1313
# (min_version, max_version, shared_preload_libraries, extwlist.extensions)
1414
extensions = {
15-
'timescaledb': (9.6, 16, True, True),
16-
'pg_cron': (9.5, 16, True, False),
17-
'pg_stat_kcache': (9.4, 16, True, False),
18-
'pg_partman': (9.4, 16, False, True)
15+
'timescaledb': (9.6, 17, True, True),
16+
'pg_cron': (9.5, 17, True, False),
17+
'pg_stat_kcache': (9.4, 17, True, False),
18+
'pg_partman': (9.4, 17, False, True)
1919
}
2020
if os.environ.get('ENABLE_PG_MON') == 'true':
21-
extensions['pg_mon'] = (11, 16, True, False)
21+
extensions['pg_mon'] = (11, 17, True, False)
2222

2323

2424
def adjust_extensions(old, version, extwlist=False):

postgres-appliance/tests/docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ services:
5151
postgresql:
5252
parameters:
5353
shared_buffers: 32MB
54-
PGVERSION: '12'
54+
PGVERSION: '13'
5555
# Just to test upgrade with clone. Without CLONE_SCOPE they don't work
5656
CLONE_WAL_S3_BUCKET: *bucket
5757
CLONE_AWS_ACCESS_KEY_ID: *access_key

0 commit comments

Comments
 (0)