On Fri, Jan 6, 2012 at 08:28:48AM -0500, Michael Beattie wrote:
> On Fri, Jan 6, 2012 at 6:13 AM, Magnus Hagander <[email protected]> wrote:
>
> On Thu, Jan 5, 2012 at 23:19, Tom Lane <[email protected]> wrote:
> > Magnus Hagander <[email protected]> writes:
> >> On Thu, Jan 5, 2012 at 17:13, Tom Lane <[email protected]> wrote:
> >>> I think link(2) would create race conditions of its own. I'd be
> >>> inclined to suggest that maybe we should just special-case a zero
> length
> >>> postmaster.pid file as meaning "okay to proceed". In general, garbage
> >
> >> That's pretty much what I meant - but with a warning message.
> >
> > Actually ... wait a minute. If we allow that, don't we create a race
> > condition between two postmasters starting at almost the same instant?
> > The second one could see the lock file when the first has created but
> > not yet filled it.
>
> Good point, yeah, it should do that. But I still think it's rare
> enough that just special-casing the error message should be enough...
>
>
>
> so just something that does like
>
> stat(filename, &st);
> size = st.st_size;
> if (size == 0)
> elog(ERROR, "lock file \"%s\" has 0 length.", filename);
>
> somewhere in CreateLockFile in miscinit.c?
I have developed the attached patch to report a zero-length file, as you
suggested.
--
Bruce Momjian <[email protected]> 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..7b7c141
*** a/src/backend/utils/init/miscinit.c
--- b/src/backend/utils/init/miscinit.c
*************** CreateLockFile(const char *filename, boo
*** 765,770 ****
--- 765,772 ----
errmsg("could not read lock file \"%s\": %m",
filename)));
close(fd);
+ if (len == 0)
+ elog(FATAL, "lock file \"%s\" is empty", DIRECTORY_LOCK_FILE);
buffer[len] = '\0';
encoded_pid = atoi(buffer);
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers