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

Commitf8a0516

Browse files
committed
Bgwriter should PANIC if it runs out of memory for pending-fsyncs
hash table. This is a pretty unlikely scenario, since the tableshould be tiny, but we can't guarantee continued correct operationif it does occur. Spotted by Qingqing Zhou.
1 parent6d9ee03 commitf8a0516

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

‎src/backend/postmaster/bgwriter.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/postmaster/bgwriter.c,v 1.15 2005/03/04 20:21:06 tgl Exp $
40+
* $PostgreSQL: pgsql/src/backend/postmaster/bgwriter.c,v 1.16 2005/05/28 17:21:32 tgl Exp $
4141
*
4242
*-------------------------------------------------------------------------
4343
*/
@@ -616,7 +616,7 @@ ForwardFsyncRequest(RelFileNode rnode, BlockNumber segno)
616616
*
617617
* This is exported because it must be called during CreateCheckPoint;
618618
* we have to be sure we have accepted all pending requests *after* we
619-
* establish the checkpointredo pointer. Since CreateCheckPoint
619+
* establish the checkpointREDO pointer. Since CreateCheckPoint
620620
* sometimes runs in non-bgwriter processes, do nothing if not bgwriter.
621621
*/
622622
void
@@ -629,6 +629,15 @@ AbsorbFsyncRequests(void)
629629
if (!am_bg_writer)
630630
return;
631631

632+
/*
633+
* We have to PANIC if we fail to absorb all the pending requests
634+
* (eg, because our hashtable runs out of memory). This is because
635+
* the system cannot run safely if we are unable to fsync what we
636+
* have been told to fsync. Fortunately, the hashtable is so small
637+
* that the problem is quite unlikely to arise in practice.
638+
*/
639+
START_CRIT_SECTION();
640+
632641
/*
633642
* We try to avoid holding the lock for a long time by copying the
634643
* request array.
@@ -647,6 +656,9 @@ AbsorbFsyncRequests(void)
647656

648657
for (request=requests;n>0;request++,n--)
649658
RememberFsyncRequest(request->rnode,request->segno);
659+
650660
if (requests)
651661
pfree(requests);
662+
663+
END_CRIT_SECTION();
652664
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp