pgsql: Do not emit WAL for unlogged BRIN indexes

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Do not emit WAL for unlogged BRIN indexes
Date: 2025-12-18 13:13:28
Message-ID: E1vWDot-001QI7-1a@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(at)gmail(dot)com>
Discussion: https://www.postgresql.org/message-id/CALdSSPhpZXVFnWjwEBNcySx_vXtXHwB2g99gE6rK0uRJm-3GgQ@mail.gmail.com
Backpatch-through: 14

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/951b60f7abdcdeb37f2d73ad4822f278d2687c1c

Modified Files
--------------
src/backend/access/brin/brin_pageops.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Noah Misch 2025-12-18 18:25:51 pgsql: Sort DO_SUBSCRIPTION_REL dump objects independent of OIDs.
Previous Message Amit Kapila 2025-12-18 05:16:40 pgsql: Fix intermittent BF failure in 040_standby_failover_slots_sync.