pgsql: Fix isolationtester race condition for notices sent before block

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix isolationtester race condition for notices sent before block
Date: 2019-07-28 00:22:13
Message-ID: E1hrWx3-0002E6-Se@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix isolationtester race condition for notices sent before blocking.

If a test sends a notice just before blocking, it's possible on
slow machines for isolationtester to detect the blocked state before
it's consumed the notice. (For this to happen, the notice would have
to arrive after isolationtester has waited for data for 10ms, so on
fast/lightly-loaded machines it's hard to reproduce the failure.)
But, if we have seen the backend as blocked, it's certainly already
sent any notices it's going to send. Therefore, one more round of
PQconsumeInput and PQisBusy should be enough to collect and process
any such notices.

This appears to explain the instability noted in commit ebd499282, so undo
the hack therein to not print notices from insert-conflict-specconflict.

Patch by me, diagnosis by Andres Freund.

Discussion: https://postgr.es/m/14616.1564251339@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/30717637c1c58fcd02980a6752c7e13c9de12b69

Modified Files
--------------
.../expected/insert-conflict-specconflict.out | 38 ++++++++++++++++++++++
src/test/isolation/isolationtester.c | 22 +++++++++++++
.../specs/insert-conflict-specconflict.spec | 6 ----
3 files changed, 60 insertions(+), 6 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2019-07-28 07:22:44 pgsql: Fix typo in fd.c
Previous Message Tom Lane 2019-07-27 20:00:03 pgsql: Don't drop NOTICE messages in isolation tests.