The following patch has been independently verified as fixing bug 4137.
The problem was that at the very start of archive recovery the %r
parameter in restore_command could be set to a filename later than the
currently requested filename (%f). This could lead to early truncation
of the archived WAL files and would cause warm standby replication to
fail soon afterwards, in certain specific circumstances.
Fix applied to both core server in generating correct %r filenames and
also to pg_standby to prevent acceptance of out-of-sequence filenames.
Request review and commit. No port specific details.
--
Simon Riggs
2ndQuadrant http://www.2ndQuadrant.com