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

Commit1358466

Browse files
committed
Fix bootstrap.c so that database startup process and bgwriter properly release
LWLocks during a panic exit. This avoids the possible self-deadlock pointedout by Qingqing Zhou. Also, I noted that an error during LoadFreeSpaceMap()or BuildFlatFiles() would result in exit(0) which would leave the postmasterthinking all is well. Added a critical section to ensure such errors don'tallow startup to proceed.Backpatched to 8.1. The 8.0 code is a bit different and I'm not sure if theproblem exists there; given we've not seen this reported from the field, I'mgoing to be conservative about backpatching any further.
1 parente4725e3 commit1358466

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

‎src/backend/bootstrap/bootstrap.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.215 2006/05/10 23:18:39 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.216 2006/06/08 23:55:48 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -55,6 +55,7 @@ extern char *optarg;
5555

5656
staticvoidusage(void);
5757
staticvoidbootstrap_signals(void);
58+
staticvoidShutdownDummyProcess(intcode,Datumarg);
5859
statichashnode*AddStr(char*str,intstrlength,intmderef);
5960
staticForm_pg_attributeAllocateAttribute(void);
6061
staticintCompHash(char*str,intlen);
@@ -395,6 +396,9 @@ BootstrapMain(int argc, char *argv[])
395396

396397
/* finish setting up bufmgr.c */
397398
InitBufferPoolBackend();
399+
400+
/* register a shutdown callback for LWLock cleanup */
401+
on_shmem_exit(ShutdownDummyProcess,0);
398402
}
399403

400404
/*
@@ -417,8 +421,14 @@ BootstrapMain(int argc, char *argv[])
417421
caseBS_XLOG_STARTUP:
418422
bootstrap_signals();
419423
StartupXLOG();
424+
/*
425+
* These next two functions don't consider themselves critical,
426+
* but we'd best PANIC anyway if they fail.
427+
*/
428+
START_CRIT_SECTION();
420429
LoadFreeSpaceMap();
421430
BuildFlatFiles(false);
431+
END_CRIT_SECTION();
422432
proc_exit(0);/* startup done */
423433

424434
caseBS_XLOG_BGWRITER:
@@ -552,6 +562,19 @@ bootstrap_signals(void)
552562
}
553563
}
554564

565+
/*
566+
* Begin shutdown of a dummy process. This is approximately the equivalent
567+
* of ShutdownPostgres() in postinit.c. We can't run transactions in a
568+
* dummy process, so most of the work of AbortTransaction() is not needed,
569+
* but we do need to make sure we've released any LWLocks we are holding.
570+
* (This is only critical during an error exit.)
571+
*/
572+
staticvoid
573+
ShutdownDummyProcess(intcode,Datumarg)
574+
{
575+
LWLockReleaseAll();
576+
}
577+
555578
/* ----------------
556579
*error handling / abort routines
557580
* ----------------

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp