pgsql: Use condition variables to wait for checkpoints.

Started by Thomas Munroover 7 years ago5 messagescomitters
Jump to latest
#1Thomas Munro
thomas.munro@gmail.com

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: /messages/by-id/CA+hUKGLY7sDe+bg1K=bnEzOofGoo4bJHYh9+cDCXJepb6DQmLw@mail.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(-)

#2Thomas Munro
thomas.munro@gmail.com
In reply to: Thomas Munro (#1)
Re: pgsql: Use condition variables to wait for checkpoints.

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

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Thomas Munro (#2)
Re: pgsql: Use condition variables to wait for checkpoints.

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

#4Michael Paquier
michael@paquier.xyz
In reply to: Tom Lane (#3)
Re: pgsql: Use condition variables to wait for checkpoints.

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.patchtext/x-diff; charset=us-asciiDownload+4-0
#5Michael Paquier
michael@paquier.xyz
In reply to: Michael Paquier (#4)
Re: pgsql: Use condition variables to wait for checkpoints.

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