Skip to content

Commit

Permalink
chore: remove pg_switch_wal (#713)
Browse files Browse the repository at this point in the history
* chore: remove pg_switch_wal

* chore: remove remnants
  • Loading branch information
pcnc committed Aug 1, 2023
1 parent 08b94a4 commit 813c7fa
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions docker/all-in-one/shutdown.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,13 @@ SQL
TIME_SINCE_LAST_DISCONNECT="$((NOW - LAST_DISCONNECT_TIME))"

if [ $TIME_SINCE_LAST_DISCONNECT -gt "$((MAX_IDLE_TIME_MINUTES * 60))" ]; then
LAST_WAL_FILE_NAME=$(run_sql -tA -c "SELECT pg_walfile_name(pg_switch_wal())")
NEW_WAL_FILE_NAME=$(run_sql -tA -c "SELECT pg_walfile_name(pg_current_wal_lsn())")

echo "$(date): No active connections for $MAX_IDLE_TIME_MINUTES minutes. Shutting down."

supervisorctl stop postgresql

# Postgres ships the latest WAL file using archive_command during shutdown, in a blocking operation
# This is to ensure that the WAL file is shipped, just in case
if [ "$LAST_WAL_FILE_NAME" != "$NEW_WAL_FILE_NAME" ]; then
sleep 2
fi
sleep 1

kill -s TERM "$(supervisorctl pid)"
fi
Expand Down

0 comments on commit 813c7fa

Please sign in to comment.