'ERROR: attempted to update invisible tuple' from 'ALTER INDEX ... ATTACH PARTITION' on parent index

Поиск
Список
Период
Сортировка
От Shruthi Gowda
Тема 'ERROR: attempted to update invisible tuple' from 'ALTER INDEX ... ATTACH PARTITION' on parent index
Дата
Msg-id CAASxf_PBcxax0wW-3gErUyftZ0XrCs3Lrpuhq4-Z3Fak1DoW7Q@mail.gmail.com
обсуждение исходный текст
Ответы Re: 'ERROR: attempted to update invisible tuple' from 'ALTER INDEX ... ATTACH PARTITION' on parent index  (Michael Paquier <michael@paquier.xyz>)
Re: 'ERROR: attempted to update invisible tuple' from 'ALTER INDEX ... ATTACH PARTITION' on parent index  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-hackers
Hi,
While testing some use cases, I encountered 'ERROR:  attempted to update invisible tuple' when a partitioned index is attached to a parent index which is also a replica identity index.
Below is the reproducible test case. The issue is seen only when the commands are executed inside a transaction.

BEGIN;
CREATE TABLE foo (  id INT NOT NULL,  ts TIMESTAMP WITH TIME ZONE NOT NULL
) PARTITION BY RANGE (ts);

CREATE TABLE foo_2023 (  id INT NOT NULL,  ts TIMESTAMP WITH TIME ZONE NOT NULL
);

ALTER TABLE ONLY foo   ATTACH PARTITION foo_2023   FOR VALUES FROM ('2023-01-01 00:00:00+09') TO ('2024-01-01 00:00:00+09');

CREATE UNIQUE INDEX pk_foo  ON ONLY foo USING btree (id, ts);

ALTER TABLE ONLY foo REPLICA IDENTITY USING INDEX pk_foo;

CREATE UNIQUE INDEX foo_2023_id_ts_ix ON foo_2023 USING btree (id, ts);

ALTER INDEX pk_foo ATTACH PARTITION foo_2023_id_ts_ix;

The 'ALTER INDEX pk_foo ATTACH PARTITION foo_2023_id_ts_ix' returns "ERROR:  attempted to update invisible tuple"
Below are few observations from debugging:
image.png
image.png
The error is seen in validatePartitionedIndex() while validating the partition.
This function marks the parent index as VALID if it found as many inherited indexes as the partitioned table has partitions.
The pg_index tuple is fetched from partedIdx->rd_indextuple.Iit looks like the index tuple is not refreshed. 
The 'indisreplident' is false, the ctid field value is old and it does not reflect the ctid changes made by  'ALTER TABLE ONLY foo REPLICA IDENTITY USING INDEX pk_foo'.
Any suggestions  ?

Regards,
Shruthi KC
EnterpriseDB: http://www.enterprisedb.com
Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Ahmed Ibrahim
Дата:
Сообщение: Issue in _bt_getrootheight
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: cataloguing NOT NULL constraints