[PATCH] applier: ignore ER_UNKNOWN_REQUEST_TYPE for IPROTO_VOTE

Vladimir Davydov vdavydov.dev at gmail.com
Wed Aug 29 17:56:17 MSK 2018


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




More information about the Tarantool-patches mailing list