Re: Refactor pg_rewind code and make it work against a standby
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Soumyadeep Chakraborty <soumyadeep2007@gmail.com>, Kyotaro Horiguchi <horikyota.ntt@gmail.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2020-11-20T00:38:11Z
Lists: pgsql-hackers
Hi,
On 2020-11-15 17:10:53 +0200, Heikki Linnakangas wrote:
> Yep, quite right. Fixed that way, thanks for the debugging!
I locally, on a heavily modified branch (AIO support), started to get
consistent failures in this test. I *suspect*, but am not sure, that
it's the test's fault, not the fault of modifications.
As far as I can tell, after the pg_rewind call, there's no guarantee
that node_c has fully caught up to the 'in A, after C was promoted'
insertion on node a. Thus at the check_query() I sometimes get just 'in
A, before promotion' back.
After adding a wait that problem seems to be fixed. Here's what I did
diff --git i/src/bin/pg_rewind/t/007_standby_source.pl w/src/bin/pg_rewind/t/007_standby_source.pl
index f6abcc2d987..48898bef2f5 100644
--- i/src/bin/pg_rewind/t/007_standby_source.pl
+++ w/src/bin/pg_rewind/t/007_standby_source.pl
@@ -88,6 +88,7 @@ $node_c->safe_psql('postgres', "checkpoint");
# - you need to rewind.
$node_a->safe_psql('postgres',
"INSERT INTO tbl1 VALUES ('in A, after C was promoted')");
+$lsn = $node_a->lsn('insert');
# Also insert a new row in the standby, which won't be present in the
# old primary.
@@ -142,6 +143,8 @@ $node_primary = $node_c;
# Run some checks to verify that C has been successfully rewound,
# and connected back to follow B.
+$node_b->wait_for_catchup('node_c', 'replay', $lsn);
+
check_query(
'SELECT * FROM tbl1',
qq(in A
- Andres
Commits
-
Make pg_rewind test case more stable.
- c71f9a094b32 14.0 landed
-
Fix timing issue in pg_rewind test.
- 39f9f04b5784 14.0 landed
-
Allow pg_rewind to use a standby server as the source system.
- 9c4f5192f69e 14.0 landed
-
pg_rewind: Refactor the abstraction to fetch from local/libpq source.
- 37d2ff380312 14.0 landed
-
pg_rewind: Replace the hybrid list+array data structure with simplehash.
- f81e97d0475c 14.0 landed
-
Refactor pg_rewind for more clear decision making.
- eb00f1d4bf96 14.0 landed
-
pg_rewind: Move syncTargetDirectory() to file_ops.c
- ffb4e27e9c5e 14.0 landed