postgresql-container: Upgrade fails due to postmaster.pid

Container platform

OCP 4, Podman/Docker

Version

12, 13

OS version of the container image

RHEL 7, RHEL 8, CentOS 7, CentOS Stream 8

Bugzilla, Jira

No response

Description

We are trying to work on and upgrade flow from version 12 to version 13 we are using k8s deployment pods when we try to deploy the new image we get an error during the upgrade

==========  $PGDATA upgrade: 12 -> 13  ==========                                                                                                                                                 
                                                                                                                                                                                                  
                                                                                                                                                                                                  
===>  Starting old postgresql once again for a clean shutdown...                                                                                                                                  
                                                                                                                                                                                                  
pg_ctl: another server might be running; trying to start server anyway                                                                                                                            
waiting for server to start....2024-02-14 12:46:35.514 UTC [31] FATAL:  lock file "postmaster.pid" already exists                                                                                 
2024-02-14 12:46:35.514 UTC [31] HINT:  Is another postmaster (PID 1) running in data directory "/var/lib/pgsql/data/userdata"?           

It seems that the postmaster.pid is always there also on restart / redeployment and the service recovers without an issue. Only during the upgrade do we face the problem.

deleting the file and redeploying the upgrade solves it.

my question is,

  1. Is that the normal behavior ?
  2. What is the best approach to do deployment upgrades?

not sure if deleting a PID is good solution to run in Production enviorment

Reproducer

deploy version 12, and redeploy version 13 with the upgrade env

can be done with podman play or minikube

About this issue

  • Original URL
  • State: open
  • Created 4 months ago
  • Reactions: 1
  • Comments: 29 (12 by maintainers)

Most upvoted comments

@fila43 I’ve added a initial PR #562 I test it locally and seems to be working – can you review and comment

thanks !

just fyi, after playing a bit with the script I managed to upgrade to 13 – not sure this will fit all builds but this is my workaround

https://github.com/sclorg/postgresql-container/commit/9c25f36b62cbdddbedff20e51902709a2204190b

hey, I tested the fix and seems to be working as design.

but I found a new problem, the repo has no longer have centos7 builds.

and centos8 with psql-13 doesn’t have psql-12 to run the upgrade - is it a bug? ( i had to build with the old centos7 to validate the fix )

  • fedora psql13 same can’t upgrade from 12

thanks so much - i will try it out in a day or two and let you know

BTW, when you restart the image you can see that the postmater.pid is there even without the upgrade it’s not been deleted when shutdown the postgres services