Skip to content

Commit 0cf3d45

Browse files
committed
fix: clean up restored cluster schemas
1 parent 9cb0f31 commit 0cf3d45

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

internal/workers/crunchy_bridge_restore.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,12 +249,13 @@ Requires=zfs-mount.service
249249
Type=forking
250250
User=postgres
251251
Group=postgres
252-
ExecStart=${PG_BIN}/pg_ctl start -t 3600 -D ${DATA_DIR} -l ${DATA_DIR}/postgresql.log
252+
# Long timeout (2 hours) to allow WAL replay for large databases (e.g., 1TB+ databases can take 30+ minutes)
253+
ExecStart=${PG_BIN}/pg_ctl start -t 7200 -D ${DATA_DIR} -l ${DATA_DIR}/postgresql.log
253254
ExecStop=${PG_BIN}/pg_ctl stop -D ${DATA_DIR} -m fast
254255
ExecReload=${PG_BIN}/pg_ctl reload -D ${DATA_DIR}
255256
KillMode=mixed
256257
KillSignal=SIGINT
257-
TimeoutStartSec=3600
258+
TimeoutStartSec=7200
258259
TimeoutStopSec=300
259260
Restart=on-failure
260261
RestartSec=5s
@@ -288,7 +289,16 @@ while [ ${RETRY_COUNT} -lt ${MAX_RETRIES} ]; do
288289
sleep 1
289290
done
290291

291-
# 8. Clean up pgBackRest config (contains credentials)
292+
# 8. Clean up Crunchy Bridge internal schemas and extensions
293+
log "Cleaning up schemas and extensions..."
294+
295+
sudo -u postgres ${PG_BIN}/psql -p ${PG_PORT} -h 127.0.0.1 -d ${DATABASE_NAME} << 'EOSQL'
296+
DROP SCHEMA IF EXISTS perfsnap CASCADE;
297+
DROP SCHEMA IF EXISTS hint_plan CASCADE;
298+
DROP EXTENSION IF EXISTS crunchy_pooler CASCADE;
299+
DROP EXTENSION IF EXISTS pg_stat_statements CASCADE;
300+
EOSQL
301+
292302
log "Cleaning up pgBackRest config..."
293303
if [ -f "${PGBACKREST_CONF}" ]; then
294304
rm -f "${PGBACKREST_CONF}" || log "Warning: Could not remove pgBackRest config"

0 commit comments

Comments
 (0)