From 389e4b3734ad28fe617cac4700a1268eec77545a Mon Sep 17 00:00:00 2001 From: Narek Galstyan Date: Mon, 2 Nov 2026 15:12:31 -0500 Subject: [PATCH 1/2] Add tests for crash recovery with unlogged bloom indexes --- contrib/bloom/t/001_wal.pl | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/contrib/bloom/t/001_wal.pl b/contrib/bloom/t/001_wal.pl index 683b1876055..8f5fae4f5de 100644 --- a/contrib/bloom/t/001_wal.pl +++ b/contrib/bloom/t/001_wal.pl @@ -81,4 +81,26 @@ for my $i (1 .. 10) test_index_replay("insert $i"); } +# The init fork of an unlogged index must survive a crash before the next +# checkpoint, and must reach the standby. +$node_primary->safe_psql("postgres", + "CREATE UNLOGGED TABLE tst_unlogged (i int4, t text);"); +$node_primary->safe_psql("postgres", + "CREATE INDEX bloomidx_unlogged ON tst_unlogged USING bloom (i, t);"); +$node_primary->wait_for_catchup($node_standby); + +my $unlogged_queries = qq(INSERT INTO tst_unlogged VALUES (1, 'a'); +SET enable_seqscan=off; +SELECT count(*) FROM tst_unlogged WHERE i = 1; +); + +$node_primary->stop('immediate'); +$node_primary->start; +is($node_primary->safe_psql("postgres", $unlogged_queries), + '1', 'unlogged index usable after crash recovery'); + +$node_standby->promote; +is($node_standby->safe_psql("postgres", $unlogged_queries), + '1', 'unlogged index usable after standby promotion'); + done_testing(); -- 2.50.1 (Apple Git-155)