Re: Large expressions in indexes can't be stored (non-TOASTable)
Nathan Bossart <nathandbossart@gmail.com>
From: Nathan Bossart <nathandbossart@gmail.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Alexander Lakhin <exclusion@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>, "Jonathan S. Katz" <jkatz@postgresql.org>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-09-24T19:26:08Z
Lists: pgsql-hackers
Attachments
- toast_snapshot.patch (text/plain) patch
On Tue, Sep 24, 2024 at 01:21:45PM +0900, Michael Paquier wrote: > On Mon, Sep 23, 2024 at 10:50:21AM -0500, Nathan Bossart wrote: >> I carefully inspected all the code paths this patch touches, and I think >> I've got all the details right, but I would be grateful if someone else >> could take a look. > > No objections from here with putting the snapshots pops and pushes > outside the inner routines of reindex/drop concurrently, meaning that > ReindexRelationConcurrently(), DefineIndex() and index_drop() are fine > to do these operations. Great. I plan to push 0001 shortly. > Actually, thinking more... Could it be better to have some more > sanity checks in the stack outside the toast code for catalogs with > toast tables? For example, I could imagine adding a check in > CatalogTupleUpdate() so as all catalog accessed that have a toast > relation require an active snapshot. That would make checks more > aggressive, because we would not need any toast data in a catalog to > make sure that there is a snapshot set. This strikes me as something > we could do better to improve the detection of failures like the one > reported by Alexander when updating catalog tuples as this can be > triggered each time we do a CatalogTupleUpdate() when dirtying a > catalog tuple. The idea is then to have something before the > HaveRegisteredOrActiveSnapshot() in the toast internals, for catalogs, > and we would not require toast data to detect problems. I gave this a try and, unsurprisingly, found a bunch of other problems. I hastily hacked together the attached patch that should fix all of them, but I'd still like to comb through the code a bit more. The three catalogs with problems are pg_replication_origin, pg_subscription, and pg_constraint. pg_contraint has had a TOAST table for a while, and I don't think it's unheard of for conbin to be large, so this one is probably worth fixing. pg_subscription hasn't had its TOAST table for quite as long, but presumably subpublications could be large enough to require out-of-line storage. pg_replication_origin, however, only has one varlena column: roname. Three out of the seven problem areas involve pg_replication_origin, but AFAICT that'd only ever be a problem if the name of your replication origin requires out-of-line storage. So... maybe we should just remove pg_replication_origin's TOAST table instead... -- nathan
Commits
-
Ensure we have a snapshot when updating various system catalogs.
- fe8ea7a2a893 17.6 landed
- ddfcfb7cec68 15.14 landed
- b7ba2c0308ce 13.22 landed
- b65be6ef00e2 14.19 landed
- 706054b11b95 18.0 landed
- 24135398f1e1 16.10 landed
-
Remove pg_replication_origin's TOAST table.
- 16bf24e0e471 18.0 landed
-
Restrict password hash length.
- 8275325a06ed 18.0 cited
-
Ensure we have a snapshot when updating pg_index entries.
- b52adbad4674 18.0 landed
-
Add TOAST table to pg_index.
- b52c4fc3c09e 18.0 landed
-
Add toast tables to most system catalogs
- 96cdeae07f93 12.0 cited