Skip to content

Commit 8c062f1

Browse files
committed
.pid is present during postgresql-server run. It should be removed with server stop. in some circumstances, it persists after the container shuts down. If it happens, this check should ensure the state is correct before the upgrade. It should remove the redundant file.
1 parent 1a91d2f commit 8c062f1

File tree

7 files changed

+35
-0
lines changed
  • 10/root/usr/share/container-scripts/postgresql
  • 12/root/usr/share/container-scripts/postgresql
  • 13/root/usr/share/container-scripts/postgresql
  • 14/root/usr/share/container-scripts/postgresql
  • 15/root/usr/share/container-scripts/postgresql
  • 16/root/usr/share/container-scripts/postgresql
  • src/root/usr/share/container-scripts/postgresql

7 files changed

+35
-0
lines changed

10/root/usr/share/container-scripts/postgresql/common.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,11 @@ function wait_for_postgresql_master() {
296296

297297
run_pgupgrade ()
298298
(
299+
# Remove .pid file if the file persists after ugly shut down
300+
if [ -f "$PGDATA/postmaster.pid" ] && ! pgrep -f "postgres" > /dev/null; then
301+
rm -rf "$PGDATA/postmaster.pid"
302+
fi
303+
299304
optimized=false
300305
old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
301306
new_raw_version=${POSTGRESQL_VERSION//\./}

12/root/usr/share/container-scripts/postgresql/common.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,11 @@ function wait_for_postgresql_master() {
296296

297297
run_pgupgrade ()
298298
(
299+
# Remove .pid file if the file persists after ugly shut down
300+
if [ -f "$PGDATA/postmaster.pid" ] && ! pgrep -f "postgres" > /dev/null; then
301+
rm -rf "$PGDATA/postmaster.pid"
302+
fi
303+
299304
optimized=false
300305
old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
301306
new_raw_version=${POSTGRESQL_VERSION//\./}

13/root/usr/share/container-scripts/postgresql/common.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,11 @@ function wait_for_postgresql_master() {
296296

297297
run_pgupgrade ()
298298
(
299+
# Remove .pid file if the file persists after ugly shut down
300+
if [ -f "$PGDATA/postmaster.pid" ] && ! pgrep -f "postgres" > /dev/null; then
301+
rm -rf "$PGDATA/postmaster.pid"
302+
fi
303+
299304
optimized=false
300305
old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
301306
new_raw_version=${POSTGRESQL_VERSION//\./}

14/root/usr/share/container-scripts/postgresql/common.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,11 @@ function wait_for_postgresql_master() {
296296

297297
run_pgupgrade ()
298298
(
299+
# Remove .pid file if the file persists after ugly shut down
300+
if [ -f "$PGDATA/postmaster.pid" ] && ! pgrep -f "postgres" > /dev/null; then
301+
rm -rf "$PGDATA/postmaster.pid"
302+
fi
303+
299304
optimized=false
300305
old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
301306
new_raw_version=${POSTGRESQL_VERSION//\./}

15/root/usr/share/container-scripts/postgresql/common.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,11 @@ function wait_for_postgresql_master() {
296296

297297
run_pgupgrade ()
298298
(
299+
# Remove .pid file if the file persists after ugly shut down
300+
if [ -f "$PGDATA/postmaster.pid" ] && ! pgrep -f "postgres" > /dev/null; then
301+
rm -rf "$PGDATA/postmaster.pid"
302+
fi
303+
299304
optimized=false
300305
old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
301306
new_raw_version=${POSTGRESQL_VERSION//\./}

16/root/usr/share/container-scripts/postgresql/common.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,11 @@ function wait_for_postgresql_master() {
296296

297297
run_pgupgrade ()
298298
(
299+
# Remove .pid file if the file persists after ugly shut down
300+
if [ -f "$PGDATA/postmaster.pid" ] && ! pgrep -f "postgres" > /dev/null; then
301+
rm -rf "$PGDATA/postmaster.pid"
302+
fi
303+
299304
optimized=false
300305
old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
301306
new_raw_version=${POSTGRESQL_VERSION//\./}

src/root/usr/share/container-scripts/postgresql/common.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,11 @@ function wait_for_postgresql_master() {
297297

298298
run_pgupgrade ()
299299
(
300+
# Remove .pid file if the file persists after ugly shut down
301+
if [ -f "$PGDATA/postmaster.pid" ] && ! pgrep -f "postgres" > /dev/null; then
302+
rm -rf "$PGDATA/postmaster.pid"
303+
fi
304+
300305
optimized=false
301306
old_raw_version=${POSTGRESQL_PREV_VERSION//\./}
302307
new_raw_version=${POSTGRESQL_VERSION//\./}

0 commit comments

Comments
 (0)