Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc299477

Browse files
committed
Fix filling of postmaster.pid in bootstrap/standalone mode.
We failed to ever fill the sixth line (LISTEN_ADDR), which caused theattempt to fill the seventh line (SHMEM_KEY) to fail, so that the sharedmemory key never got added to the file in standalone mode. This has beenbroken since we added more content to our lock files in 9.1.To fix, tweak the logic in CreateLockFile to add an empty LISTEN_ADDRline in standalone mode. This is a tad grotty, but since that functionalready knows almost everything there is to know about the contents oflock files, it doesn't seem that it's any better to hack it elsewhere.It's not clear how significant this bug really is, since a standalonebackend should never have any children and thus it seems not criticalto be able to check the nattch count of the shmem segment externally.But I'm going to back-patch the fix anyway.This problem had escaped notice because of an ancient (and in hindsightpretty dubious) decision to suppress LOG-level messages by default instandalone mode; so that the elog(LOG) complaint in AddToDataDirLockFilethat should have warned of the problem didn't do anything. Fixing thatis material for a separate patch though.
1 parent3717f08 commitc299477

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

‎src/backend/utils/init/miscinit.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -894,9 +894,9 @@ CreateLockFile(const char *filename, bool amPostmaster,
894894

895895
/*
896896
* Successfully created the file, now fill it.See comment in miscadmin.h
897-
* about the contents.Note that we write the sameinfo into both datadir
898-
* and socket lockfiles; although more stuff may get added to the datadir
899-
* lockfile later.
897+
* about the contents.Note that we write the samefirst five lines into
898+
*both datadirand socket lockfiles; although more stuff may get added to
899+
*the datadirlockfile later.
900900
*/
901901
snprintf(buffer,sizeof(buffer),"%d\n%s\n%ld\n%d\n%s\n",
902902
amPostmaster ? (int)my_pid :-((int)my_pid),
@@ -905,6 +905,13 @@ CreateLockFile(const char *filename, bool amPostmaster,
905905
PostPortNumber,
906906
socketDir);
907907

908+
/*
909+
* In a standalone backend, the next line (LOCK_FILE_LINE_LISTEN_ADDR)
910+
* will never receive data, so fill it in as empty now.
911+
*/
912+
if (isDDLock&& !amPostmaster)
913+
strlcat(buffer,"\n",sizeof(buffer));
914+
908915
errno=0;
909916
if (write(fd,buffer,strlen(buffer))!=strlen(buffer))
910917
{
@@ -1078,7 +1085,8 @@ AddToDataDirLockFile(int target_line, const char *str)
10781085
{
10791086
if ((srcptr=strchr(srcptr,'\n'))==NULL)
10801087
{
1081-
elog(LOG,"bogus data in \"%s\"",DIRECTORY_LOCK_FILE);
1088+
elog(LOG,"incomplete data in \"%s\": found only %d newlines while trying to add line %d",
1089+
DIRECTORY_LOCK_FILE,lineno-1,target_line);
10821090
close(fd);
10831091
return;
10841092
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp