TRAP: failed Assert("offsets[i] > offsets[i - 1]"), File: "tidstore.c" - Mailing list pgsql-bugs

From Andrei Lepikhov
Subject TRAP: failed Assert("offsets[i] > offsets[i - 1]"), File: "tidstore.c"
Date
Msg-id b97f1850-fc7b-43c4-9b04-4e97bb9e7dc0@gmail.com
Whole thread
Responses Re: TRAP: failed Assert("offsets[i] > offsets[i - 1]"), File: "tidstore.c"
List pgsql-bugs
Hi,

While experimenting with query plans, I periodically see test_tidstore 
fail on the assertion in TidStoreSetBlockOffsets().

The cause is that the harness function do_set_block_offsets() forwards 
the SQL array straight to TidStoreSetBlockOffsets(), which has an 
explicit contract:

"The offset numbers 'offsets' must be sorted in ascending order."

array_agg() without ORDER BY gives no such guarantee, and plan shapes 
that reshuffle the input can deliver the offsets out of order and trip 
the Assert.

The issue is minor and doesn't expose any underlying bug, but it is 
still worth fixing: it removes a source of flaky test runs and makes 
life easier for extension developers who reuse the same pattern.

Patch attached.

-- 
regards, Andrei Lepikhov,
pgEdge

Attachment

pgsql-bugs by date:

Previous
From: SIEBERT Florent
Date:
Subject: patroni-4.1.1-1PGDG.rhel9.7.noarch.rpm missing in https://download.postgresql.org/pub/repos/yum/common/redhat/rhel-9-x86_64/
Next
From: "David G. Johnston"
Date:
Subject: Re: BUG #19456: # Unit-Labeling Issue: `pg_size_pretty()` Incorrectly Labels Binary Units as Decimal Units