agora inbox for pgsql-bugs@postgresql.org  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: exclusion@gmail.com
Subject: BUG #19686: Rolling back SET TABLESPACE + INSERT leads to index corruption
Date: Sun, 13 Sep 2026 16:00:01 +0000
Message-ID: <19686-30f4da834585129f@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      19686
Logged by:          Alexander Lakhin
Email address:      exclusion@gmail.com
PostgreSQL version: 19beta3
Operating system:   Ubuntu 24.04
Description:        

The following script:
rm -rf /tmp/ts
mkdir /tmp/ts

echo "
CREATE TABLESPACE ts LOCATION '/tmp/ts';
CREATE TABLE t (a int);
CREATE INDEX ON t(a);

BEGIN;
ALTER TABLE t SET TABLESPACE ts;
INSERT INTO t VALUES (0);
ROLLBACK;
INSERT INTO t VALUES (0);
INSERT INTO t SELECT i FROM generate_series(1, 4000) i;
" | psql

triggers:
2026-09-13 18:09:42.598 EEST|postgres|regression|6aa6bcb6.297fd6|LOG:
statement: INSERT INTO t SELECT i FROM generate_series(1, 4000) i;
TRAP: failed Assert("_bt_posting_valid(itup)"), File: "nbtdedup.c", Line:
900, PID: 2719702
ExceptionalCondition at assert.c:51:13
_bt_form_posting at nbtdedup.c:905:7
_bt_dedup_finish_pending at nbtdedup.c:584:11
_bt_dedup_pass at nbtdedup.c:173:15
_bt_delete_or_dedup_one_page at nbtinsert.c:2827:3
_bt_findinsertloc at nbtinsert.c:918:4
_bt_doinsert at nbtinsert.c:261:16
btinsert at nbtree.c:219:11
index_insert at indexam.c:231:9

The assertion failure is reproduced starting from 0d861bbb7.

The index corruption is also reproduced with gist:
echo "
CREATE TABLESPACE ts LOCATION '/tmp/ts';
CREATE TABLE t (a int4range);
CREATE INDEX ON t USING gist (a);

BEGIN;
ALTER TABLE t SET TABLESPACE ts;
INSERT INTO t VALUES (int4range(0, 5));
ROLLBACK;
INSERT INTO t VALUES (int4range(0, 5));
" | psql

echo "
SELECT * FROM t;
SET enable_seqscan = off;
SET enable_bitmapscan = off;
EXPLAIN SELECT * FROM t WHERE a && int4range(0, 100);
SELECT * FROM t WHERE a && int4range(0, 100);
" | psql

returns:
ROLLBACK
INSERT 0 1
   a
-------
 [0,5)
(1 row)

SET
SET
                               QUERY PLAN
-------------------------------------------------------------------------
 Index Only Scan using t_a_idx on t  (cost=0.14..40.39 rows=14 width=32)
   Index Cond: (a && '[0,100)'::int4range)
(2 rows)

   a
-------
 [0,5)
 [0,5)
(2 rows)








view thread (2+ messages)  latest in thread

Message-ID: <19686-30f4da834585129f@postgresql.org>
Permalink:  ../19686-30f4da834585129f@postgresql.org/
Also on:    postgresql.org/message-id/19686-30f4da834585129f@postgresql.org

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, exclusion@gmail.com
  Subject: Re: BUG #19686: Rolling back SET TABLESPACE + INSERT leads to index corruption
  In-Reply-To: <19686-30f4da834585129f@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox