BUG #18499: Reindexing spgist index concurrently triggers Assert("TransactionIdIsValid(state->myXid)") - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #18499: Reindexing spgist index concurrently triggers Assert("TransactionIdIsValid(state->myXid)")
Date
Msg-id 18499-8a519c280f956480@postgresql.org
Whole thread Raw
Responses Re: BUG #18499: Reindexing spgist index concurrently triggers Assert("TransactionIdIsValid(state->myXid)")
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      18499
Logged by:          Alexander Lakhin
Email address:      exclusion@gmail.com
PostgreSQL version: 17beta1
Operating system:   Ubuntu 22.04
Description:

The following script:
cat << EOF | psql &
CREATE TABLE t(i int, p point);
CREATE INDEX spgist_point_idx ON t USING spgist(p);

INSERT INTO t (i, p)
        SELECT g, point(g*10+1, g*10+1) FROM generate_series(1, 100000) g;
SELECT pg_sleep(1);
INSERT INTO t (i, p)
        SELECT g, point(g*10+1, g*10+1) FROM generate_series(1, 100000) g;
EOF

cat << EOF | psql
SELECT pg_sleep(1);
REINDEX INDEX CONCURRENTLY spgist_point_idx;
EOF

triggers an assertion failure with the following stack trace:
TRAP: failed Assert("TransactionIdIsValid(state->myXid)"), File:
"spgutils.c", Line: 1078, PID: 2975757

(gdb) bt
...
#5  0x00005569aefe0727 in ExceptionalCondition
(conditionName=conditionName@entry=0x5569af0562a0
"TransactionIdIsValid(state->myXid)", fileName=fileName@entry=0x5569af05636c
"spgutils.c", lineNumber=lineNumber@entry=1078)
    at assert.c:66
#6  0x00005569aeb3c344 in spgFormDeadTuple
(state=state@entry=0x7ffc3a771760, tupstate=tupstate@entry=1,
blkno=blkno@entry=0, offnum=offnum@entry=1) at spgutils.c:1078
#7  0x00005569aeb3385b in spgPageIndexMultiDelete (...) at
spgdoinsert.c:166
#8  0x00005569aeb34d90 in doPickSplit (...) at spgdoinsert.c:1177
#9  0x00005569aeb35a57 in spgdoinsert (...) at spgdoinsert.c:2139
#10 0x00005569aeb3661f in spginsert (...) at spginsert.c:206
#11 0x00005569aeb11a6d in index_insert (...) at indexam.c:230
#12 0x00005569aeb035f5 in heapam_index_validate_scan (...) at
heapam_handler.c:1963
#13 0x00005569aeb9589b in table_index_validate_scan (...) at
../../../src/include/access/tableam.h:1855
#14 validate_index (...) at index.c:3392
#15 0x00005569aec4dbeb in ReindexRelationConcurrently (...) at
indexcmds.c:4036
#16 0x00005569aec4ec05 in ReindexIndex (...) at indexcmds.c:2814
#17 0x00005569aec4efd9 in ExecReindex (...) at indexcmds.c:2743

(gdb) frame 6
(gdb) p state->myXid
$3 = 0

Without asserts enabled, REINDEX executed with no error.

Reproduced on REL_12_STABLE .. master.


pgsql-bugs by date:

Previous
From: Michael Paquier
Date:
Subject: Re: error "can only drop stats once" brings down database
Next
From: "Wetmore, Matthew (CTR)"
Date:
Subject: RE: [EXTERNAL] BUG #18498: Locking a table from a trigger (with using two sessions) causes a deadlock: the bug or the feature?