public inbox for [email protected]  
help / color / mirror / Atom feed
From: Adrian Klaver <[email protected]>
To: [email protected] <[email protected]>
To: [email protected]
Subject: Re: What happens if the socket lock file is deleted?
Date: Thu, 29 Jan 2026 12:40:06 -0800
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>

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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: What happens if the socket lock file is deleted?
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox