summaryrefslogtreecommitdiff
path: root/src/bin/pg_rewind/file_ops.h
diff options
context:
space:
mode:
authorFujii Masao <fujii@postgresql.org>2018-03-29 04:00:21 +0900
committerFujii Masao <fujii@postgresql.org>2018-03-29 04:00:21 +0900
commit09e96b3f35627a2939e2effd8b98aaa934f59b32 (patch)
treeec89a7332b25c611ca11e7e50d6ea818f8163afb /src/bin/pg_rewind/file_ops.h
parentd92bc83c48bdea9888e64cf1e2edbac9693099c9 (diff)
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
Diffstat (limited to 'src/bin/pg_rewind/file_ops.h')
-rw-r--r--src/bin/pg_rewind/file_ops.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/bin/pg_rewind/file_ops.h b/src/bin/pg_rewind/file_ops.h
index be580ee4db5..9d26cf4f774 100644
--- a/src/bin/pg_rewind/file_ops.h
+++ b/src/bin/pg_rewind/file_ops.h
@@ -15,6 +15,7 @@
extern void open_target_file(const char *path, bool trunc);
extern void write_target_range(char *buf, off_t begin, size_t size);
extern void close_target_file(void);
+extern void remove_target_file(const char *path, bool missing_ok);
extern void truncate_target_file(const char *path, off_t newsize);
extern void create_target(file_entry_t *t);
extern void remove_target(file_entry_t *t);