]> granicus.if.org Git - postgresql/commit
Fix handling of files that source server removes during pg_rewind is running.
authorFujii Masao <fujii@postgresql.org>
Wed, 28 Mar 2018 19:00:21 +0000 (04:00 +0900)
committerFujii Masao <fujii@postgresql.org>
Wed, 28 Mar 2018 19:01:43 +0000 (04:01 +0900)
commitf1e07d576318910738566abac2b4a57e891cb876
treeb770d37c47fcd429302461ecd95b6a9cfaf1ae0d
parentc98f218fbf5aeb8accb192a0222de26b67f4cff5
Fix handling of files that source server removes during pg_rewind is running.

After processing the filemap to build the list of chunks that will be
fetched from the source to rewing the target server, it is possible that
a file which was previously processed is removed from the source.  A
simple example of such an occurence is a WAL segment which gets recycled
on the target in-between.  When the filemap is processed, files not
categorized as relation files are first truncated to prepare for its
full copy of which is going to be taken from the source, divided into a
set of junks.  However, for a recycled WAL segment, this would result in
a segment which has a zero-byte size.  With such an empty file,
post-rewind recovery thinks that records are saved but they are actually
not because of the truncation which happened when processing the
filemap, resulting in data loss.

In order to fix the problem, make sure that files which are found as
removed on the source when receiving chunks of them are as well deleted
on the target server for consistency.

Back-patch to 9.5 where pg_rewind was added.

Author: Tsunakawa Takayuki
Reviewed-by: Michael Paquier
Reported-by: Tsunakawa Takayuki
Discussion: https://postgr.es/m/0A3221C70F24FB45833433255569204D1F8DAAA2%40G01JPEXMBYT05
src/bin/pg_rewind/file_ops.c
src/bin/pg_rewind/file_ops.h
src/bin/pg_rewind/libpq_fetch.c