Skip to content

Commit a4d0f66

Browse files
authored
chore: push lsn checkpoint on autoshutdown; enable use of recovery_target_lsn; bump admin-mgr (#714)
* chore: push lsn checkpoint on autoshutdown * chore: switch `recovery_target` to `recovery_target_lsn` * chore: create lsn checkpoint file at first boot * chore: bump adminmgr
1 parent 558df85 commit a4d0f66

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

ansible/files/postgresql_config/custom_walg.conf.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
# - Recovery Target -
1313

14-
#recovery_target = 'immediate'
14+
#recovery_target_lsn = ''
1515
#recovery_target_time = ''
1616
#recovery_target_action = 'promote'
1717
#recovery_target_timeline = 'current'

ansible/vars.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ postgres_exporter_release_checksum:
4242
amd64: sha256:ff541bd3ee19c0ae003d71424a75edfcc8695e828dd20d5b4555ce433c89d60b
4343

4444
adminapi_release: 0.48.0
45-
adminmgr_release: 0.9.0
45+
adminmgr_release: 0.10.0
4646

4747
# Postgres Extensions
4848
postgis_release: "3.3.2"

docker/all-in-one/entrypoint.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/bin/bash
22
set -eou pipefail
33

4+
PG_CONF=/etc/postgresql/postgresql.conf
5+
SUPERVISOR_CONF=/etc/supervisor/supervisord.conf
6+
7+
DATA_VOLUME_MOUNTPOINT=${DATA_VOLUME_MOUNTPOINT:-/data}
8+
export CONFIGURED_FLAG_PATH=${CONFIGURED_FLAG_PATH:-$DATA_VOLUME_MOUNTPOINT/machine.configured}
9+
410
# Ref: https://gist.github.com/sj26/88e1c6584397bb7c13bd11108a579746
511
function retry {
612
# Pass 0 for unlimited retries
@@ -44,11 +50,14 @@ function enable_swap {
4450
swapon /mnt/swapfile
4551
}
4652

47-
PG_CONF=/etc/postgresql/postgresql.conf
48-
SUPERVISOR_CONF=/etc/supervisor/supervisord.conf
53+
function create_lsn_checkpoint_file {
54+
if [ ! -f "${DATA_VOLUME_MOUNTPOINT}/latest-lsn-checkpoint" ]; then
55+
echo "0/0" > "${DATA_VOLUME_MOUNTPOINT}/latest-lsn-checkpoint"
56+
chown postgres:postgres "${DATA_VOLUME_MOUNTPOINT}/latest-lsn-checkpoint"
57+
chmod 0300 "${DATA_VOLUME_MOUNTPOINT}/latest-lsn-checkpoint"
58+
fi
59+
}
4960

50-
DATA_VOLUME_MOUNTPOINT=${DATA_VOLUME_MOUNTPOINT:-/data}
51-
export CONFIGURED_FLAG_PATH=${CONFIGURED_FLAG_PATH:-$DATA_VOLUME_MOUNTPOINT/machine.configured}
5261

5362
function setup_postgres {
5463
tar -xzvf "$INIT_PAYLOAD_PATH" -C / ./etc/postgresql.schema.sql
@@ -234,6 +243,7 @@ fi
234243

235244
if [ "${PLATFORM_DEPLOYMENT:-}" ]; then
236245
enable_swap
246+
create_lsn_checkpoint_file
237247
fi
238248

239249
touch "$CONFIGURED_FLAG_PATH"

docker/all-in-one/shutdown.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ SQL
5959
# This is to ensure that the WAL file is shipped, just in case
6060
sleep 1
6161

62+
/usr/bin/admin-mgr lsn-checkpoint-push || echo "Failed to push LSN checkpoint"
63+
6264
kill -s TERM "$(supervisorctl pid)"
6365
fi
6466
}

0 commit comments

Comments
 (0)