On 1/29/26 12:29, [email protected] wrote:
In software I have developed separately, I have noticed that most systems will 
periodically delete files within the temporary directory hierarchy that have 
not been accessed recently, and that includes lock files for long running 
processes. I have never noticed the lock file associated with a postgreSQL 
socket be missing though.

Does PostgreSQL periodically touch the lock file so it won’t be deleted? 
Alternatively, does PostgreSQL simply re-create the lock file if it has been 
deleted? I know the documentation says to never “manually”’delete one of those 
lock files.


From here at ~line 1781:

https://github.com/postgres/postgres/blob/master/src/backend/postmaster/postmaster.c

/*
                 * Once a minute, verify that postmaster.pid hasn't been 
removed or
                 * overwritten.  If it has, we force a shutdown.  This avoids 
having
                 * postmasters and child processes hanging around after their 
database
                 * is gone, and maybe causing problems if a new database 
cluster is
                 * created in the same place.  It also provides some protection
                 * against a DBA foolishly removing postmaster.pid and manually
                 * starting a new postmaster.  Data corruption is likely to 
ensue from
                 * that anyway, but we can minimize the damage by aborting ASAP.
                 */
                if (now - last_lockfile_recheck_time >= 1 * SECS_PER_MINUTE)
                {
                        if (!RecheckDataDirLockFile())
                        {
                                ereport(LOG,
(errmsg("performing immediate shutdown because data directory lock file is invalid")));
                                kill(MyProcPid, SIGQUIT);
                        }
                        last_lockfile_recheck_time = now;
                }

--
Adrian Klaver
[email protected]


Reply via email to