🌐 AI搜索 & 代理 主页
Skip to content

Commit 4b6d096

Browse files
committed
Do not emit WAL for unlogged BRIN indexes
Operations on unlogged relations should not be WAL-logged. The brin_initialize_empty_new_buffer() function didn't get the memo. The function is only called when a concurrent update to a brin page uses up space that we're just about to insert to, which makes it pretty hard to hit. If you do manage to hit it, a full-page WAL record is erroneously emitted for the unlogged index. If you then crash, crash recovery will fail on that record with an error like this: FATAL: could not create file "base/5/32819": File exists Author: Kirill Reshke <reshkekirill@gmail.com> Discussion: https://www.postgresql.org/message-id/CALdSSPhpZXVFnWjwEBNcySx_vXtXHwB2g99gE6rK0uRJm-3GgQ@mail.gmail.com Backpatch-through: 14
1 parent a3e7bbd commit 4b6d096

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/backend/access/brin/brin_pageops.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,11 @@ brin_initialize_empty_new_buffer(Relation idxrel, Buffer buffer)
893893
page = BufferGetPage(buffer);
894894
brin_page_init(page, BRIN_PAGETYPE_REGULAR);
895895
MarkBufferDirty(buffer);
896-
log_newpage_buffer(buffer, true);
896+
897+
/* XLOG stuff */
898+
if (RelationNeedsWAL(idxrel))
899+
log_newpage_buffer(buffer, true);
900+
897901
END_CRIT_SECTION();
898902

899903
/*

0 commit comments

Comments
 (0)