diff --git a/src/box/applier.cc b/src/box/applier.cc index e18c34f01407bdd0c9ab092467a3c55a39276adc..fecdb7d79a879e9baeccd3224b1910475d01b290 100644 --- a/src/box/applier.cc +++ b/src/box/applier.cc @@ -39,6 +39,7 @@ #include "coio_buf.h" #include "xstream.h" #include "recovery.h" +#include "wal.h" #include "xrow.h" #include "box/cluster.h" #include "iproto_constants.h" diff --git a/src/box/box.cc b/src/box/box.cc index 6be2207c39c3d72d760603af269941c09c185ad9..411b94122b0a1242edade2c6eadc52c3cb8b9bfd 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -35,6 +35,7 @@ #include "iproto.h" #include "iproto_constants.h" #include "recovery.h" +#include "wal.h" #include "relay.h" #include "applier.h" #include <rmean.h> @@ -1175,6 +1176,8 @@ box_free(void) if (recovery) { recovery_exit(recovery); recovery = NULL; + if (wal) + wal_writer_stop(); } /* * See gh-584 "box_free() is called even if box is not @@ -1385,6 +1388,8 @@ box_init(void) port_init(); iproto_init(); box_set_listen(); + recovery_finalize(recovery, &wal_stream.base); + box_sync_replication_source(); } else { /* TODO: don't create recovery for this case */ @@ -1407,8 +1412,10 @@ box_init(void) int64_t rows_per_wal = box_check_rows_per_wal(cfg_geti64("rows_per_wal")); enum wal_mode wal_mode = box_check_wal_mode(cfg_gets("wal_mode")); - recovery_finalize(recovery, &wal_stream.base, wal_mode, rows_per_wal); - + if (wal_mode != WAL_NONE) { + wal_writer_start(wal_mode, cfg_gets("wal_dir"), &SERVER_UUID, + &recovery->vclock, rows_per_wal); + } engine_end_recovery(); rmean_cleanup(rmean_box); diff --git a/src/box/cluster.cc b/src/box/cluster.cc index a83e330ac71350c65146d77a41a9002598b5f8d2..e7fc0455d9b3e8e873e1a5c9f52411fb63ef7812 100644 --- a/src/box/cluster.cc +++ b/src/box/cluster.cc @@ -38,6 +38,7 @@ #include "box.h" #include "recovery.h" +#include "wal.h" #include "applier.h" /** diff --git a/src/box/recovery.cc b/src/box/recovery.cc index f5faba506f29df466c77498da5f7cd663f18d4c0..46a94bf38f3dfad6c226149409e52821e9df8066 100644 --- a/src/box/recovery.cc +++ b/src/box/recovery.cc @@ -36,7 +36,7 @@ #include "xlog.h" #include "xrow.h" #include "xstream.h" - +#include "wal.h" /* wal_watcher */ #include "cluster.h" #include "session.h" @@ -198,8 +198,6 @@ recovery_exit(struct recovery *r) /* Avoid fibers, there is no event loop */ r->watcher = NULL; recovery_delete(r); - if (wal) - wal_writer_stop(); } /** @@ -363,8 +361,7 @@ recover_remaining_wals(struct recovery *r, struct xstream *stream, } void -recovery_finalize(struct recovery *r, struct xstream *stream, - enum wal_mode wal_mode, int64_t rows_per_wal) +recovery_finalize(struct recovery *r, struct xstream *stream) { recovery_stop_local(r); @@ -384,10 +381,6 @@ recovery_finalize(struct recovery *r, struct xstream *stream, */ vclock_inc(&r->vclock, r->server_id); } - if (wal_mode != WAL_NONE) { - wal_writer_start(wal_mode, r->wal_dir.dirname, - &SERVER_UUID, &r->vclock, rows_per_wal); - } } diff --git a/src/box/recovery.h b/src/box/recovery.h index 61a7b3c598efd9233d9c39129bc4a515d084f339..fec2617c2885485c405db00cc6be2236834bf46c 100644 --- a/src/box/recovery.h +++ b/src/box/recovery.h @@ -35,7 +35,6 @@ #include "xlog.h" #include "vclock.h" #include "tt_uuid.h" -#include "wal.h" #if defined(__cplusplus) extern "C" { @@ -83,8 +82,7 @@ void recovery_stop_local(struct recovery *r); void -recovery_finalize(struct recovery *r, struct xstream *stream, - enum wal_mode mode, int64_t rows_per_wal); +recovery_finalize(struct recovery *r, struct xstream *stream); void recovery_fill_lsn(struct recovery *r, struct xrow_header *row); diff --git a/src/box/txn.cc b/src/box/txn.cc index 3c65a43c05c995953317b15f64d23875be8a3a5a..15f692ff7f2c0697bd0723ba80751dfb536bcdce 100644 --- a/src/box/txn.cc +++ b/src/box/txn.cc @@ -33,6 +33,7 @@ #include "box.h" /* global recovery */ #include "tuple.h" #include "recovery.h" +#include "wal.h" #include <fiber.h> #include "request.h" /* for request_name */ #include "xrow.h"