Skip to content

Commit 7b8d9be

Browse files
committed
Add Postgres 17, 18, 19 support
- Raise version_compat.h upper bound to PG20 (allows PG19 compilation) - Add PG19 to PGVERSIONS in Makefile; use Citus v14.1.0 for PG18/19 - Extend CI matrices (run-tests.yml, run-pgaftest.yml) to cover PG18/19 with correct Citus version per release; bump pgaftest builder to PG18 - Fix #1116: thread dbname through ReplicationSource so primary_conninfo includes a dbname keyword, required by PG17 synchronized_standby_slots for logical replication slot failover - Guard pg_stat_wal_receiver.received_tli against NULL: PG18 introduced WALRCV_CONNECTING state where received_tli is NULL; fall back to pg_control_checkpoint() timeline_id during that transient state Fixes #1116
1 parent 48c02be commit 7b8d9be

8 files changed

Lines changed: 47 additions & 16 deletions

File tree

.github/workflows/run-pgaftest.yml

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
strategy:
4444
fail-fast: false
4545
matrix:
46-
PGVERSION: [14, 15, 16, 17]
46+
PGVERSION: [14, 15, 16, 17, 18, 19]
4747

4848
steps:
4949
- uses: actions/checkout@v7.0.0
@@ -54,11 +54,11 @@ jobs:
5454
- name: Build pgaf:run image (PG${{ matrix.PGVERSION }})
5555
run: |
5656
# Match the CITUSTAG-per-PGVERSION logic from the top-level Makefile:
57-
# PG14–15 require Citus v12 (last version supporting those releases).
58-
# PG16+ use the current default.
57+
# PG14–15 require Citus v12, PG16–17 require v13, PG18+ require v14.
5958
case "${{ matrix.PGVERSION }}" in
6059
14|15) CITUSTAG=v12.1.5 ;;
61-
*) CITUSTAG=v13.2.0 ;;
60+
16|17) CITUSTAG=v13.2.0 ;;
61+
*) CITUSTAG=v14.1.0 ;;
6262
esac
6363
docker build \
6464
--build-arg PGVERSION=${{ matrix.PGVERSION }} \
@@ -73,7 +73,8 @@ jobs:
7373
# this step only adds the pg_createcluster layer on top.
7474
case "${{ matrix.PGVERSION }}" in
7575
14|15) CITUSTAG=v12.1.5 ;;
76-
*) CITUSTAG=v13.2.0 ;;
76+
16|17) CITUSTAG=v13.2.0 ;;
77+
*) CITUSTAG=v14.1.0 ;;
7778
esac
7879
docker build \
7980
--build-arg PGVERSION=${{ matrix.PGVERSION }} \
@@ -117,7 +118,7 @@ jobs:
117118
needs: style_checker
118119
runs-on: ubuntu-latest
119120
env:
120-
PGVERSION: 17
121+
PGVERSION: 18
121122

122123
steps:
123124
- uses: actions/checkout@v7.0.0
@@ -129,7 +130,7 @@ jobs:
129130
run: |
130131
docker build \
131132
--build-arg PGVERSION=${{ env.PGVERSION }} \
132-
--build-arg CITUSTAG=v13.2.0 \
133+
--build-arg CITUSTAG=v14.1.0 \
133134
--target pgaftest \
134135
-t pgaf:pgaftest \
135136
.
@@ -169,24 +170,33 @@ jobs:
169170
- { PGVERSION: 15, schedule: quick }
170171
- { PGVERSION: 16, schedule: quick }
171172
- { PGVERSION: 17, schedule: quick }
173+
- { PGVERSION: 18, schedule: quick }
174+
- { PGVERSION: 19, schedule: quick }
172175
# node: create_standby_with_pgdata, maintenance_and_drop, auth,
173176
# monitor_disabled, replace_monitor, extension_update,
174177
# debian_clusters, tablespaces
175178
- { PGVERSION: 14, schedule: node }
176179
- { PGVERSION: 15, schedule: node }
177180
- { PGVERSION: 16, schedule: node }
178181
- { PGVERSION: 17, schedule: node }
182+
- { PGVERSION: 18, schedule: node }
183+
- { PGVERSION: 19, schedule: node }
179184
# ssl: enable_ssl, ssl_self_signed, ssl_cert
180185
- { PGVERSION: 14, schedule: ssl }
181186
- { PGVERSION: 15, schedule: ssl }
182187
- { PGVERSION: 16, schedule: ssl }
183188
- { PGVERSION: 17, schedule: ssl }
184-
# slow schedules: PG17 only
189+
- { PGVERSION: 18, schedule: ssl }
190+
- { PGVERSION: 19, schedule: ssl }
191+
# slow schedules: PG17 only (FSM logic, not version-specific code paths)
185192
- { PGVERSION: 17, schedule: multi-alternate } # multi_alternate
186193
- { PGVERSION: 17, schedule: multi-misc } # multi_standbys, multi_maintenance, ensure, multi_ifdown
187194
- { PGVERSION: 17, schedule: multi-async } # multi_async
188195
- { PGVERSION: 17, schedule: citus-1 } # citus_cluster_name, citus_force_failover, citus_multi_standbys
189196
- { PGVERSION: 17, schedule: citus-2 } # basic_citus_operation, nonha_citus_operation, citus_skip_pg_hba
197+
# slow schedules on PG18 to validate new-version behaviour
198+
- { PGVERSION: 18, schedule: multi-alternate }
199+
- { PGVERSION: 18, schedule: multi-misc }
190200

191201
steps:
192202
- uses: actions/checkout@v7.0.0
@@ -257,7 +267,7 @@ jobs:
257267
strategy:
258268
fail-fast: false
259269
matrix:
260-
PGVERSION: [14, 15, 16, 17]
270+
PGVERSION: [14, 15, 16, 17, 18, 19]
261271

262272
steps:
263273
- uses: actions/checkout@v7.0.0
@@ -278,7 +288,8 @@ jobs:
278288
run: |
279289
case "${{ matrix.PGVERSION }}" in
280290
14|15) CITUSTAG=v12.1.5 ;;
281-
*) CITUSTAG=v13.2.0 ;;
291+
16|17) CITUSTAG=v13.2.0 ;;
292+
*) CITUSTAG=v14.1.0 ;;
282293
esac
283294
docker build \
284295
--build-arg PGVERSION=${{ matrix.PGVERSION }} \

.github/workflows/run-tests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ jobs:
4040
- 15
4141
- 16
4242
- 17
43+
- 18
44+
- 19
4345
steps:
4446
- name: Checkout repository
4547
uses: actions/checkout@v7.0.0
@@ -69,6 +71,8 @@ jobs:
6971
- 15
7072
- 16
7173
- 17
74+
- 18
75+
- 19
7276
TEST:
7377
- multi
7478
- single

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
.DEFAULT_GOAL := all
55

66
# Supported PostgreSQL versions:
7-
PGVERSIONS = 13 14 15 16 17 18
7+
PGVERSIONS = 13 14 15 16 17 18 19
88

99
# Default version:
1010
PGVERSION ?= $(lastword $(PGVERSIONS))
@@ -305,7 +305,8 @@ BUILD_ARGS_pg14 = --build-arg PGVERSION=14 --build-arg CITUSTAG=v12.1.5
305305
BUILD_ARGS_pg15 = --build-arg PGVERSION=15 --build-arg CITUSTAG=v12.1.5
306306
BUILD_ARGS_pg16 = --build-arg PGVERSION=16 --build-arg CITUSTAG=$(CITUSTAG)
307307
BUILD_ARGS_pg17 = --build-arg PGVERSION=17 --build-arg CITUSTAG=$(CITUSTAG)
308-
BUILD_ARGS_pg18 = --build-arg PGVERSION=18 --build-arg CITUSTAG=$(CITUSTAG)
308+
BUILD_ARGS_pg18 = --build-arg PGVERSION=18 --build-arg CITUSTAG=v14.1.0
309+
BUILD_ARGS_pg19 = --build-arg PGVERSION=19 --build-arg CITUSTAG=v14.1.0
309310

310311
# DOCKER BUILDS
311312

src/bin/common/pgctl.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2350,12 +2350,22 @@ prepare_recovery_settings(const char *pgdata,
23502350
primaryNode->host,
23512351
primaryNode->port);
23522352

2353+
/*
2354+
* PG17 introduced synchronized_standby_slots for logical slot
2355+
* failover; pg_sync_replication_slots() requires primary_conninfo
2356+
* to include a dbname keyword. Pass it when available.
2357+
*/
2358+
const char *dbname =
2359+
IS_EMPTY_STRING_BUFFER(replicationSource->dbname)
2360+
? NULL
2361+
: replicationSource->dbname;
2362+
23532363
if (!prepare_primary_conninfo(primaryConnInfo,
23542364
MAXCONNINFO,
23552365
primaryNode->host,
23562366
primaryNode->port,
23572367
replicationSource->userName,
2358-
NULL, /* no database */
2368+
dbname,
23592369
replicationSource->password,
23602370
replicationSource->applicationName,
23612371
replicationSource->sslOptions,

src/bin/common/pgsql.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2616,7 +2616,10 @@ pgsql_get_postgres_metadata(PGSQL *pgsql,
26162616
" end as current_lsn,"
26172617
" pg_control_version, catalog_version_no, system_identifier,"
26182618
" case when pg_is_in_recovery()"
2619-
" then (select received_tli from pg_stat_wal_receiver)"
2619+
" then coalesce("
2620+
" (select received_tli from pg_stat_wal_receiver"
2621+
" where status <> 'connecting'),"
2622+
" (select timeline_id from pg_control_checkpoint()))"
26202623
" else (select timeline_id from pg_control_checkpoint()) "
26212624
" end as timeline_id "
26222625
" from (values(1)) as dummy"

src/bin/common/pgsql.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ typedef struct ReplicationSource
243243
{
244244
NodeAddress primaryNode;
245245
char userName[NAMEDATALEN];
246+
char dbname[NAMEDATALEN]; /* database name for primary_conninfo (PG17+) */
246247
char slotName[MAXCONNINFO];
247248
char password[MAXCONNINFO];
248249
char maximumBackupRate[MAXIMUM_BACKUP_RATE_LEN];

src/bin/pg_autoctl/primary_standby.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,7 @@ standby_init_replication_source(LocalPostgresServer *postgres,
849849
}
850850

851851
strlcpy(upstream->userName, username, NAMEDATALEN);
852+
strlcpy(upstream->dbname, postgres->postgresSetup.dbname, NAMEDATALEN);
852853

853854
if (password != NULL)
854855
{

src/monitor/version_compat.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
#include "postgres.h"
1616

17-
/* we support Postgres versions 10, 11, 12, 13, 14, 15, 16, 17, 18. */
18-
#if (PG_VERSION_NUM < 100000 || PG_VERSION_NUM >= 190000)
17+
/* we support Postgres versions 10, 11, 12, 13, 14, 15, 16, 17, 18, 19. */
18+
#if (PG_VERSION_NUM < 100000 || PG_VERSION_NUM >= 200000)
1919
#error "Unknown or unsupported postgresql version"
2020
#endif
2121

0 commit comments

Comments
 (0)