2


I used this https://github.com/tianon/docker-postgres-upgrade to upgrade postgres from 11 to 12 version & facing issue while upgrade, got error - "postmaster servicing the old cluster"

Here using docker container for 11 & 12 in separately, also scale down docker service before that upgarde, but not sure why this postmaster issue came & how to fix this.??

docker run --rm \
    -v aip-pgs-data:/var/lib/postgresql/$OLD/data \
    -v aip-pg12-data:/var/lib/postgresql/$NEW/data \
    "tianon/postgres-upgrade:$OLD-to-$NEW"

Above docker run cmd part of logs:--

Success. You can now start the database server using:

    pg_ctl -D /var/lib/postgresql/12/data -l logfile start


There seems to be a postmaster servicing the old cluster.
Please shutdown that postmaster and try again.
Failure, exiting
0a5839ad7309d6256510fe89513774a16c4f26ec6a827f9f0089fd8cc10254cb

Thank you in advance.

user2128514
  • 47
  • 2
  • 9
  • "Please shutdown that postmaster and try again." - did you try shutting down the old postmaster like it asks you to? – Richard Huxton Nov 01 '19 at 09:29
  • @RichardHuxton before running the above "tianon/postgres-upgrade" docker run, i have scaled postgres docker service to 0 like ( docker service scale pgs=0 ), But still throwing why..? Did i wrong..? Or any other way to stop postmaster..? – user2128514 Nov 01 '19 at 13:21
  • It seems like rather than doing `docker service scale pgs=0`, you need to actually `docker stop` the v11 container – richyen Nov 01 '19 at 17:45
  • @RichardHuxton I have tried that but still getting some error like below after manual stop docker container. error-: – user2128514 Nov 04 '19 at 15:09
  • @RichardHuxton I have tried that but still getting some error like below after manual stop docker container. Error:- – user2128514 Nov 04 '19 at 15:13
  • Error :--- Success. You can now start the database server using: pg_ctl -D /var/lib/postgresql/12/data -l logfile start initdb: warning: enabling "trust" authentication for local connections You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb. Performing Consistency Checks ----------------------------- Checking cluster versions ok The source cluster was not shut down cleanly. Failure, exiting – user2128514 Nov 04 '19 at 15:13
  • I tried a longer stop_grace_period so that postgresql server will have enough time to stop everything when it receives the SIGTERM (https://www.postgresql.org/docs/11/server-shutdown.html). Then postgres stopped – user2128514 Nov 08 '19 at 08:00

2 Answers2

1

The problem is that the postgres server isn't shutting down cleanly before docker kills it, but stopping the process will also restart the container.

Another option is to disable restarts

docker update --restart=no $CONTAINER_ID

then exec into the container

docker exec -it $CONTAINER_ID bash

find the pg_ctl binary, su to the postgres user, then run pg_ctl stop

# which pg_ctl
/usr/lib/postgresql/12/bin/pg_ctl
# su postgres
$ /usr/lib/postgresql/12/bin/pg_ctl stop
Curtis Mattoon
  • 4,642
  • 2
  • 27
  • 34
0

I tried a longer stop_grace_period so that postgresql server will have enough time to stop everything when it receives the SIGTERM (postgresql.org/docs/11/server-shutdown.html). Then postgres stopped

user2128514
  • 47
  • 2
  • 9