Skip to content

Commit 5b36298

Browse files
hashworksporsager
andauthored
Add support for PostgreSQL 17 (hapostgres#1061)
* Add support for PostgreSQL 17 * Reference current debian in README * Fix pg_ctl calls by moving subcommand last pg_ctl v17 has changed parsing of options, resulting in a pg_ctl: too many command-line arguments` error, but moving the subcommand to be the last argument works around the issue. I think this is the relevant commit in pg17 postgres/postgres@03d1080 * Reference latest PostgreSQL version in docs * Include v17 in compatible version output * Update azure build command to v17 * Limit mentioned support in docs to v17 --------- Co-authored-by: Rasmus Porsager <rasmus@porsager.com>
1 parent 5a1846b commit 5b36298

File tree

9 files changed

+32
-30
lines changed

9 files changed

+32
-30
lines changed

.github/workflows/run-tests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
- 14
2323
- 15
2424
- 16
25+
- 17
2526
TEST:
2627
- multi
2728
- single
@@ -51,7 +52,7 @@ jobs:
5152
pip3 install --user black
5253
black --version
5354
gcc --version
54-
git clone -b v0.8.19 --depth 1 https://github.com/citusdata/tools.git ../tools
55+
git clone -b v0.8.31 --depth 1 https://github.com/citusdata/tools.git ../tools
5556
sudo make -C ../tools install
5657
install_uncrustify
5758
rm -rf uncrustify*

Makefile

Lines changed: 2 additions & 1 deletion
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
7+
PGVERSIONS = 13 14 15 16 17
88

99
# Default version:
1010
PGVERSION ?= $(lastword $(PGVERSIONS))
@@ -276,6 +276,7 @@ BUILD_ARGS_pg13 = --build-arg PGVERSION=13 --build-arg CITUSTAG=v10.2.9
276276
BUILD_ARGS_pg14 = --build-arg PGVERSION=14 --build-arg CITUSTAG=$(CITUSTAG)
277277
BUILD_ARGS_pg15 = --build-arg PGVERSION=15 --build-arg CITUSTAG=$(CITUSTAG)
278278
BUILD_ARGS_pg16 = --build-arg PGVERSION=16 --build-arg CITUSTAG=$(CITUSTAG)
279+
BUILD_ARGS_pg17 = --build-arg PGVERSION=17 --build-arg CITUSTAG=$(CITUSTAG)
279280

280281
# DOCKER BUILDS
281282

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
pg_auto_failover is an extension and service for PostgreSQL that monitors
66
and manages automated failover for a Postgres cluster. It is optimized for
7-
simplicity and correctness and supports Postgres 13 and newer.
7+
simplicity and correctness and supports Postgres 13 to 17.
88

99
pg_auto_failover supports several Postgres architectures and implements a
1010
safe automated failover for your Postgres service. It is possible to get
@@ -67,14 +67,14 @@ install by following the linked documentation and then::
6767

6868
```bash
6969
$ sudo apt-get install pg-auto-failover-cli
70-
$ sudo apt-get install postgresql-16-auto-failover
70+
$ sudo apt-get install postgresql-17-auto-failover
7171
```
7272

7373
When using debian, two packages are provided for pg_auto_failover: the
7474
monitor Postgres extension is packaged separately and depends on the
7575
Postgres version you want to run for the monitor itself. The monitor's
76-
extension package is named `postgresql-14-auto-failover` when targeting
77-
Postgres 14.
76+
extension package is named `postgresql-17-auto-failover` when targeting
77+
Postgres 17.
7878

7979
Then another package is prepared that contains the `pg_autoctl` command, and
8080
the name of the package is `pg-auto-failover-cli`. That's the package that
@@ -85,12 +85,12 @@ follow these steps before installing the previous packages.
8585

8686
```bash
8787
$ curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
88-
$ echo "deb http://apt.postgresql.org/pub/repos/apt buster-pgdg main" > /etc/apt/sources.list.d/pgdg.list
88+
$ echo "deb http://apt.postgresql.org/pub/repos/apt bookworm-pgdg main" > /etc/apt/sources.list.d/pgdg.list
8989

9090
# bypass initdb of a "main" cluster
9191
$ echo 'create_main_cluster = false' | sudo tee -a /etc/postgresql-common/createcluster.conf
9292
$ apt-get update
93-
$ apt-get install -y --no-install-recommends postgresql-14
93+
$ apt-get install -y --no-install-recommends postgresql-17
9494
```
9595

9696
### Other installation methods

docs/azure-tutorial.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ nodes. It will help us run and observe PostgreSQL.
154154
"curl https://install.citusdata.com/community/deb.sh | sudo bash" \
155155
"sudo DEBIAN_FRONTEND=noninteractive apt-get install -q -y postgresql-common" \
156156
"echo 'create_main_cluster = false' | sudo tee -a /etc/postgresql-common/createcluster.conf" \
157-
"sudo DEBIAN_FRONTEND=noninteractive apt-get install -q -y postgresql-16-auto-failover" \
157+
"sudo DEBIAN_FRONTEND=noninteractive apt-get install -q -y postgresql-17-auto-failover" \
158158
"sudo usermod -a -G postgres ha-admin" &
159159
done
160160
wait
@@ -178,7 +178,7 @@ own roles in the system.
178178
--auth trust \
179179
--ssl-self-signed \
180180
--pgdata monitor \
181-
--pgctl /usr/lib/postgresql/16/bin/pg_ctl
181+
--pgctl /usr/lib/postgresql/17/bin/pg_ctl
182182
183183
This command initializes a PostgreSQL cluster at the location pointed
184184
by the ``--pgdata`` option. When ``--pgdata`` is omitted, ``pg_autoctl``
@@ -225,7 +225,7 @@ We’ll create the primary database using the ``pg_autoctl create`` subcommand.
225225
--username ha-admin \
226226
--dbname appdb \
227227
--hostname ha-demo-a.internal.cloudapp.net \
228-
--pgctl /usr/lib/postgresql/16/bin/pg_ctl \
228+
--pgctl /usr/lib/postgresql/17/bin/pg_ctl \
229229
--monitor 'postgres://autoctl_node@ha-demo-monitor.internal.cloudapp.net/pg_auto_failover?sslmode=require'
230230
231231
Notice the user and database name in the monitor connection string -- these
@@ -274,7 +274,7 @@ Next connect to node B and do the same process. We'll do both steps at once:
274274
--username ha-admin \
275275
--dbname appdb \
276276
--hostname ha-demo-b.internal.cloudapp.net \
277-
--pgctl /usr/lib/postgresql/16/bin/pg_ctl \
277+
--pgctl /usr/lib/postgresql/17/bin/pg_ctl \
278278
--monitor 'postgres://autoctl_node@ha-demo-monitor.internal.cloudapp.net/pg_auto_failover?sslmode=require'
279279
280280
ssh -T -l ha-admin `vm_ip b` << CMD

docs/install.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ Installing pg_auto_failover
66
We provide native system packages for pg_auto_failover on most popular Linux
77
distributions.
88

9-
Use the steps below to install pg_auto_failover on PostgreSQL 16. At the
10-
current time pg_auto_failover is compatible with PostgreSQL 13 to 16.
9+
Use the steps below to install pg_auto_failover on PostgreSQL 17. At the
10+
current time pg_auto_failover is compatible with PostgreSQL 13 to 17.
1111

1212
Ubuntu or Debian
1313
----------------
@@ -20,13 +20,13 @@ Binary packages for debian and derivatives (ubuntu) are available from
2020
documentation and then::
2121

2222
$ sudo apt-get install pg-auto-failover-cli
23-
$ sudo apt-get install postgresql-16-auto-failover
23+
$ sudo apt-get install postgresql-17-auto-failover
2424

2525
__ https://wiki.postgresql.org/wiki/Apt
2626

2727
The Postgres extension named "pgautofailover" is only necessary on the
2828
monitor node. To install that extension, you can install the
29-
``postgresql-16-auto-failover`` package when using Postgres 16. It's
29+
``postgresql-17-auto-failover`` package when using Postgres 17. It's
3030
available for other Postgres versions too.
3131

3232
Avoiding the default Postgres service
@@ -42,12 +42,12 @@ debian package, follow those steps:
4242
::
4343

4444
$ curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
45-
$ echo "deb http://apt.postgresql.org/pub/repos/apt buster-pgdg main" > /etc/apt/sources.list.d/pgdg.list
45+
$ echo "deb http://apt.postgresql.org/pub/repos/apt bookworm-pgdg main" > /etc/apt/sources.list.d/pgdg.list
4646

4747
# bypass initdb of a "main" cluster
4848
$ echo 'create_main_cluster = false' | sudo tee -a /etc/postgresql-common/createcluster.conf
4949
$ apt-get update
50-
$ apt-get install -y --no-install-recommends postgresql-14
50+
$ apt-get install -y --no-install-recommends postgresql-17
5151

5252
That way when it's time to :ref:`pg_autoctl_create_monitor` or
5353
:ref:`pg_autoctl_create_postgres` there is no confusion about how to handle
@@ -91,7 +91,7 @@ Here's a sample output from the command:
9191
WorkingDirectory = /var/lib/postgresql
9292
Environment = 'PGDATA=/var/lib/postgresql/monitor'
9393
User = postgres
94-
ExecStart = /usr/lib/postgresql/10/bin/pg_autoctl run
94+
ExecStart = /usr/lib/postgresql/17/bin/pg_autoctl run
9595
Restart = always
9696
StartLimitBurst = 0
9797
@@ -128,7 +128,7 @@ pg_auto_failover uses the same build dependencies:
128128

129129
::
130130

131-
$ sudo apt-get build-dep -y --no-install-recommends postgresql-14
131+
$ sudo apt-get build-dep -y --no-install-recommends postgresql-17
132132

133133
Then build pg_auto_failover from sources with the following instructions:
134134

src/bin/pg_autoctl/azure.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,10 +1055,10 @@ azure_build_pg_autoctl(AzureRegionResources *azRegion)
10551055
pid_t pidArray[MAX_VMS_PER_REGION] = { 0 };
10561056

10571057
char *buildCommand =
1058-
"make PG_CONFIG=/usr/lib/postgresql/16/bin/pg_config "
1058+
"make PG_CONFIG=/usr/lib/postgresql/17/bin/pg_config "
10591059
"-C pg_auto_failover -s clean all "
10601060
" && "
1061-
"sudo make PG_CONFIG=/usr/lib/postgresql/16/bin/pg_config "
1061+
"sudo make PG_CONFIG=/usr/lib/postgresql/17/bin/pg_config "
10621062
"BINDIR=/usr/local/bin -C pg_auto_failover install";
10631063

10641064
log_info("Building pg_auto_failover from sources on %d Azure VMs",

src/bin/pg_autoctl/cli_common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1524,7 +1524,7 @@ keeper_cli_print_version(int argc, char **argv)
15241524
"pg_autoctl extension version %s\n",
15251525
PG_AUTOCTL_EXTENSION_VERSION);
15261526
fformat(stdout, "compiled with %s\n", PG_VERSION_STR);
1527-
fformat(stdout, "compatible with Postgres 13, 14, 15, and 16\n");
1527+
fformat(stdout, "compatible with Postgres 13, 14, 15, 16 and 17\n");
15281528
}
15291529

15301530
exit(0);

src/bin/pg_autoctl/pgctl.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,12 +1569,12 @@ pg_ctl_initdb(const char *pg_ctl, const char *pgdata)
15691569
log_info("Initialising a PostgreSQL cluster at \"%s\"", pgdata);
15701570
log_info("%s initdb -s -D %s --option '--auth=trust'", pg_ctl, pgdata);
15711571

1572-
Program program = run_program(pg_ctl, "initdb",
1572+
Program program = run_program(pg_ctl,
15731573
"--silent",
15741574
"--pgdata", pgdata,
15751575

15761576
/* avoid warning message */
1577-
"--option", "'--auth=trust'",
1577+
"--option", "'--auth=trust'", "initdb",
15781578
NULL);
15791579

15801580
bool success = program.returnCode == 0;
@@ -1944,8 +1944,8 @@ pg_ctl_stop(const char *pg_ctl, const char *pgdata)
19441944
Program program = run_program(pg_ctl,
19451945
"--pgdata", pgdata,
19461946
"--wait",
1947-
"stop",
19481947
"--mode", "fast",
1948+
"stop",
19491949
NULL);
19501950

19511951
/*
@@ -2009,7 +2009,7 @@ pg_ctl_stop(const char *pg_ctl, const char *pgdata)
20092009
int
20102010
pg_ctl_status(const char *pg_ctl, const char *pgdata, bool log_output)
20112011
{
2012-
Program program = run_program(pg_ctl, "status", "-D", pgdata, NULL);
2012+
Program program = run_program(pg_ctl, "-D", pgdata, "status", NULL);
20132013
int returnCode = program.returnCode;
20142014

20152015
log_level(log_output ? LOG_INFO : LOG_DEBUG,
@@ -2032,7 +2032,7 @@ bool
20322032
pg_ctl_promote(const char *pg_ctl, const char *pgdata)
20332033
{
20342034
Program program =
2035-
run_program(pg_ctl, "promote", "-D", pgdata, "--no-wait", NULL);
2035+
run_program(pg_ctl, "-D", pgdata, "--no-wait", "promote", NULL);
20362036
int returnCode = program.returnCode;
20372037

20382038
log_debug("%s promote -D %s --no-wait", pg_ctl, pgdata);

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

0 commit comments

Comments
 (0)