Skip to content

Commit 5002613

Browse files
committed
Limit checkpointer requests queue size
If the number of sync requests is big enough, the palloc() call in AbsorbSyncRequests() will attempt to allocate more than 1 GB of memory, resulting in failure. This can lead to an infinite loop in the checkpointer process, as it repeatedly fails to absorb the pending requests. This commit limits the checkpointer requests queue size to 10M items. In addition to preventing the palloc() failure, this change helps to avoid long queue processing time. Also, this commit is for backpathing only. The master branch receives a more invasive yet comprehensive fix for this problem. Discussion: https://postgr.es/m/db4534f83a22a29ab5ee2566ad86ca92%40postgrespro.ru Backpatch-through: 13
1 parent 868b39a commit 5002613

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/backend/postmaster/checkpointer.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ static CheckpointerShmemStruct *CheckpointerShmem;
140140
/* interval for calling AbsorbSyncRequests in CheckpointWriteDelay */
141141
#define WRITES_PER_ABSORB 1000
142142

143+
/* Max number of requests the checkpointer request queue can hold */
144+
#define MAX_CHECKPOINT_REQUESTS 10000000
145+
143146
/*
144147
* GUC parameters
145148
*/
@@ -906,7 +909,7 @@ CheckpointerShmemInit(void)
906909
*/
907910
MemSet(CheckpointerShmem, 0, size);
908911
SpinLockInit(&CheckpointerShmem->ckpt_lck);
909-
CheckpointerShmem->max_requests = NBuffers;
912+
CheckpointerShmem->max_requests = Min(NBuffers, MAX_CHECKPOINT_REQUESTS);
910913
ConditionVariableInit(&CheckpointerShmem->start_cv);
911914
ConditionVariableInit(&CheckpointerShmem->done_cv);
912915
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy