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] applier: ignore ER_UNKNOWN_REQUEST_TYPE for IPROTO_VOTE
Date: Wed, 29 Aug 2018 17:56:17 +0300	[thread overview]
Message-ID: <745b289ee540b1361e3cb1fdf3eeba6feb83b868.1535554518.git.vdavydov.dev@gmail.com> (raw)

IPROTO_VOTE command (successor of IPROTO_REQUEST_VOTE) was introduced in
Tarantool 1.10.1. It is sent by an applier to its master only if the
master is running Tarantool 1.10.1 or newer. However, the master may be
running a Tarantool version 1.10.1 that isn't aware of IPROTO_VOTE, in
which case the applier will fail to connect with ER_UNKNOWN_REQUEST_TYPE
error.

Let's fix this issue by ignoring ER_UNKNOWN_REQUEST_TYPE received in
reply to IPROTO_VOTE command.
---
https://github.com/tarantool/tarantool/commits/dv/applier-ignore-unknown-request-error-on-vote

 src/box/applier.cc | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/src/box/applier.cc b/src/box/applier.cc
index 28df8f7c..7c4fc224 100644
--- a/src/box/applier.cc
+++ b/src/box/applier.cc
@@ -213,17 +213,24 @@ applier_connect(struct applier *applier)
 	diag_clear(&fiber()->diag);
 
 	/*
-	 * Tarantool >= 1.10.1: send an IPROTO_VOTE request to
-	 * fetch the master's ballot before proceeding to "join".
-	 * It will be used for leader election on bootstrap.
+	 * Send an IPROTO_VOTE request to fetch the master's ballot
+	 * before proceeding to "join". It will be used for leader
+	 * election on bootstrap.
 	 */
-	if (applier->version_id >= version_id(1, 10, 1)) {
-		xrow_encode_vote(&row);
-		coio_write_xrow(coio, &row);
-		coio_read_xrow(coio, ibuf, &row);
-		if (row.type != IPROTO_OK)
-			xrow_decode_error_xc(&row);
+	xrow_encode_vote(&row);
+	coio_write_xrow(coio, &row);
+	coio_read_xrow(coio, ibuf, &row);
+	if (row.type == IPROTO_OK) {
 		xrow_decode_ballot_xc(&row, &applier->ballot);
+	} else try {
+		xrow_decode_error_xc(&row);
+	} catch (ClientError *e) {
+		if (e->errcode() != ER_UNKNOWN_REQUEST_TYPE)
+			e->raise();
+		/*
+		 * Master isn't aware of IPROTO_VOTE request.
+		 * It's OK - we can proceed without it.
+		 */
 	}
 
 	applier_set_state(applier, APPLIER_CONNECTED);
-- 
2.11.0

                 reply	other threads:[~2018-08-29 14:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=745b289ee540b1361e3cb1fdf3eeba6feb83b868.1535554518.git.vdavydov.dev@gmail.com \
    --to=vdavydov.dev@gmail.com \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [PATCH] applier: ignore ER_UNKNOWN_REQUEST_TYPE for IPROTO_VOTE' \
    /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