From: Andrey Lepikhov <a.lepikhov@postgrespro.ru>
To: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Paquier <michael@paquier.xyz>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: Assertion on create index concurrently
Date: Sun, 27 Jun 2021 22:33:44 +0300
Message-ID: <a988c2c0-5c6c-27e4-3acb-a4e2bdebd064@postgrespro.ru> (raw)
In-Reply-To: <9238.1624808236@sss.pgh.pa.us>
References: <9b905019-5297-7372-0ad2-e1a4bb66a719@postgrespro.ru>
<YNfV9WfPh7eduCfM@paquier.xyz>
<9238.1624808236@sss.pgh.pa.us>
On 27/6/21 18:37, Tom Lane wrote:
> Michael Paquier <michael@paquier.xyz> writes:
>> On Sat, Jun 26, 2021 at 09:48:45PM +0300, Andrey Lepikhov wrote:
>>> This problem affects PG 9.6 - 13. The master branch was fixed 9 months ago
>>> by commit 83158f7, that made this operation transactional, but still.
>
>> This looks like a good argument for back-patching 83158f7 all the way
>> down, as 813fb03 exists since 9.4. Any thoughts from others?
>
> +1 ... 83158f7 has survived long enough to have reasonable confidence
> in it.
Technically, 83158f7 is trivial patch. I think, some efforts is required
only for PG9.6. I prepared a patch for this version.
--
regards,
Andrey Lepikhov
Postgres Professional
Attachments:0001-Back-patch-of-83158f7-for-PG9_6.patch (text/plain, 2.4K) download
From 1bcb60119f8de5f63165e5de51289156747041c2 Mon Sep 17 00:00:00 2001
From: "Andrey V. Lepikhov" <a.lepikhov@postgrespro.ru>
Date: Sun, 27 Jun 2021 22:29:40 +0300
Subject: [PATCH] Back-patch of 83158f7 for PG9_6
---
src/backend/catalog/index.c | 23 ++++++++---------------
1 file changed, 8 insertions(+), 15 deletions(-)
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.cindex f1fe529981..35c44fa26a 100644--- a/src/backend/catalog/index.c+++ b/src/backend/catalog/index.c@@ -3281,18 +3281,10 @@ validate_index_heapscan(Relation heapRelation,
* index_set_state_flags - adjust pg_index state flags
*
* This is used during CREATE/DROP INDEX CONCURRENTLY to adjust the pg_index
- * flags that denote the index's state. Because the update is not- * transactional and will not roll back on error, this must only be used as- * the last step in a transaction that has not made any transactional catalog- * updates!+ * flags that denote the index's state.
*
- * Note that heap_inplace_update does send a cache inval message for the+ * Note that CatalogTupleUpdate() sends a cache invalidation message for the
* tuple, so other sessions will hear about the update as soon as we commit.
- *- * NB: In releases prior to PostgreSQL 9.4, the use of a non-transactional- * update here would have been unsafe; now that MVCC rules apply even for- * system catalog scans, we could potentially use a transactional update here- * instead.
*/
void
index_set_state_flags(Oid indexId, IndexStateFlagsAction action)
@@ -3300,9 +3292,7 @@ index_set_state_flags(Oid indexId, IndexStateFlagsAction action)
Relation pg_index;
HeapTuple indexTuple;
Form_pg_index indexForm;
-- /* Assert that current xact hasn't done any transactional updates */- Assert(GetTopTransactionIdIfAny() == InvalidTransactionId);+ CatalogIndexState indstate;
/* Open pg_index and fetch a writable copy of the index's tuple */
pg_index = heap_open(IndexRelationId, RowExclusiveLock);
@@ -3362,8 +3352,11 @@ index_set_state_flags(Oid indexId, IndexStateFlagsAction action)
break;
}
- /* ... and write it back in-place */- heap_inplace_update(pg_index, indexTuple);+ /* ... and update it */+ indstate = CatalogOpenIndexes(pg_index);+ simple_heap_update(pg_index, &indexTuple->t_self, indexTuple);+ CatalogIndexInsert(indstate, indexTuple);+ CatalogCloseIndexes(indstate);
heap_close(pg_index, RowExclusiveLock);
}
--
2.31.1
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-bugs@postgresql.org
Cc: a.lepikhov@postgrespro.ru, tgl@sss.pgh.pa.us, michael@paquier.xyz, pgsql-bugs@lists.postgresql.org
Subject: Re: Assertion on create index concurrently
In-Reply-To: <a988c2c0-5c6c-27e4-3acb-a4e2bdebd064@postgrespro.ru>
* 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