Re: Stabilize recovery conflict stats checks in 031_recovery_conflict.pl

Поиск
Список
Период
Сортировка
Искать

Re: Stabilize recovery conflict stats checks in 031_recovery_conflict.pl

От:
Fujii Masao <masao.fujii@gmail.com>
Дата:
On Wed, Sep 2, 2026 at 5:57 PM Nazir Bilal Yavuz  wrote:
> I confirm that your patch fixes the problem and LGTM.

Thanks Ayush and Nazir, for the test and review! I've pushed the patch.


> I attached a patch for fixing this problem by using poll_query_until()
> like you did. I am not sure if 'test_custom_stats/001_custom_stats' is
> the real problem since you need quite a big sleep time to reproduce
> it, but I wanted to mention it just in case.

As you mentioned, this doesn't seem to be causing any actual buildfarm or
CI failures at the moment. So I'm inclined to leave things as they are
and not apply the patch....

Of course, if many others think it's better to apply it proactively,
I'm ok with that, though.

Regards,

-- 
Fujii Masao


Re: Stabilize recovery conflict stats checks in 031_recovery_conflict.pl

От:
Fujii Masao <masao.fujii@gmail.com>
Дата:
On Fri, Sep 4, 2026 at 6:48 AM Ayush Tiwari  wrote:
> Thoughts?

Thanks for the patches! They look good to me.

> Although split for review, I think both patches should be
> applied together.

+1

> Backpatch-through: 17

Is this because the test exists in v15 and v16 but is skipped there?

Regards,

-- 
Fujii Masao


Re: Stabilize recovery conflict stats checks in 031_recovery_conflict.pl

От:
Alexander Lakhin <exclusion@gmail.com>
Дата:
Вложения:
04.09.2026 19:00, Alexander Lakhin wrote:
> Yes, I've tested both on my side -- no single run (of thousands) failed.
> Also checked with LLM all the failures of 031_recovery_conflict registered
> on wiki -- they all should be ruled out now.

Having tried a bit harder (running the test on a relatively slow riscv64
device), I've discovered one more instability. It can be reproduced
reliably on an ordinary machine with:
/tmp/temp.config
autovacuum_naptime = 1
autovacuum_analyze_threshold = 1

--- a/src/backend/commands/analyze.c
+++ b/src/backend/commands/analyze.c
@@ -132,4 +132,5 @@ analyze_rel(Oid relid, RangeVar *relation,
      CHECK_FOR_INTERRUPTS();

+if (AmAutoVacuumWorkerProcess()) pg_usleep(1000000);
      /*
       * Open the relation, getting ShareUpdateExclusiveLock to ensure that two
--- a/src/test/recovery/t/031_recovery_conflict.pl
+++ b/src/test/recovery/t/031_recovery_conflict.pl
@@ -132,4 +132,5 @@ $node_primary->safe_psql($test_db,
  $node_primary->wait_for_replay_catchup($node_standby);

+sleep(1);
  # DECLARE and FETCH from cursor on the standby
  $res = $psql_standby->query_safe(

TEMP_CONFIG=/tmp/temp.config make -s check -C src/test/recovery PROVE_TESTS="t/031*"
t/031_recovery_conflict.pl .. 4/? # die: timed out waiting for file 
.../src/test/recovery/tmp_check/log/031_recovery_conflict_standby.log contents to match: (?^:User query might have 
needed to see row versions that must be removed) at t/031_recovery_conflict.pl line 324.
# Looks like your test exited with 255 just after 4.
t/031_recovery_conflict.pl .. Dubious, test returned 255 (wstat 65280, 0xff00)
All 4 subtests passed

Test Summary Report
-------------------
t/031_recovery_conflict.pl (Wstat: 65280 (exited 255) Tests: 4 Failed: 0)
   Non-zero exit status: 255
Files=1, Tests=4, 183 wallclock secs ( 0.00 usr  0.00 sys +  0.17 cusr  0.24 csys =  0.41 CPU)

(Originally, the test failed for me without extra autovacuum-related
settings and sleeps.)

Best regards,
Alexander


Re: Stabilize recovery conflict stats checks in 031_recovery_conflict.pl

От:
Fujii Masao <masao.fujii@gmail.com>
Дата:
On Mon, Sep 7, 2026 at 1:34 AM Ayush Tiwari  wrote:
> Hmm, I think we can just disable the autovacuum completely.
>
> I revised 0002 to disable autovacuum for the test node instead.  With your
> reproducer, the revised patch passes all 18 tests.  The regular test passes
> as well.
>
> Thoughts?

LGTM. So barring any objections, I will commit the patches.

Regards,

-- 
Fujii Masao


Re: Stabilize recovery conflict stats checks in 031_recovery_conflict.pl

От:
Alexander Lakhin <exclusion@gmail.com>
Дата:
Hello Fujii-san,

16.09.2026 13:30, Fujii Masao wrote:
On Mon, Sep 7, 2026 at 1:34 AM Ayush Tiwari <ayushtiwari.slg01@gmail.com> wrote:
Hmm, I think we can just disable the autovacuum completely.

I revised 0002 to disable autovacuum for the test node instead.  With your
reproducer, the revised patch passes all 18 tests.  The regular test passes
as well.

Thoughts?
LGTM. So barring any objections, I will commit the patches.

It looks like skink asks for the fix, e.g. as below [3]:
 69/325 recovery - postgresql:recovery/031_recovery_conflict                            ERROR           1013.92s   (exit status 255 or 0xff)

[11:14:59.084](0.080s) ok 14 - startup deadlock: lock acquisition is waiting
Waiting for replication conn standby's replay_lsn to pass 0/3461410 on primary
done
timed out waiting for match: (?^:User transaction caused buffer deadlock with recovery.) at /home/bf/bf-build/skink/REL_17_STABLE/pgsql/src/test/recovery/t/031_recovery_conflict.pl line 318.

This is a new failure mode, but it's still caused by autovacuum, as far as
I can see.

I've reproduced this locally when running 20 tests in parallel, in a VM
with 10% CPU limit.
16      [10:21:35] t/031_recovery_conflict.pl ..
16      Dubious, test returned 255 (wstat 65280, 0xff00)
16      All 14 subtests passed
16      [10:21:35]
16
16      Test Summary Report
16      -------------------
16      t/031_recovery_conflict.pl (Wstat: 65280 (exited 255) Tests: 14 Failed: 0)
16        Non-zero exit status: 255
16        Parse errors: No plan found in TAP output
16      Files=1, Tests=14, 510 wallclock secs ( 0.06 usr  0.05 sys +  2.28 cusr 18.31 csys = 20.70 CPU)
16      Result: FAIL
16      # Tests were run but no plan was declared and done_testing() was not seen.
16      # Looks like your test exited with 255 just after 14.
16      make: *** [Makefile:28: check] Error 1

With  log_autovacuum_min_duration = 0:
/031_recovery_conflict_primary.log:
2026-10-01 10:17:23.078 UTC [193321][client backend][4/8:0] LOG:  statement: BEGIN;
2026-10-01 10:17:23.255 UTC [193321][client backend][4/8:0] LOG:  statement: INSERT INTO test_recovery_conflict_table1(a) SELECT generate_series(1, 100) i;
2026-10-01 10:17:23.364 UTC [193321][client backend][4/8:767] LOG:  statement: ROLLBACK;
...
2026-10-01 10:17:27.804 UTC [193405][autovacuum worker][11/7:0] LOG:  automatic vacuum of table "test_db.public.test_recovery_conflict_table1": index scans: 0
        pages: 0 removed, 1 remain, 1 scanned (100.00% of total), 0 eagerly scanned
        tuples: 100 removed, 2 remain, 0 are dead but not yet removable
...
2026-10-01 10:17:33.901 UTC [193477][client backend][7/5:0] LOG:  connection authorized: user=vagrant database=test_db application_name=031_recovery_conflict.pl
2026-10-01 10:17:36.171 UTC [193477][client backend][7/6:0] LOG:  statement: VACUUM FREEZE test_recovery_conflict_table1;
2026-10-01 10:17:36.996 UTC [193477][client backend][:0] LOG:  disconnection: session time: 0:00:03.096 user=vagrant database=test_db host=[local]
...

As a result, there is no "WAL redo at X/XXXX for Heap2/PRUNE_VACUUM_SCAN"
after 10:17:36 and "User transaction caused buffer deadlock with recovery"
in 031_recovery_conflict_standby.log.

[1] https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=skink&dt=2026-09-28%2023%3A37%3A34
[2] https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=skink&dt=2026-09-29%2010%3A39%3A34
[3] https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=skink&dt=2026-09-30%2008%3A38%3A16


Best regards,
Alexander

Re: Stabilize recovery conflict stats checks in 031_recovery_conflict.pl

От:
Fujii Masao <masao.fujii@gmail.com>
Дата:
On Wed, Sep 16, 2026 at 7:30 PM Fujii Masao  wrote:
> LGTM. So barring any objections, I will commit the patches.

I've pushed the patches. Thanks!

Let's keep monitoring to see whether similar recovery test failures occur again.

Regards,

-- 
Fujii Masao


FAQ