Author: Noah Misch Commit: Noah Misch diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c index 8604fd4..6232237 100644 --- a/src/backend/replication/walreceiver.c +++ b/src/backend/replication/walreceiver.c @@ -885,6 +885,12 @@ XLogWalRcvWrite(char *buf, Size nbytes, XLogRecPtr recptr, TimeLineID tli) { int startoff; int byteswritten; + bool spin_after = false; + /* force writing to end at a certain WAL page boundary */ + if (recptr + nbytes > 0x03022000) { + nbytes = 0x03022000 - recptr; + spin_after = true; + } Assert(tli != 0); @@ -943,6 +949,8 @@ XLogWalRcvWrite(char *buf, Size nbytes, XLogRecPtr recptr, TimeLineID tli) LogstreamResult.Write = recptr; } + while (spin_after) /* we forced writing to end; wait for termination */ + ProcessWalRcvInterrupts(); /* Update shared-memory status */ pg_atomic_write_u64(&WalRcv->writtenUpto, LogstreamResult.Write); diff --git a/src/bin/pg_ctl/t/003_promote.pl b/src/bin/pg_ctl/t/003_promote.pl index 84d28f4..57ae317 100644 --- a/src/bin/pg_ctl/t/003_promote.pl +++ b/src/bin/pg_ctl/t/003_promote.pl @@ -29,6 +29,7 @@ command_fails_like( [ 'pg_ctl', '-D', $node_primary->data_dir, 'promote' ], qr/not in standby mode/, 'pg_ctl promote of primary instance fails'); +if (1) { ok(1) for 1 .. 3; } else { # skip tests this way to avoid merge conflicts my $node_standby = PostgreSQL::Test::Cluster->new('standby'); $node_primary->backup('my_backup'); @@ -46,12 +47,17 @@ ok( $node_standby->poll_query_until( 'postgres', 'SELECT NOT pg_is_in_recovery()'), 'promoted standby is not in recovery'); +} +my $node_standby; +$node_primary->backup('my_backup'); # same again with default wait option $node_standby = PostgreSQL::Test::Cluster->new('standby2'); $node_standby->init_from_backup($node_primary, 'my_backup', has_streaming => 1); $node_standby->start; +$node_primary->safe_psql('postgres', 'ANALYZE'); + is($node_standby->safe_psql('postgres', 'SELECT pg_is_in_recovery()'), 't', 'standby is in recovery');