Skip site navigation (1) Skip section navigation (2)

Re: FATAL: bogus data in lock file "postmaster.pid": ""

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>,Robert Haas <robertmhaas(at)gmail(dot)com>,Michael Beattie <mtbeedee(at)gmail(dot)com>,Magnus Hagander <magnus(at)hagander(dot)net>,Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>,Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: FATAL: bogus data in lock file "postmaster.pid": ""
Date: 2012-08-29 21:05:37
Message-ID: 20120829210537.GB8753@momjian.us (view raw or flat)
Thread:
Lists: pgsql-hackers
Applied.

---------------------------------------------------------------------------

On Wed, Aug 29, 2012 at 08:51:40AM -0400, Bruce Momjian wrote:
> On Wed, Aug 29, 2012 at 12:56:26AM -0400, Tom Lane wrote:
> > Bruce Momjian <bruce(at)momjian(dot)us> writes:
> > > On Wed, Aug 29, 2012 at 12:24:26AM -0400, Alvaro Herrera wrote:
> > >> It's a pretty strange line wrap you got in this version of the patch.
> > >> Normally we just let the string run past the 78 char limit, without
> > >> cutting it in any way.  And moving the start of the string to the line
> > >> following "errhint(" looks very odd to me.
> > 
> > > OK, updated patch attached.
> > 
> > I agree with Alvaro's complaint that moving the whole string literal to
> > the next line isn't conformant to our usual coding style.  Definitely
> > nitpicky, but why would you do it like that?
> 
> I remember now why I added "\n".  I am used to writing pg_upgrade output
> strings, which are obviously not sent to log files.  Seems I forgot that
> distinction.  As far as moving the string to the next line, I was trying
> to keep the line from getting too long.  
> 
> Updated patch has everyone on the same line.  I am fine with nitpicky. 
> Frankly, I have applied so many patches in the past few weeks, I am glad
> someone is watching.
> 
> -- 
>   Bruce Momjian  <bruce(at)momjian(dot)us>        http://momjian.us
>   EnterpriseDB                             http://enterprisedb.com
> 
>   + It's impossible for everything to be true. +

> diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c
> new file mode 100644
> index 775d71f..9a0f92c
> *** a/src/backend/utils/init/miscinit.c
> --- b/src/backend/utils/init/miscinit.c
> *************** CreateLockFile(const char *filename, boo
> *** 766,771 ****
> --- 766,779 ----
>   							filename)));
>   		close(fd);
>   
> + 		if (len == 0)
> + 		{
> + 			ereport(FATAL,
> + 					(errcode(ERRCODE_LOCK_FILE_EXISTS),
> + 					 errmsg("lock file \"%s\" is empty", filename),
> + 					 errhint("Either another server is starting, or the lock file is the remnant of a previous server startup crash.")));
> + 		}
> + 
>   		buffer[len] = '\0';
>   		encoded_pid = atoi(buffer);
>   
> diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
> new file mode 100644
> index af8d8b2..81ba39e
> *** a/src/bin/pg_ctl/pg_ctl.c
> --- b/src/bin/pg_ctl/pg_ctl.c
> *************** get_pgpid(void)
> *** 292,299 ****
>   	}
>   	if (fscanf(pidf, "%ld", &pid) != 1)
>   	{
> ! 		write_stderr(_("%s: invalid data in PID file \"%s\"\n"),
> ! 					 progname, pid_file);
>   		exit(1);
>   	}
>   	fclose(pidf);
> --- 292,304 ----
>   	}
>   	if (fscanf(pidf, "%ld", &pid) != 1)
>   	{
> ! 		/* Is the file empty? */
> ! 		if (ftell(pidf) == 0 && feof(pidf))
> ! 			write_stderr(_("%s: the PID file \"%s\" is empty\n"),
> ! 						 progname, pid_file);
> ! 		else
> ! 			write_stderr(_("%s: invalid data in PID file \"%s\"\n"),
> ! 						 progname, pid_file);
>   		exit(1);
>   	}
>   	fclose(pidf);

> 
> -- 
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers


-- 
  Bruce Momjian  <bruce(at)momjian(dot)us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +


In response to

pgsql-hackers by date

Next:From: Robert HaasDate: 2012-08-29 21:08:09
Subject: Re: MySQL search query is not executing in Postgres DB
Previous:From: Tom LaneDate: 2012-08-29 20:06:16
Subject: Re: splitting *_desc routines

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group