Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: kostja@tarantool.org
Cc: tarantool-patches@freelists.org
Subject: [PATCH 1/2] replication: fix log message in case of sync failure
Date: Thu, 24 May 2018 21:00:27 +0300	[thread overview]
Message-ID: <c05037a58237a0de6001518473f4693d22b4ed0a.1527183256.git.vdavydov.dev@gmail.com> (raw)
In-Reply-To: <cover.1527183256.git.vdavydov.dev@gmail.com>
In-Reply-To: <cover.1527183256.git.vdavydov.dev@gmail.com>

replicaset_sync() returns not only if the instance synchronized to
connected replicas, but also if some replicas have disconnected and
the quorum can't be formed any more. Nevertheless, it always prints
that sync has been completed. Fix it.

See #3422
---
 src/box/replication.cc | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/box/replication.cc b/src/box/replication.cc
index 7bdefccf..6d90ee5f 100644
--- a/src/box/replication.cc
+++ b/src/box/replication.cc
@@ -636,18 +636,10 @@ 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");
+	if (quorum == 0)
 		return;
-	}
+
+	say_verbose("synchronizing with %d replicas", quorum);
 
 	/*
 	 * Wait until all connected replicas synchronize up to
@@ -657,10 +649,18 @@ replicaset_sync(void)
 	       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);
+	if (replicaset.applier.synced < 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;
 	}
+
+	say_crit("replica set sync complete, quorum of %d "
+		 "replicas formed", quorum);
 }
 
 void
-- 
2.11.0

  reply	other threads:[~2018-05-24 18:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-24 18:00 [PATCH 0/2] Do not enter orphan if replica is re-bootstrapping Vladimir Davydov
2018-05-24 18:00 ` Vladimir Davydov [this message]
2018-05-24 18:00 ` [PATCH 2/2] replication: do not stop syncing if replicas are loading Vladimir Davydov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c05037a58237a0de6001518473f4693d22b4ed0a.1527183256.git.vdavydov.dev@gmail.com \
    --to=vdavydov.dev@gmail.com \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [PATCH 1/2] replication: fix log message in case of sync failure' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox