On Mon, Aug 27, 2012 at 10:17:43PM -0400, Bruce Momjian wrote:
> Seems pg_ctl would also need some cleanup if we change the error
> message and/or timing.
> 
> I am thinking we should just change the error message in the postmaster
> and pg_ctl to say the file is empty, and call it done (no hint message).
> If we do want a hint, say that either the file is stale from a crash or
> another postmaster is starting up, and let the user diagnose it.

Updated patch attached which just reports the file as empty.  I assume
we don't want the extra text output for pg_ctl like we do for the
backend.

-- 
  Bruce Momjian  <br...@momjian.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..9f0a58a
*** a/src/backend/utils/init/miscinit.c
--- b/src/backend/utils/init/miscinit.c
*************** CreateLockFile(const char *filename, boo
*** 766,771 ****
--- 766,781 ----
  							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\n"
+ 					 "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..0be0f2d
*** 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 (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@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to