Update pgxn/neon/pagestore_smgr.c

Co-authored-by: Heikki Linnakangas <heikki@neon.tech>
This commit is contained in:
Konstantin Knizhnik
2024-06-01 22:01:39 +03:00
committed by GitHub
parent ab706fc88d
commit 890143fcfc

View File

@@ -3064,6 +3064,14 @@ neon_end_unlogged_build(SMgrRelation reln)
/* Make the relation look permanent again */
reln->smgr_relpersistence = RELPERSISTENCE_PERMANENT;
/*
* Drop all buffers of the relation from buffer cache. They have valid contents, so it's a bit sad to throw
* them away, but they might be marked as !BM_PERMANENT, which is no longer true and could cause
* trouble afterwards. Also, there's a race condition with checkpoint and the mdunlink call below: The
* checkpointer uses mdexists() to check if the buffer belongs to an unlogged relation, and then writes
* the page to disk if it exists, but we might unlink the file in between the mdexists() and mdwrite() calls,
* causing the write to fail.
*/
{
static ForkNumber forks[] = { MAIN_FORKNUM, FSM_FORKNUM, VISIBILITYMAP_FORKNUM };
static BlockNumber blocks[] = { 0, 0, 0 };