pgsql: Use condition variables to wait for checkpoints.
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(-)
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
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
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
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