[PATCH 3/6] iproto: fix IPROTO_SERVER_IS_RO key code

Vladimir Davydov vdavydov.dev at gmail.com
Wed Jun 13 19:10:35 MSK 2018


IPROTO_SERVER_IS_RO currently has code 0x07 and is defined in the header
key section, which is wrong, because this key is only used in request
body. Let's move it to the body section, where it belongs, and set its
code to 0x29. This shouldn't break anything even if 0x07 is reused in
future, because the two codes belong to different sections and hence are
never parsed in the same function. Worst that can happen is we fail to
bootstrap a node in the cluster if it is running a newer tarantool
version.

While we are at it, let's also add the key name and change its type from
MP_UINT to MP_BOOL.

Fixes commit a8ecd1e122ae ("replication: fix bug with read-only replica
as a bootstrap leader").
---
 src/box/iproto_constants.c | 5 +++--
 src/box/iproto_constants.h | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/box/iproto_constants.c b/src/box/iproto_constants.c
index 6dba85f5..3adb7cd4 100644
--- a/src/box/iproto_constants.c
+++ b/src/box/iproto_constants.c
@@ -40,10 +40,10 @@ const unsigned char iproto_key_type[IPROTO_KEY_MAX] =
 		/* 0x04 */	MP_DOUBLE, /* IPROTO_TIMESTAMP */
 		/* 0x05 */	MP_UINT,   /* IPROTO_SCHEMA_VERSION */
 		/* 0x06 */	MP_UINT,   /* IPROTO_SERVER_VERSION */
-		/* 0x07 */	MP_UINT,   /* IPROTO_SERVER_IS_RO */
 	/* }}} */
 
 	/* {{{ unused */
+		/* 0x07 */	MP_UINT,
 		/* 0x08 */	MP_UINT,
 		/* 0x09 */	MP_UINT,
 		/* 0x0a */	MP_UINT,
@@ -86,6 +86,7 @@ const unsigned char iproto_key_type[IPROTO_KEY_MAX] =
 	/* 0x26 */	MP_MAP, /* IPROTO_VCLOCK */
 	/* 0x27 */	MP_STR, /* IPROTO_EXPR */
 	/* 0x28 */	MP_ARRAY, /* IPROTO_OPS */
+	/* 0x29 */	MP_BOOL, /* IPROTO_SERVER_IS_RO */
 	/* }}} */
 };
 
@@ -166,7 +167,7 @@ const char *iproto_key_strs[IPROTO_KEY_MAX] = {
 	"vector clock",     /* 0x26 */
 	"expression",       /* 0x27 */
 	"operations",       /* 0x28 */
-	NULL,               /* 0x29 */
+	"server is ro",     /* 0x29 */
 	NULL,               /* 0x2a */
 	NULL,               /* 0x2b */
 	NULL,               /* 0x2c */
diff --git a/src/box/iproto_constants.h b/src/box/iproto_constants.h
index dd50bf87..d1320de7 100644
--- a/src/box/iproto_constants.h
+++ b/src/box/iproto_constants.h
@@ -58,7 +58,6 @@ enum iproto_key {
 	IPROTO_TIMESTAMP = 0x04,
 	IPROTO_SCHEMA_VERSION = 0x05,
 	IPROTO_SERVER_VERSION = 0x06,
-	IPROTO_SERVER_IS_RO = 0x07,
 	/* Leave a gap for other keys in the header. */
 	IPROTO_SPACE_ID = 0x10,
 	IPROTO_INDEX_ID = 0x11,
@@ -77,6 +76,7 @@ enum iproto_key {
 	IPROTO_VCLOCK = 0x26,
 	IPROTO_EXPR = 0x27, /* EVAL */
 	IPROTO_OPS = 0x28, /* UPSERT but not UPDATE ops, because of legacy */
+	IPROTO_SERVER_IS_RO = 0x29,
 	/* Leave a gap between request keys and response keys */
 	IPROTO_DATA = 0x30,
 	IPROTO_ERROR = 0x31,
-- 
2.11.0




More information about the Tarantool-patches mailing list