From dfb21acb2c362430958505d10bbb79aee5b24007 Mon Sep 17 00:00:00 2001 From: Konstantin Osipov <kostja@tarantool.org> Date: Wed, 29 Jul 2015 21:41:42 +0300 Subject: [PATCH] recovery: restore recovery_atfork() There is still a valid case for fork() after start, it's box.coredump(). The assert that replaced recovery_atfork() call would sporadically fail even in our own test suite. Revert the change. --- src/box/box.cc | 3 ++- src/box/recovery.cc | 12 ++++++++++++ src/box/recovery.h | 6 ++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/box/box.cc b/src/box/box.cc index 6d607c0cd5..35b4143699 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -502,7 +502,8 @@ box_load_cfg() void box_atfork() { - assert(recovery == NULL); + /* box.coredump() forks to save a core. */ + recovery_atfork(recovery); } int diff --git a/src/box/recovery.cc b/src/box/recovery.cc index b64f137427..9843da6631 100644 --- a/src/box/recovery.cc +++ b/src/box/recovery.cc @@ -242,6 +242,18 @@ recovery_exit(struct recovery_state *r) recovery_delete(r); } +void +recovery_atfork(struct recovery_state *r) +{ + xlog_atfork(&r->current_wal); + /* + * Make sure that atexit() handlers in the child do + * not try to stop the non-existent thread. + * The writer is not used in the child. + */ + r->writer = NULL; +} + void recovery_apply_row(struct recovery_state *r, struct xrow_header *row) { diff --git a/src/box/recovery.h b/src/box/recovery.h index f3799447ca..c68f56c88a 100644 --- a/src/box/recovery.h +++ b/src/box/recovery.h @@ -158,6 +158,12 @@ recovery_apply_row(struct recovery_state *r, struct xrow_header *packet); int64_t recovery_last_checkpoint(struct recovery_state *r); +/** + * Ensure we don't corrupt the current WAL file in the child. + */ +void +recovery_atfork(struct recovery_state *r); + #if defined(__cplusplus) } /* extern "C" */ #endif /* defined(__cplusplus) */ -- GitLab