From: | 勇次 安藤 <antengynnnn536(at)gmail(dot)com> |
---|---|
To: | Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>, Daniel Gustafsson <daniel(at)yesql(dot)se>, "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org> |
Subject: | Re: reltuples kept decreasing with each autovacuum run Re: BUG #18773: オートバキュームのリトライ時にreltuplesの値が減少する |
Date: | 2025-01-21 02:13:05 |
Message-ID: | SEZPR06MB6118DB81A59E53911F45BD5EF4E62@SEZPR06MB6118.apcprd06.prod.outlook.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
ダニエルさん
お世話になっております。
今回の事象はauroraで発生している事象になります。
動きとしてはバグの可能性が高いと考えています。ご確認いただけますと助かります。
必要な資料などあれば連絡ください。
まさおさん
情報のご連携ありがとうございます。同じ事象が再現できたとのことで、
現在のところ対応は、バキュームのリトライが発生した場合に、アナライズを実施する手立てしかない認識で、夜間バッチ時間帯の本番環境で起きていることから、長時間稼働したものがあればれんらくをもらって手動でアナライズを行う手立てしかおこなえず、後手後手になっています・・・オンライン前にすべてのテーブルに対してアナライズを行うことでオンラインへの影響をなくす手立てがあるるかと思うのですが、テーブル数が2000を超えているので、オンライン開始までに終わらせられるかなど検証を進めている状況です・・
よろしくお願いします。
________________________________
From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
Sent: Thursday, January 16, 2025 1:53 AM
To: Daniel Gustafsson <daniel(at)yesql(dot)se>; antengynnnn536(at)gmail(dot)com <antengynnnn536(at)gmail(dot)com>; pgsql-bugs(at)lists(dot)postgresql(dot)org <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: reltuples kept decreasing with each autovacuum run Re: BUG #18773: オートバキュームのリトライ時にreltuplesの値が減少する
On 2025/01/15 22:32, Daniel Gustafsson wrote:
>> On 15 Jan 2025, at 06:59, PG Bug reporting form <noreply(at)postgresql(dot)org> wrote:
>>
>> The following bug has been logged on the website:
>>
>> Bug reference: 18773
>> Logged by: 勇次 安藤
>> Email address: antengynnnn536(at)gmail(dot)com
>> PostgreSQL version: 13.6
>> Operating system: linax
>> Description:
>>
>> 現在、auroraposgres SQLを使用して、オートバキュームを起動して、運用を行っています。
>
> Re-submitting this bugreport in English will greatly improve your chances of
> getting help.
+1
BTW, the reported issue is that when a table contains dead tuples that cannot be
removed due to a long-running transaction, repeated autovacuum runs gradually
decrease the table's reltuples value until it reaches a small number. I also
was able to reproduce this issue on the current HEAD as follows:
Session 1:
=# CREATE TABLE t AS SELECT i FROM generate_series(1, 50000) i;
=# BEGIN;
=# DELETE FROM t WHERE i = 1;
-- (Leave this session open)
Session 2:
=# DELETE FROM t WHERE i > 30000;
=# SELECT relpages, reltuples FROM pg_class WHERE relname = 't';
In my test, reltuples kept decreasing with each autovacuum run, as shown below:
------------
30000
15746
8452
4719
2809
1831
1331
1075
944
877
843
825
816
812
810
808
807
------------
After reltuples drops to 807, running ANALYZE restores the correct count of
live tuples. However, repeated autovacuum runs then cause reltuples to
decrease again.
From my review of the code, this seems related to the logic in vac_estimate_reltuples().
When a table has many unremovable dead tuples, autovacuum scans pages containing
mostly dead tuples and finds only a small number of live tuples. These few live
tuples are counted toward reltuples, but this small count is indirectly used to
calculate subsequent reltuples values. This feedback loop causes reltuples to
continually decrease in such scenarios.
I'm not sure if this is a bug, and I currently don't have a good solution
for the issue.
Regards,
--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION
From | Date | Subject | |
---|---|---|---|
Next Message | 谭忠涛 | 2025-01-21 02:30:24 | Performance Issue when using gin index |
Previous Message | Viktor Remennik | 2025-01-20 21:29:44 | Re: BUG #18780: Bindings types are lost for complex queries |