From 861803eec5962036bc711a3aa7dc08f8b535c196 Mon Sep 17 00:00:00 2001 From: Konstantin Osipov <kostja@tarantool.org> Date: Tue, 22 May 2018 23:08:23 +0300 Subject: [PATCH] replication: add logging to replication connect/sync --- src/box/box.cc | 4 ++-- src/box/replication.cc | 23 ++++++++++++++++++++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/box/box.cc b/src/box/box.cc index 4cf7dd13d0..e3eb2738f3 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -1925,13 +1925,13 @@ box_cfg_xc(void) /* Follow replica */ replicaset_follow(); - say_info("ready to accept requests"); - fiber_gc(); is_box_configured = true; if (!is_bootstrap_leader) replicaset_sync(); + + say_info("ready to accept requests"); } void diff --git a/src/box/replication.cc b/src/box/replication.cc index 0b770c9131..89e9eb4a5c 100644 --- a/src/box/replication.cc +++ b/src/box/replication.cc @@ -520,6 +520,7 @@ replicaset_connect(struct applier **appliers, int count, replicaset_update(appliers, count); return; } + say_verbose("connecting to %d replicas", count); /* * Simultaneously connect to remote peers to receive their UUIDs @@ -564,9 +565,13 @@ replicaset_connect(struct applier **appliers, int count, timeout -= ev_monotonic_now(loop()) - wait_start; } if (state.connected < count) { + say_crit("failed to connect to %d out of %d replicas", + count - state.connected, count); /* Timeout or connection failure. */ if (connect_all) goto error; + } else { + say_verbose("connected to %d replicas", state.connected); } for (int i = 0; i < count; i++) { @@ -631,29 +636,41 @@ replicaset_sync(void) { int quorum = replicaset_quorum(); + if (quorum > 0) + say_verbose("synchronizing with %d replicas", quorum); + if (replicaset.applier.connected < quorum) { /* * Not enough replicas connected to form a quorum. * Do not stall configuration, leave the instance * in 'orphan' state. */ + say_crit("entering orphan mode"); return; } /* - * Wait until a quorum is formed. Abort waiting if - * a quorum cannot be formed because of errors. + * Wait until all connected replicas synchronize up to + * replication_sync_lag */ while (replicaset.applier.synced < quorum && replicaset.applier.connected >= quorum) fiber_cond_wait(&replicaset.applier.cond); + + if (quorum > 0) { + say_crit("replica set sync complete, quorum of %d " + "replicas formed", quorum); + } } void replicaset_check_quorum(void) { - if (replicaset.applier.synced >= replicaset_quorum()) + if (replicaset.applier.synced >= replicaset_quorum()) { + if (replicaset_quorum() > 0) + say_crit("leaving orphan mode"); box_clear_orphan(); + } } void -- GitLab