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

Commit87f9982

Browse files
committed
Fix failure to mark init buffers as BM_PERMANENT.
This could result in corruption of the init fork of an unlogged indexif the ambuildempty routine for that index used shared buffers tocreate the init fork, which was true for brin, gin, gist, and hashindexes.Patch by me, based on an earlier patch by Michael Paquier, who alsoreviewed this one. This also incorporates an idea from ArturZakirov.Discussion:http://postgr.es/m/CACYUyc8yccE4xfxhqxfh_Mh38j7dRFuxfaK1p6dSNAEUakxUyQ@mail.gmail.com
1 parent37289ff commit87f9982

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

‎src/backend/storage/buffer/bufmgr.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1292,12 +1292,17 @@ BufferAlloc(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
12921292
* paranoia. We also reset the usage_count since any recency of use of
12931293
* the old content is no longer relevant. (The usage_count starts out at
12941294
* 1 so that the buffer can survive one clock-sweep pass.)
1295+
*
1296+
* Make sure BM_PERMANENT is set for buffers that must be written at every
1297+
* checkpoint. Unlogged buffers only need to be written at shutdown
1298+
* checkpoints, except for their "init" forks, which need to be treated
1299+
* just like permanent relations.
12951300
*/
12961301
buf->tag=newTag;
12971302
buf_state &= ~(BM_VALID |BM_DIRTY |BM_JUST_DIRTIED |
12981303
BM_CHECKPOINT_NEEDED |BM_IO_ERROR |BM_PERMANENT |
12991304
BUF_USAGECOUNT_MASK);
1300-
if (relpersistence==RELPERSISTENCE_PERMANENT)
1305+
if (relpersistence==RELPERSISTENCE_PERMANENT||forkNum==INIT_FORKNUM)
13011306
buf_state |=BM_TAG_VALID |BM_PERMANENT |BUF_USAGECOUNT_ONE;
13021307
else
13031308
buf_state |=BM_TAG_VALID |BUF_USAGECOUNT_ONE;

‎src/include/storage/buf_internals.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@
6464
#defineBM_JUST_DIRTIED(1U << 28)/* dirtied since write started */
6565
#defineBM_PIN_COUNT_WAITER(1U << 29)/* have waiter for sole pin */
6666
#defineBM_CHECKPOINT_NEEDED(1U << 30)/* must write for checkpoint */
67-
#defineBM_PERMANENT(1U << 31)/* permanentrelation (not
68-
* unlogged) */
67+
#defineBM_PERMANENT(1U << 31)/* permanentbuffer (not
68+
* unlogged, or init fork) */
6969
/*
7070
* The maximum allowed value of usage_count represents a tradeoff between
7171
* accuracy and speed of the clock-sweep buffer management algorithm. A

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp