| From: | Narek Galstyan <narek(dot)galstyan(at)enterprisedb(dot)com> |
|---|---|
| To: | pgsql-hackers(at)postgresql(dot)org |
| Subject: | Unlogged bloom indexes break after crash recovery |
| Date: | 2026-11-03 01:06:59 |
| Message-ID: | CAHsn6_y9zCAj5Vc4-nOQrNu3io_ToVdMJkbgAfW-wOnuwF6Bmw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi all,
I noticed that bloom indexes are not properly WAL-looged on unlogged tables
and attached is my attempt at fixing it
Since commit ccadf73163c
<https://github.com/postgres/postgres/commit/ccadf73163ca88bdaa74b8223d4dde05d17f550b>
(discussion:
https://www.postgresql.org/message-id/6e5bbc08-cdfc-b2b3-9e23-1a914b9850a9@iki.fi)
`contrib/bloom` index AM's blbuildempty() wrote the metapage of the init
fork through generic WAL, which emits no WAL record for an unlogged
relation.
The init fork must be WAL-logged as it is used to recreate main fork of an
unlogged relation after a crash.
Without this fix, after a crash, an unlogged and bloom-indexed relation
gets a zero-ed out index meta page. As a result, insertions and index scans
fail with "Relation is not a bloom index" or "could not read blocks 0..0",
until an index rebuild.
Narek
--
| Attachment | Content-Type | Size |
|---|---|---|
| 0001-Add-tests-for-crash-recovery-with-unlogged-bloom-ind.patch | application/octet-stream | 1.4 KB |
| 0002-Fix-init-fork-unlogged-table-WAL-logging-of-bloom-in.patch | application/octet-stream | 3.6 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Peter Smith | 2026-11-03 01:44:46 | Re: Proposal: Conflict log history table for Logical Replication |
| Previous Message | Chao Li | 2026-11-03 01:03:53 | Re: [PATCH] pgcrypto: Fix sha-crypt rounds= values that do not fit in int (BUG #19743) |