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

Commit6bd7816

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 gin, gist, and hash indexes.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 parent8c6b940 commit6bd7816

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,10 +870,15 @@ BufferAlloc(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
870870
* paranoia. We also reset the usage_count since any recency of use of
871871
* the old content is no longer relevant. (The usage_count starts out at
872872
* 1 so that the buffer can survive one clock-sweep pass.)
873+
*
874+
* Make sure BM_PERMANENT is set for buffers that must be written at every
875+
* checkpoint. Unlogged buffers only need to be written at shutdown
876+
* checkpoints, except for their "init" forks, which need to be treated
877+
* just like permanent relations.
873878
*/
874879
buf->tag=newTag;
875880
buf->flags &= ~(BM_VALID |BM_DIRTY |BM_JUST_DIRTIED |BM_CHECKPOINT_NEEDED |BM_IO_ERROR |BM_PERMANENT);
876-
if (relpersistence==RELPERSISTENCE_PERMANENT)
881+
if (relpersistence==RELPERSISTENCE_PERMANENT||forkNum==INIT_FORKNUM)
877882
buf->flags |=BM_TAG_VALID |BM_PERMANENT;
878883
else
879884
buf->flags |=BM_TAG_VALID;

‎src/include/storage/buf_internals.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#defineBM_PIN_COUNT_WAITER(1 << 6)/* have waiter for sole pin */
4040
#defineBM_CHECKPOINT_NEEDED(1 << 7)/* must write for checkpoint */
4141
#defineBM_PERMANENT(1 << 8)/* permanent relation (not
42-
* unlogged) */
42+
* unlogged, or init fork) */
4343

4444
typedefbits16BufFlags;
4545

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp