vac_update_datfrozenxid will raise "wrong tuple length" if pg_database tuple contains toast attribute.
От
Junfeng Yang
Тема
vac_update_datfrozenxid will raise "wrong tuple length" if pg_database tuple contains toast attribute.
Дата
Msg-id
DM5PR0501MB38800D9E4605BCA72DD35557CCE10@DM5PR0501MB3880.namprd05.prod.outlook.com
Список
Дерево обсуждения
vac_update_datfrozenxid will raise "wrong tuple length" if pg_database tuple contains toast attribute. Junfeng Yang <yjerome@vmware.com>
回复: vac_update_datfrozenxid will raise "wrong tuple length" if pg_database tuple contains toast attribute. Junfeng Yang <yjerome@vmware.com>
Re: vac_update_datfrozenxid will raise "wrong tuple length" if pg_database tuple contains toast attribute. Amit Kapila <amit.kapila16@gmail.com>
Re: vac_update_datfrozenxid will raise "wrong tuple length" if pg_database tuple contains toast attribute. Michael Paquier <michael@paquier.xyz>
Re: vac_update_datfrozenxid will raise "wrong tuple length" if pg_database tuple contains toast attribute. Michael Paquier <michael@paquier.xyz>
Re: vac_update_datfrozenxid will raise "wrong tuple length" if pg_database tuple contains toast attribute. Ashwin Agrawal <ashwinstar@gmail.com>
Re: vac_update_datfrozenxid will raise "wrong tuple length" if pg_database tuple contains toast attribute. Michael Paquier <michael@paquier.xyz>
Re: vac_update_datfrozenxid will raise "wrong tuple length" if pg_database tuple contains toast attribute. Arthur Nascimento <tureba@gmail.com>
Re: vac_update_datfrozenxid will raise "wrong tuple length" if pg_database tuple contains toast attribute. Nathan Bossart <nathandbossart@gmail.com>
Re: vac_update_datfrozenxid will raise "wrong tuple length" if pg_database tuple contains toast attribute. Arthur Nascimento <tureba@gmail.com>
Hi hackers,
Recently, we encounter an issue that if the database grant too many roles that `datacl` toasted, vacuum freeze will fail with error "wrong tuple length".
To reproduce the issue, please follow below steps:
CREATE DATABASE vacuum_freeze_test;-- create helper functioncreate or replace function toast_pg_database_datacl() returns text as $body$declaremycounter int;beginfor mycounter in select i from generate_series(1, 2800) i loopexecute 'create role aaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' || mycounter;execute 'grant ALL on database vacuum_freeze_test to aaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' || mycounter;end loop;return 'ok';end;$body$ language plpgsql volatile strict;-- create roles and grant on the databaseselect toast_pg_database_datacl();-- connect to the database\c vacuum_freeze_test-- chech the size of column dataclselect datname, pg_column_size(datacl) as datacl_size, age(datfrozenxid) from pg_database where datname='vacuum_freeze_test';-- execute vacuum freeze and it should raise "wrong tuple length"vacuum freeze;
The root cause is that vac_update_datfrozenxid fetch a copy of pg_database tuple from system cache.
But the system cache flatten any toast attributes, which cause the length chech failed in heap_inplace_update.
A path is attached co auther by Ashwin Agrawal, the solution is to fetch the pg_database tuple from disk instead of system cache if needed.
В списке pgsql-hackers по дате отправления