pid.diff

text/x-diff

Filename: pid.diff
Type: text/x-diff
Part: 0
Message: Re: FATAL: bogus data in lock file "postmaster.pid": ""

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: unified
File+
src/backend/utils/init/miscinit.c 0 0
diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c
new file mode 100644
index 775d71f..0309494
*** a/src/backend/utils/init/miscinit.c
--- b/src/backend/utils/init/miscinit.c
*************** CreateLockFile(const char *filename, boo
*** 766,771 ****
--- 766,793 ----
  							filename)));
  		close(fd);
  
+ 		if (len == 0)
+ 		{
+ 			/*
+ 			 *	An empty lock file exits;  either is it from another postmaster
+ 			 *	that is still starting up, or left from a crash.  Check for
+ 			 *	five seconds, then if it still empty, it must be from a crash,
+ 			 *	so fail and recommend lock file removal.
+ 			 */
+ 			if (ntries < 5)
+ 			{
+ 				sleep(1);
+ 				continue;
+ 			}
+ 			else
+ 				ereport(FATAL,
+ 						(errcode(ERRCODE_LOCK_FILE_EXISTS),
+ 						 errmsg("lock file \"%s\" is empty", filename),
+ 						 errhint(
+ 						"Empty lock file probably left from operating system crash during\n"
+ 						"database startup;  file deletion suggested.")));
+ 		}
+ 
  		buffer[len] = '\0';
  		encoded_pid = atoi(buffer);