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

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: exclusion(at)gmail(dot)com
Subject: BUG #18499: Reindexing spgist index concurrently triggers Assert("TransactionIdIsValid(state->myXid)")
Date: 2024-06-07 11:00:00
Message-ID: 18499-8a519c280f956480@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 18499
Logged by: Alexander Lakhin
Email address: exclusion(at)gmail(dot)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(at)entry=0x5569af0562a0
"TransactionIdIsValid(state->myXid)", fileName=fileName(at)entry=0x5569af05636c
"spgutils.c", lineNumber=lineNumber(at)entry=1078)
at assert.c:66
#6 0x00005569aeb3c344 in spgFormDeadTuple
(state=state(at)entry=0x7ffc3a771760, tupstate=tupstate(at)entry=1,
blkno=blkno(at)entry=0, offnum=offnum(at)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.

Responses

Browse pgsql-bugs by date

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