Skip to content

Commit f332b91

Browse files
Move to spilo-18/spilo-cdp-18 (#1191)
- Support PG18 - Patroni 4.1.0 - bg_mon from the original repo Not included for PG18: - pglogical-ticker - pgl-ddl-deploy --------- Co-authored-by: Ida Novindasari <idanovinda@gmail.com>
1 parent 4be7a74 commit f332b91

File tree

10 files changed

+104
-97
lines changed

10 files changed

+104
-97
lines changed

delivery.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ allow_concurrent_steps: true
33

44
build_env: &BUILD_ENV
55
BASE_IMAGE: container-registry.zalando.net/library/ubuntu-22.04
6-
PGVERSION: 17
6+
PGVERSION: 18
7+
PGOLDVERSIONS: "16 17"
78
MULTI_ARCH_REGISTRY: container-registry-test.zalando.net/acid
89

910
pipeline:
@@ -32,7 +33,7 @@ pipeline:
3233
docker buildx build --platform "linux/amd64,linux/arm64" \
3334
--build-arg PGVERSION="$PGVERSION" \
3435
--build-arg BASE_IMAGE="$BASE_IMAGE" \
35-
--build-arg PGOLDVERSIONS="14 15 16" \
36+
--build-arg PGOLDVERSIONS="$PGOLDVERSIONS" \
3637
-t "$ECR_TEST_IMAGE" \
3738
--push .
3839
@@ -61,7 +62,7 @@ pipeline:
6162
docker buildx build --platform "linux/amd64,linux/arm64" \
6263
--build-arg PGVERSION="$PGVERSION" \
6364
--build-arg BASE_IMAGE="$BASE_IMAGE" \
64-
--build-arg PGOLDVERSIONS="14 15 16" \
65+
--build-arg PGOLDVERSIONS="$PGOLDVERSIONS" \
6566
-t "$ECR_TEST_IMAGE" \
6667
--push .
6768
cdp-promote-image "$ECR_TEST_IMAGE"
@@ -92,7 +93,7 @@ pipeline:
9293
docker buildx build --platform "linux/amd64,linux/arm64" \
9394
--build-arg PGVERSION="$PGVERSION" \
9495
--build-arg BASE_IMAGE="$BASE_IMAGE" \
95-
--build-arg PGOLDVERSIONS="14 15 16" \
96+
--build-arg PGOLDVERSIONS="$PGOLDVERSIONS" \
9697
-t "$ECR_TEST_IMAGE" \
9798
--push .
9899
cdp-promote-image "$ECR_TEST_IMAGE"

postgres-appliance/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ARG BASE_IMAGE=ubuntu:22.04
2-
ARG PGVERSION=17
2+
ARG PGVERSION=18
33
ARG DEMO=false
44
ARG COMPRESS=false
55
ARG ADDITIONAL_LOCALES=
@@ -46,7 +46,7 @@ ARG PGVERSION
4646
ARG TIMESCALEDB_APACHE_ONLY=true
4747
ARG TIMESCALEDB_TOOLKIT=true
4848
ARG COMPRESS
49-
ARG PGOLDVERSIONS="13 14 15 16"
49+
ARG PGOLDVERSIONS="14 15 16 17"
5050
ARG WITH_PERL=false
5151

5252
ARG DEB_PG_SUPPORTED_VERSIONS="$PGOLDVERSIONS $PGVERSION"
@@ -69,7 +69,7 @@ COPY --from=dependencies-builder /builddeps/wal-g /usr/local/bin/
6969
COPY build_scripts/patroni.sh build_scripts/compress_build.sh /builddeps/
7070

7171
# Install patroni
72-
ENV PATRONIVERSION=4.0.6
72+
ENV PATRONIVERSION=4.1.0
7373

7474
WORKDIR /
7575

postgres-appliance/bootstrap/maybe_pg_upgrade.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def perform_pitr(postgresql, cluster_version, bin_version, config):
4040
except Exception:
4141
logs = tail_postgres_logs()
4242
# Spilo has no other locales except en_EN.UTF-8, therefore we are safe here.
43-
if int(cluster_version) >= 13 and 'recovery ended before configured recovery target was reached' in logs:
43+
if 'recovery ended before configured recovery target was reached' in logs:
4444
# Starting from version 13 Postgres stopped promoting when recovery target wasn't reached.
4545
# In order to improve the user experience we reset all possible recovery targets and retry.
4646
recovery_conf = config[config['method']].get('recovery_conf', {})
@@ -103,7 +103,7 @@ def main():
103103
except Exception as e:
104104
logger.error('Failed to update extensions: %r', e)
105105

106-
upgrade.analyze()
106+
upgrade.analyze(bin_version)
107107

108108

109109
def call_maybe_pg_upgrade():

postgres-appliance/build_scripts/base.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ if [ "$WITH_PERL" != "true" ]; then
5151
equivs-build perl
5252
fi
5353

54-
curl -sL "https://github.com/zalando-pg/bg_mon/archive/$BG_MON_COMMIT.tar.gz" | tar xz
54+
curl -sL "https://github.com/CyberDem0n/bg_mon/archive/$BG_MON_COMMIT.tar.gz" | tar xz
5555
curl -sL "https://github.com/zalando-pg/pg_auth_mon/archive/$PG_AUTH_MON_COMMIT.tar.gz" | tar xz
5656
curl -sL "https://github.com/zubkov-andrei/pg_profile/archive/$PG_PROFILE.tar.gz" | tar xz
5757

@@ -83,10 +83,8 @@ for version in $DEB_PG_SUPPORTED_VERSIONS; do
8383
"postgresql-${version}-pgaudit"
8484
"postgresql-${version}-pldebugger"
8585
"postgresql-${version}-pglogical"
86-
"postgresql-${version}-pglogical-ticker"
8786
"postgresql-${version}-plpgsql-check"
8887
"postgresql-${version}-pg-checksums"
89-
"postgresql-${version}-pgl-ddl-deploy"
9088
"postgresql-${version}-pgq-node"
9189
"postgresql-${version}-postgis-${POSTGIS_VERSION%.*}"
9290
"postgresql-${version}-postgis-${POSTGIS_VERSION%.*}-scripts"
@@ -95,10 +93,12 @@ for version in $DEB_PG_SUPPORTED_VERSIONS; do
9593
"postgresql-${version}-decoderbufs"
9694
"postgresql-${version}-pllua"
9795
"postgresql-${version}-pgvector"
98-
"postgresql-${version}-roaringbitmap")
96+
"postgresql-${version}-roaringbitmap"
97+
"postgresql-${version}-pgfaceting")
9998

100-
if [ "$version" -ge 14 ]; then
101-
EXTRAS+=("postgresql-${version}-pgfaceting")
99+
if [ "$version" != "18" ]; then
100+
EXTRAS+=("postgresql-${version}-pgl-ddl-deploy"
101+
"postgresql-${version}-pglogical-ticker")
102102
fi
103103

104104
if [ "$WITH_PERL" = "true" ]; then

postgres-appliance/major_upgrade/inplace_upgrade.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ def restore_custom_statistics_target(self):
451451
except Exception:
452452
logger.error("Failed to execute '%s'", query)
453453

454-
def reanalyze(self):
454+
def custom_stats_target_reanalyze(self):
455455
from patroni.postgresql.connection import get_connection_cursor
456456

457457
if not self._statistics:
@@ -470,12 +470,15 @@ def reanalyze(self):
470470
except Exception:
471471
logger.error("Failed to execute '%s'", query)
472472

473+
def full_reanalyze(self):
474+
self.postgresql.analyze(self.desired_version)
475+
473476
def analyze(self):
474477
try:
475478
self.reset_custom_statistics_target()
476479
except Exception as e:
477480
logger.error('Failed to reset custom statistics targets: %r', e)
478-
self.postgresql.analyze(True)
481+
self.postgresql.analyze(self.desired_version, in_stages=True)
479482
try:
480483
self.restore_custom_statistics_target()
481484
except Exception as e:
@@ -634,7 +637,10 @@ def do_upgrade(self):
634637

635638
analyze_thread.join()
636639

637-
self.reanalyze()
640+
if int(self.desired_version) < 18:
641+
self.custom_stats_target_reanalyze()
642+
else:
643+
self.full_reanalyze()
638644

639645
logger.info('Total upgrade time (with analyze): %s', time.time() - downtime_start)
640646
self.postgresql.bootstrap.call_post_bootstrap(self.config['bootstrap'])

postgres-appliance/major_upgrade/pg_upgrade.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,9 @@ def prepare_new_pgdata(self, version):
207207
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}]
210-
if self.query("SELECT current_setting('data_checksums')::bool")[0][0]:
211-
initdb_config.append('data-checksums')
210+
checksums_enabled = self.query("SELECT current_setting('data_checksums')::bool")[0][0]
211+
if checksums_enabled == (int(version) < 18):
212+
initdb_config.append('data-checksums' if checksums_enabled else 'no-data-checksums')
212213

213214
logger.info('initdb config: %s', initdb_config)
214215

@@ -268,9 +269,12 @@ def do_upgrade(self):
268269
return self.pg_upgrade() and self.restore_shared_preload_libraries()\
269270
and self.switch_pgdata() and self.cleanup_old_pgdata()
270271

271-
def analyze(self, in_stages=False):
272-
vacuumdb_args = ['--analyze-in-stages'] if in_stages else []
273-
logger.info('Rebuilding statistics (vacuumdb%s)', (' ' + vacuumdb_args[0] if in_stages else ''))
272+
def analyze(self, version, in_stages=False):
273+
vacuumdb_args = []
274+
if in_stages:
275+
vacuumdb_args = ['--analyze-in-stages'] if int(version) < 18 else ['--analyze-in-stages',
276+
'--missing-stats-only']
277+
logger.info('Rebuilding statistics (vacuumdb%s)', (' ' + ' '.join(vacuumdb_args) if in_stages else ''))
274278
if 'username' in self.config.superuser:
275279
vacuumdb_args += ['-U', self.config.superuser['username']]
276280
vacuumdb_args += ['-Z', '-j']

postgres-appliance/scripts/post_init.sh

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,12 @@ CREATE TABLE IF NOT EXISTS public.postgres_log (
139139
query_pos integer,
140140
location text,
141141
application_name text,
142+
backend_type text,
143+
leader_pid integer,
144+
query_id bigint,
142145
CONSTRAINT postgres_log_check CHECK (false) NO INHERIT
143146
);
144147
GRANT SELECT ON public.postgres_log TO admin;"
145-
if [ "$PGVER" -ge 13 ]; then
146-
echo "ALTER TABLE public.postgres_log ADD COLUMN IF NOT EXISTS backend_type text;"
147-
fi
148-
if [ "$PGVER" -ge 14 ]; then
149-
echo "ALTER TABLE public.postgres_log ADD COLUMN IF NOT EXISTS leader_pid integer;"
150-
echo "ALTER TABLE public.postgres_log ADD COLUMN IF NOT EXISTS query_id bigint;"
151-
fi
152148

153149
# Sunday could be 0 or 7 depending on the format, we just create both
154150
LOG_SHIP_HOURLY=$(echo "SELECT text(current_setting('log_rotation_age') = '1h')" | psql -tAX -d postgres 2> /dev/null | tail -n 1)

postgres-appliance/scripts/spilo_commons.py

Lines changed: 5 additions & 5 deletions
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, 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)
15+
'timescaledb': (9.6, 18, True, True),
16+
'pg_cron': (9.5, 18, True, False),
17+
'pg_stat_kcache': (9.4, 18, True, False),
18+
'pg_partman': (9.4, 18, False, True)
1919
}
2020
if os.environ.get('ENABLE_PG_MON') == 'true':
21-
extensions['pg_mon'] = (11, 17, True, False)
21+
extensions['pg_mon'] = (11, 18, True, False)
2222

2323

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

postgres-appliance/tests/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ services:
5050
postgresql:
5151
parameters:
5252
shared_buffers: 32MB
53-
PGVERSION: '13'
53+
PGVERSION: '14'
5454
# Just to test upgrade with clone. Without CLONE_SCOPE they don't work
5555
CLONE_WAL_S3_BUCKET: *bucket
5656
CLONE_AWS_ACCESS_KEY_ID: *access_key

0 commit comments

Comments
 (0)