pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Use condition variables to wait for checkpoints.
5+ messages / 4 participants
[nested] [flat]

Commits from this thread:
  2019-03-14 364298be22  Fix race condition in recently-added TAP test for recovery consistency
* pgsql: Use condition variables to wait for checkpoints.
@ 2019-03-13 22:02 Thomas Munro <tmunro@postgresql.org>
  2019-03-13 23:02 ` Re: pgsql: Use condition variables to wait for checkpoints. Thomas Munro <thomas.munro@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Thomas Munro @ 2019-03-13 22:02 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Use condition variables to wait for checkpoints.

Previously we used a polling/sleeping loop to wait for checkpoints
to begin and end, which leads to up to a couple hundred milliseconds
of needless thumb-twiddling.  Use condition variables instead.

Author: Thomas Munro
Reviewed-by: Andres Freund
Discussion: https://postgr.es/m/CA%2BhUKGLY7sDe%2Bbg1K%3DbnEzOofGoo4bJHYh9%2BcDCXJepb6DQmLw%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/c6c9474aafa4de357ae424cd18b69e8bf7a4babe

Modified Files
--------------
doc/src/sgml/monitoring.sgml          | 10 +++++++++-
src/backend/postmaster/checkpointer.c | 21 +++++++++++++++++----
src/backend/postmaster/pgstat.c       |  6 ++++++
src/include/pgstat.h                  |  2 ++
4 files changed, 34 insertions(+), 5 deletions(-)



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: pgsql: Use condition variables to wait for checkpoints.
  2019-03-13 22:02 pgsql: Use condition variables to wait for checkpoints. Thomas Munro <tmunro@postgresql.org>
@ 2019-03-13 23:02 ` Thomas Munro <thomas.munro@gmail.com>
  2019-03-13 23:25   ` Re: pgsql: Use condition variables to wait for checkpoints. Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 5+ messages in thread

From: Thomas Munro @ 2019-03-13 23:02 UTC (permalink / raw)
  To: Thomas Munro <tmunro@postgresql.org>; +Cc: pgsql-committers@lists.postgresql.org

On Thu, Mar 14, 2019 at 11:02 AM Thomas Munro <tmunro@postgresql.org> wrote:
> Use condition variables to wait for checkpoints.

BF animal "loach" is blaming a recoveryCheck failure in
016_min_conistency on this commit.  I wonder if there some timing
dependency in that new test that broke when CHECKPOINT became faster.

-- 
Thomas Munro
https://enterprisedb.com




^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: pgsql: Use condition variables to wait for checkpoints.
  2019-03-13 22:02 pgsql: Use condition variables to wait for checkpoints. Thomas Munro <tmunro@postgresql.org>
  2019-03-13 23:02 ` Re: pgsql: Use condition variables to wait for checkpoints. Thomas Munro <thomas.munro@gmail.com>
@ 2019-03-13 23:25   ` Tom Lane <tgl@sss.pgh.pa.us>
  2019-03-14 00:33     ` Re: pgsql: Use condition variables to wait for checkpoints. Michael Paquier <michael@paquier.xyz>
  0 siblings, 1 reply; 5+ messages in thread

From: Tom Lane @ 2019-03-13 23:25 UTC (permalink / raw)
  To: Thomas Munro <thomas.munro@gmail.com>; +Cc: Michael Paquier <michael@paquier.xyz>; pgsql-committers@lists.postgresql.org

Thomas Munro <thomas.munro@gmail.com> writes:
> On Thu, Mar 14, 2019 at 11:02 AM Thomas Munro <tmunro@postgresql.org> wrote:
>> Use condition variables to wait for checkpoints.

> BF animal "loach" is blaming a recoveryCheck failure in
> 016_min_conistency on this commit.  I wonder if there some timing
> dependency in that new test that broke when CHECKPOINT became faster.

Uh, yeah, I'd say it's pretty obvious: the failure is

error running SQL: 'psql:<stdin>:1: ERROR:  relation "test1" does not exist
LINE 1: SELECT count(*) FROM test1;
                             ^'
while running 'psql -XAtq -d port=57404 host=/tmp/8ItZDq6QmQ dbname='postgres' -f - -v ON_ERROR_STOP=1' with sql 'SELECT count(*) FROM test1;' at /usr/home/pgbf/buildroot/HEAD/pgsql.build/src/test/recovery/../../../src/test/perl/PostgresNode.pm line 1331.

and if you look at the test script, there is no sort of wait for the
creation of "test1" to propagate to the slave before we try to query
it on the slave.  We'd have seen this fall over soon enough with or
without your commit.

			regards, tom lane




^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: pgsql: Use condition variables to wait for checkpoints.
  2019-03-13 22:02 pgsql: Use condition variables to wait for checkpoints. Thomas Munro <tmunro@postgresql.org>
  2019-03-13 23:02 ` Re: pgsql: Use condition variables to wait for checkpoints. Thomas Munro <thomas.munro@gmail.com>
  2019-03-13 23:25   ` Re: pgsql: Use condition variables to wait for checkpoints. Tom Lane <tgl@sss.pgh.pa.us>
@ 2019-03-14 00:33     ` Michael Paquier <michael@paquier.xyz>
  2019-03-14 03:51       ` Re: pgsql: Use condition variables to wait for checkpoints. Michael Paquier <michael@paquier.xyz>
  0 siblings, 1 reply; 5+ messages in thread

From: Michael Paquier @ 2019-03-14 00:33 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Thomas Munro <thomas.munro@gmail.com>; pgsql-committers@lists.postgresql.org

On Wed, Mar 13, 2019 at 07:25:37PM -0400, Tom Lane wrote:
> and if you look at the test script, there is no sort of wait for the
> creation of "test1" to propagate to the slave before we try to query
> it on the slave.  We'd have seen this fall over soon enough with or
> without your commit.

Oops, sorry.  I was monitoring the buildfarm yesterday and did not
notice any failures.  The attached should fix the problem.  Does that
look fine?
--
Michael

Attachments:

recoveryminlsn-tap-fix.patch (text/x-diff, 704B) download diff --git a/src/test/recovery/t/016_min_consistency.pl b/src/test/recovery/t/016_min_consistency.pl index 8f1a89c2d3..90a270650d 100644 --- a/src/test/recovery/t/016_min_consistency.pl +++ b/src/test/recovery/t/016_min_consistency.pl @@ -97,6 +97,10 @@ INSERT INTO test1 SELECT generate_series(1, 10000);"); $primary->safe_psql('postgres', 'CHECKPOINT;'); $primary->safe_psql('postgres', 'UPDATE test1 SET a = a + 1;'); +# Wait for table creation to happen on the standby. +$primary->wait_for_catchup($standby, 'replay', + $primary->lsn('insert')); + # Fill in the standby's shared buffers with the data filled in # previously. $standby->safe_psql('postgres', 'SELECT count(*) FROM test1;');
signature.asc (application/pgp-signature, 832B) download ^ permalink raw reply [nested|flat] 5+ messages in thread

* Re: pgsql: Use condition variables to wait for checkpoints.
  2019-03-13 22:02 pgsql: Use condition variables to wait for checkpoints. Thomas Munro <tmunro@postgresql.org>
  2019-03-13 23:02 ` Re: pgsql: Use condition variables to wait for checkpoints. Thomas Munro <thomas.munro@gmail.com>
  2019-03-13 23:25   ` Re: pgsql: Use condition variables to wait for checkpoints. Tom Lane <tgl@sss.pgh.pa.us>
  2019-03-14 00:33     ` Re: pgsql: Use condition variables to wait for checkpoints. Michael Paquier <michael@paquier.xyz>
@ 2019-03-14 03:51       ` Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 5+ messages in thread

From: Michael Paquier @ 2019-03-14 03:51 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Thomas Munro <thomas.munro@gmail.com>; pgsql-committers@lists.postgresql.org

On Thu, Mar 14, 2019 at 09:33:42AM +0900, Michael Paquier wrote:
> Oops, sorry.  I was monitoring the buildfarm yesterday and did not
> notice any failures.  The attached should fix the problem.  Does that
> look fine?

loach has just turned red again, so I have committed this fix to cool
it down.
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2019-03-14 03:51 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-03-13 22:02 pgsql: Use condition variables to wait for checkpoints. Thomas Munro <tmunro@postgresql.org>
2019-03-13 23:02 ` Thomas Munro <thomas.munro@gmail.com>
2019-03-13 23:25   ` Tom Lane <tgl@sss.pgh.pa.us>
2019-03-14 00:33     ` Michael Paquier <michael@paquier.xyz>
2019-03-14 03:51       ` Michael Paquier <michael@paquier.xyz>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox