Skip to content

Commit 2086ad5

Browse files
committed
fix(ansible): move pgBackRest spool-path off the 10GB root volume
pgBackRest's spool-path was never set explicitly, so it defaulted to /var/spool/pgbackrest on the AMI's 10GB root volume instead of /data (the dedicated EBS volume PGDATA lives on). Sets spool-path = /data/pgbackrest_spool in the ansible-managed pgbackrest.conf, and updates the AppArmor profile to allow writes there. The AMI-bake-time directory-creation task added here does not create this directory on any live instance's real /data -- that volume is always a separately-provisioned EBS volume attached at real instance launch, never part of the AMI image at any Packer stage. So the config value and the AppArmor grant here are correct and needed groundwork, but on their own they do not make archive-async safe to enable anywhere in the fleet. The real fix is a runtime mechanism, tracked at INDATA-1153.
1 parent cbf34f0 commit 2086ad5

4 files changed

Lines changed: 13 additions & 3 deletions

File tree

ansible/files/pgbackrest_config/pgbackrest.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ log-level-console = info
1313
log-level-file = detail
1414
log-subprocess = y
1515
resume = n
16+
# spool-path shares a filesystem with pg_wal so archive-get can hand off WAL segments via rename instead of copy; only reachable once archive-async is enabled. The matching AppArmor grants live in ansible/files/postgresql_config/sbpostgres_apparmor and the audit exclusion in nix/packages/supascan/internal/config/defaults.go -- keep this path in sync across those, plus the directory-creation loop entry in ansible/tasks/setup-pgbackrest.yml (bake-time only; see INDATA-1153 for why that alone doesn't create this directory on any live instance's real /data).
17+
spool-path = /data/pgbackrest_spool
1618
start-fast = y
1719
# Note: the [supabase] stanza (pg1-path, pg1-socket-path, pg1-user) has been
1820
# removed from this file. supabase-admin-agent owns that stanza and writes it

ansible/files/postgresql_config/sbpostgres_apparmor

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ profile sbpostgres flags=(attach_disconnected) {
127127
/var/lib/postgresql/data/standby.signal rw,
128128
/var/lib/pgbackrest rw,
129129
/etc/pgbackrest/conf.d/** rw,
130-
/var/spool/pgbackrest/** rw,
130+
# bare-dir grant needed alongside ** (same as /data/pgdata/pg_wal/) since ** doesn't cover the directory inode itself; path must match spool-path in ansible/files/pgbackrest_config/pgbackrest.conf, which has the full cross-file sync note
131+
/data/pgbackrest_spool/ rw,
132+
/data/pgbackrest_spool/** rw,
131133
/var/log/pgbackrest/** rw,
132134
/etc/** r,
133135
/usr/local/** r,
@@ -190,7 +192,9 @@ profile sbpostgres flags=(attach_disconnected) {
190192
/var/lib/postgresql/data/standby.signal rw,
191193
/var/lib/pgbackrest rw,
192194
/etc/pgbackrest/conf.d/** rw,
193-
/var/spool/pgbackrest/** rw,
195+
# bare-dir grant needed alongside ** (same as /data/pgdata/pg_wal/) since ** doesn't cover the directory inode itself; path must match spool-path in ansible/files/pgbackrest_config/pgbackrest.conf, which has the full cross-file sync note
196+
/data/pgbackrest_spool/ rw,
197+
/data/pgbackrest_spool/** rw,
194198
/var/log/pgbackrest/** rw,
195199
/etc/** r,
196200
/usr/local/** r,

ansible/tasks/setup-pgbackrest.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
# (running as the pgbackrest user) cannot read conf files created by adminapi.
4848
- {dir: /etc/pgbackrest/conf.d, mode: '02770'}
4949
- {dir: /var/lib/pgbackrest}
50-
- {dir: /var/spool/pgbackrest}
50+
# setgid (02770), same reason as conf.d above (postgres_shell and pgbackrest_shell both write here per sbpostgres_apparmor); must match spool-path in pgbackrest.conf; bake-time only, see INDATA-1153 for why that alone doesn't create this on any live instance's real /data
51+
- {dir: /data/pgbackrest_spool, mode: '02770'}
5152
- {dir: /var/log/pgbackrest}
5253
loop_control:
5354
loop_var: backrest_dir

nix/packages/supascan/internal/config/defaults.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ var DefaultExclusions = Config{
6363
// PostgreSQL data directory - contents are dynamic database state
6464
"/data/pgdata",
6565

66+
// pgBackRest spool - transient WAL archive-get/archive-push queue, not durable state
67+
"/data/pgbackrest_spool",
68+
6669
// Deployment/provisioning tools - internal implementation details
6770
"/opt/saltstack",
6871

0 commit comments

Comments
 (0)