diff --git a/src/box/box.cc b/src/box/box.cc index 6d607c0cd5b28d11d4924c485148d8116b903884..35b4143699987e12584a6f901cbe7d72f3233129 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 b64f13742718b2d12564292ff2fd1cbdc9909013..9843da6631f01549b3b720b802c9f1c282be5588 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 f3799447ca92b17d996837b4aa12f5064f990ca2..c68f56c88a8c93cb6d4699a38c990c35fce6f938 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) */