Re: Possible fails in pg_stat_statements test - Mailing list pgsql-hackers

From Anton A. Melnikov
Subject Re: Possible fails in pg_stat_statements test
Date
Msg-id 790a395a-2487-3119-3c99-01fc051fccb7@inbox.ru
Whole thread Raw
In response to Re: Possible fails in pg_stat_statements test  (Andres Freund <andres@anarazel.de>)
Responses Re: Possible fails in pg_stat_statements test  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
Hello,

thank you much for your attention and for your thought.

On 20.03.2022 20:36, Andres Freund wrote:
>> This patch introduces an additional counter of wal records not related to
>> the query being executed.
> 
> They're not unrelated though.

Yes, i've missformulated here.
Indeed there is a relation but it seems of the some other kind.
It would be nice to clarify the terminology.
Maybe divide WAL records into two kinds:
1) WAL records, the number of which depends on the given query itself. 
(say strong relation)
2) WAL records, the number of which depends on the given query and on 
the previous query history. (say weak relation)

So  modified in the patch wal_records counter will belongs to the first 
kind while the number of wal records due to on-access pruning and new 
clog page generation to the second.

> -many. For read-only queries the generated WAL due to on-access pruning can be
> a significant factor in performance. Removing that information makes
> pg_stat_statments *less* useful.

A separate counter for the second type of records, say, 
extra_wal_records, will not only remove this disadvantage, but on the 
contrary will provide additional information.

The next version of the patch with additional counter is attached.

Really, now it is clearly seen that sometimes
> WAL due to on-access pruning can be a significant factor !
After  pgbench -c10 -t300:
postgres=# SELECT substring(query for 30), wal_records, 
extra_wal_records FROM pg_stat_statements WHERE extra_wal_records != 0;

            substring            | wal_records | extra_wal_records
--------------------------------+-------------+-------------------
  UPDATE pgbench_tellers SET tba |        4557 |                15
  create table pgbench_history(t |          48 |                 1
  create table pgbench_branches( |          40 |                 1
  UPDATE pgbench_accounts SET ab |        5868 |              1567
  drop table if exists pgbench_a |          94 |                 1
  UPDATE pgbench_branches SET bb |        5993 |                14
  SELECT abalance FROM pgbench_a |           0 |                 7
(7 rows)

> Can the test failures be encountered without such an elaborate setup? If not,
> then I don't really see why we need to do anything here?

There was a real bug report from our test department. They do long time 
repetitive tests and sometimes met this failure.
So i suppose there is a non-zero probability that such error can occur 
in the one-shot test as well.
The sequence given in the first letter helps to catch this failure quickly.

With best regards,

-- 
Anton A. Melnikov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
Attachment

pgsql-hackers by date:

Previous
From: Justin Pryzby
Date:
Subject: Re: Removing more vacuumlazy.c special cases, relfrozenxid optimizations
Next
From: Michael Paquier
Date:
Subject: Re: Add LZ4 compression in pg_dump