From 7873003b75394015d694a53f4bd48c94aa95e96a Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Fri, 28 Nov 2025 21:05:18 +0200 Subject: [PATCH v14 2/4] Add test for multixid wraparound Author: Andrey Borodin --- src/test/modules/test_slru/meson.build | 3 +- .../test_slru/t/002_multixact_wraparound.pl | 50 +++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 src/test/modules/test_slru/t/002_multixact_wraparound.pl diff --git a/src/test/modules/test_slru/meson.build b/src/test/modules/test_slru/meson.build index e58bbdf75ac..691b387d13f 100644 --- a/src/test/modules/test_slru/meson.build +++ b/src/test/modules/test_slru/meson.build @@ -38,7 +38,8 @@ tests += { 'enable_injection_points': get_option('injection_points') ? 'yes' : 'no', }, 'tests': [ - 't/001_multixact.pl' + 't/001_multixact.pl', + 't/002_multixact_wraparound.pl' ], }, } diff --git a/src/test/modules/test_slru/t/002_multixact_wraparound.pl b/src/test/modules/test_slru/t/002_multixact_wraparound.pl new file mode 100644 index 00000000000..efaf902e5e3 --- /dev/null +++ b/src/test/modules/test_slru/t/002_multixact_wraparound.pl @@ -0,0 +1,50 @@ +# Copyright (c) 2024-2025, PostgreSQL Global Development Group + +# Test multixact wraparound + +use strict; +use warnings FATAL => 'all'; + +use PostgreSQL::Test::Cluster; +use PostgreSQL::Test::Utils; + +use Test::More; + +my ($node, $result); + +$node = PostgreSQL::Test::Cluster->new('mike'); +$node->init; +$node->append_conf('postgresql.conf', + "shared_preload_libraries = 'test_slru'"); + +# Set the cluster's next multitransaction to 0xFFFFFFF0. +my $node_pgdata = $node->data_dir; +command_ok( + [ + 'pg_resetwal', + '--multixact-ids' => '0xFFFFFFF0,0xFFFFFFF0', + $node_pgdata + ], + "set the cluster's next multitransaction to 0xFFFFFFF0"); +command_ok( + [ + 'dd', 'if=/dev/zero', "of=$node_pgdata/pg_multixact/offsets/FFFF", + 'bs=4', 'count=65536' + ], + "init SLRU file"); + +command_ok([ 'rm', "$node_pgdata/pg_multixact/offsets/0000", ], + "drop old SLRU file"); + +$node->start; +$node->safe_psql('postgres', q(CREATE EXTENSION test_slru)); + +# Consume multixids to wrap around +foreach my $i (1 .. 32) +{ + $node->safe_psql('postgres', q{SELECT test_create_multixact();}); +} + +$node->stop; + +done_testing(); -- 2.51.2