1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-10 17:42:29 +03:00

Now that START_REPLICATION returns the next timeline's ID after reaching end

of timeline, take advantage of that in walreceiver.

Startup process is still in control of choosign the target timeline, by
scanning the timeline history files present in pg_xlog, but walreceiver now
uses the next timeline's ID to fetch its history file immediately after it
has finished streaming the old timeline. Before, the standby would first try
to restart streaming on the old timeline, which fetches the missing timeline
history file as a side-effect, and only then restart from the new timeline.
This patch eliminates the extra iteration, which speeds up the timeline
switch and reduces the noise in the log caused by the extra restart on the
old timeline.
This commit is contained in:
Heikki Linnakangas
2013-01-18 11:48:29 +02:00
parent 2ff6555313
commit 6f7cddc7ae
3 changed files with 46 additions and 29 deletions

View File

@@ -505,8 +505,15 @@ WalReceiverMain(void)
* our side, too.
*/
EnableWalRcvImmediateExit();
walrcv_endstreaming();
walrcv_endstreaming(&primaryTLI);
DisableWalRcvImmediateExit();
/*
* If the server had switched to a new timeline that we didn't know
* about when we began streaming, fetch its timeline history file
* now.
*/
WalRcvFetchTimeLineHistoryFiles(startpointTLI, primaryTLI);
}
else
ereport(LOG,