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

Commit055c352

Browse files
After any checkpoint, close all smgr files handles in bgwriter
1 parenta297d64 commit055c352

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

‎src/backend/postmaster/bgwriter.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,15 @@ BackgroundWriterMain(void)
276276
*/
277277
pgstat_send_bgwriter();
278278

279+
if (FirstCallSinceLastCheckpoint())
280+
{
281+
/*
282+
* After any checkpoint, close all smgr files.This is so we
283+
* won't hang onto smgr references to deleted files indefinitely.
284+
*/
285+
smgrcloseall();
286+
}
287+
279288
/*
280289
* Sleep until we are signaled or BgWriterDelay has elapsed.
281290
*

‎src/backend/postmaster/checkpointer.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,3 +1346,28 @@ UpdateSharedMemoryConfig(void)
13461346

13471347
elog(DEBUG2,"checkpointer updated shared memory configuration values");
13481348
}
1349+
1350+
/*
1351+
* FirstCallSinceLastCheckpoint allows a process to take an action once
1352+
* per checkpoint cycle by asynchronously checking for checkpoint completion.
1353+
*/
1354+
bool
1355+
FirstCallSinceLastCheckpoint(void)
1356+
{
1357+
/* use volatile pointer to prevent code rearrangement */
1358+
volatileCheckpointerShmemStruct*cps=CheckpointerShmem;
1359+
staticintckpt_done=0;
1360+
intnew_done;
1361+
boolFirstCall= false;
1362+
1363+
SpinLockAcquire(&cps->ckpt_lck);
1364+
new_done=cps->ckpt_done;
1365+
SpinLockRelease(&cps->ckpt_lck);
1366+
1367+
if (new_done!=ckpt_done)
1368+
FirstCall= true;
1369+
1370+
ckpt_done=new_done;
1371+
1372+
returnFirstCall;
1373+
}

‎src/include/postmaster/bgwriter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,6 @@ extern void AbsorbFsyncRequests(void);
3838
externSizeCheckpointerShmemSize(void);
3939
externvoidCheckpointerShmemInit(void);
4040

41+
externboolFirstCallSinceLastCheckpoint(void);
42+
4143
#endif/* _BGWRITER_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp