From: Nathan Bossart <nathandbossart@gmail.com>
To: Alexander Lakhin <exclusion@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Jonathan S. Katz <jkatz@postgresql.org>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Large expressions in indexes can't be stored (non-TOASTable)
Date: Thu, 19 Sep 2024 13:36:36 -0500
Message-ID: <ZuxvNDVfqpahqZNb@nathan> (raw)
In-Reply-To: <a97d7401-e7c9-f771-6a00-037379f0a8bb@gmail.com>
References: <b611015f-b423-458c-aa2d-be0e655cc1b4@postgresql.org>
<ZtipsVMZAGjrO1p_@nathan>
<1679756.1725476893@sss.pgh.pa.us>
<c500a379-7a20-4ab4-bcc9-5ea9aabe017a@postgresql.org>
<ZuroEfWjxd4Zj6Yq@nathan>
<1812111.1726671296@sss.pgh.pa.us>
<ZusvlZBrPKm913LA@nathan>
<a97d7401-e7c9-f771-6a00-037379f0a8bb@gmail.com>
On Thu, Sep 19, 2024 at 12:00:00PM +0300, Alexander Lakhin wrote:
> I've discovered that Jonathan's initial script:
> CREATE TABLE def (id int);
> SELECT array_agg(n) b FROM generate_series(1,10_000) n \gset
> CREATE OR REPLACE FUNCTION vec_quantizer (a int, b int[]) RETURNS bool
> AS $$ SELECT true $$ LANGUAGE SQL IMMUTABLE;
> CREATE INDEX ON def (vec_quantizer(id, :'b'));
>
> completed with:
> DROP INDEX CONCURRENTLY def_vec_quantizer_idx;
>
> triggers an assertion failure:
> TRAP: failed Assert("HaveRegisteredOrActiveSnapshot()"), File: "toast_internals.c", Line: 668, PID: 3723372
Ha, that was fast. The attached patch seems to fix the assertion failures.
It's probably worth checking if any of the adjacent code paths are
affected, too.
--
nathan
Attachments:fix_assert.patch (text/plain, 1.1K) downloaddiff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.cindex b2b3ecb524..2e378ef4ef 100644--- a/src/backend/catalog/index.c+++ b/src/backend/catalog/index.c@@ -2255,6 +2255,7 @@ index_drop(Oid indexId, bool concurrent, bool concurrent_lock_mode)
PopActiveSnapshot();
CommitTransactionCommand();
StartTransactionCommand();
+ PushActiveSnapshot(GetTransactionSnapshot());
/*
* Now we must wait until no running transaction could be using the
@@ -2283,8 +2284,10 @@ index_drop(Oid indexId, bool concurrent, bool concurrent_lock_mode)
* Again, commit the transaction to make the pg_index update visible
* to other sessions.
*/
+ PopActiveSnapshot();
CommitTransactionCommand();
StartTransactionCommand();
+ PushActiveSnapshot(GetTransactionSnapshot());
/*
* Wait till every transaction that saw the old index state has
@@ -2387,6 +2390,8 @@ index_drop(Oid indexId, bool concurrent, bool concurrent_lock_mode)
{
UnlockRelationIdForSession(&heaprelid, ShareUpdateExclusiveLock);
UnlockRelationIdForSession(&indexrelid, ShareUpdateExclusiveLock);
++ PopActiveSnapshot();
}
}
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-hackers@postgresql.org
Cc: nathandbossart@gmail.com, exclusion@gmail.com, tgl@sss.pgh.pa.us, jkatz@postgresql.org, pgsql-hackers@lists.postgresql.org
Subject: Re: Large expressions in indexes can't be stored (non-TOASTable)
In-Reply-To: <ZuxvNDVfqpahqZNb@nathan>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox