Internal error while setting reloption on system catalogs.

From: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Internal error while setting reloption on system catalogs.
Date: 2019-02-05 11:58:37
Message-ID: 20190205.205837.52833927.horiguchi.kyotaro@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello.

The following command complains with an internal
error. (allow_system_table_mods is on).

alter table pg_attribute set (fillfactor = 90);
> ERROR: AccessExclusiveLock required to add toast table.

The same happens for pg_class. This is because ATRewriteCatalogs
tries to add a toast table to the relations with taking
ShareUpdateExclusiveLock. The decision whether to provide a toast
table for each system catalog is taken in the commit 96cdeae07f
that the two relations won't have a toast relation, so we should
avoid that for all mapped relations.

I didn't find a place where ATTACH PARTITION sends
RELKIND_PARTITIONED_TABLE to the function so the case is omitted
in the patch. Actually the regression test doesn't complain with
the following assertion there in the function.

> Assert(tab->relkind != RELKIND_PARTITIONED_TABLE ||
> tab->partition_constraint == NULL ||
> !tab->check_toast)

Many other commands seem not to need the toast check but the
patch doesn't care about them. It would be another issue.

According to alter_table.sql, it doesn't need a test.

-- XXX: It would be useful to add checks around trying to manipulate
-- catalog tables, but that might have ugly consequences when run
-- against an existing server with allow_system_table_mods = on.

The first attached is for master and 11.
The second is for 10.
The third is for 9.6.

9.4 and 9.5 doesn't suffer the problem but it is because they
create toast table for mapped relations at that time.

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

Attachment Content-Type Size
allow_alter_table_on_system_catalog_master.patch text/x-patch 2.3 KB
allow_alter_table_on_system_catalog_pg10.patch text/x-patch 2.2 KB
allow_alter_table_on_system_catalog_pg96.patch text/x-patch 1.4 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kyotaro HORIGUCHI 2019-02-05 12:30:24 Re: What happens if checkpoint haven't completed until the next checkpoint interval or max_wal_size?
Previous Message Michael Paquier 2019-02-05 11:42:59 Re: What happens if checkpoint haven't completed until the next checkpoint interval or max_wal_size?