From a657409880b01478ed78497b01e9719069b3c6bd Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 10 Feb 2022 17:53:43 +0800 Subject: [PATCH 1/3] message redirection mechanism of mnode --- source/dnode/mgmt/impl/src/dndMnode.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/dnode/mgmt/impl/src/dndMnode.c b/source/dnode/mgmt/impl/src/dndMnode.c index 20585f269b..0874c633bf 100644 --- a/source/dnode/mgmt/impl/src/dndMnode.c +++ b/source/dnode/mgmt/impl/src/dndMnode.c @@ -552,8 +552,12 @@ static void dndWriteMnodeMsgToWorker(SDnode *pDnode, SDnodeWorker *pWorker, SRpc if (code != 0) { if (pRpcMsg->msgType & 1u) { - SRpcMsg rsp = {.handle = pRpcMsg->handle, .ahandle = pRpcMsg->ahandle, .code = code}; - rpcSendResponse(&rsp); + if (code == TSDB_CODE_DND_MNODE_NOT_DEPLOYED || code == TSDB_CODE_APP_NOT_READY) { + dndSendRedirectRsp(pDnode, pRpcMsg); + } else { + SRpcMsg rsp = {.handle = pRpcMsg->handle, .ahandle = pRpcMsg->ahandle, .code = code}; + rpcSendResponse(&rsp); + } } rpcFreeCont(pRpcMsg->pCont); } From 19f319b3bdfa7f47cef902ed977a6eb345576f10 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 10 Feb 2022 17:53:52 +0800 Subject: [PATCH 2/3] minor changes --- source/dnode/mnode/impl/src/mndMnode.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndMnode.c b/source/dnode/mnode/impl/src/mndMnode.c index dde48853ad..1e0164a572 100644 --- a/source/dnode/mnode/impl/src/mndMnode.c +++ b/source/dnode/mnode/impl/src/mndMnode.c @@ -604,13 +604,13 @@ static int32_t mndGetMnodeMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp * pShow->bytes[cols] = 8; pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP; - strcpy(pSchema[cols].name, "role_time"); + strcpy(pSchema[cols].name, "create_time"); pSchema[cols].bytes = htonl(pShow->bytes[cols]); cols++; pShow->bytes[cols] = 8; pSchema[cols].type = TSDB_DATA_TYPE_TIMESTAMP; - strcpy(pSchema[cols].name, "create_time"); + strcpy(pSchema[cols].name, "role_time"); pSchema[cols].bytes = htonl(pShow->bytes[cols]); cols++; @@ -659,11 +659,11 @@ static int32_t mndRetrieveMnodes(SMnodeMsg *pReq, SShowObj *pShow, char *data, i cols++; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - *(int64_t *)pWrite = pObj->roleTime; + *(int64_t *)pWrite = pObj->createdTime; cols++; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - *(int64_t *)pWrite = pObj->createdTime; + *(int64_t *)pWrite = pObj->roleTime; cols++; numOfRows++; From 05efaccfb6b2c711ea949b6e19eb2ed8e6ec2e3f Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 10 Feb 2022 21:38:15 +0800 Subject: [PATCH 3/3] minor changes --- source/dnode/mnode/impl/test/mnode/mnode.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/dnode/mnode/impl/test/mnode/mnode.cpp b/source/dnode/mnode/impl/test/mnode/mnode.cpp index f56b864cad..c69c86eb1c 100644 --- a/source/dnode/mnode/impl/test/mnode/mnode.cpp +++ b/source/dnode/mnode/impl/test/mnode/mnode.cpp @@ -45,8 +45,8 @@ TEST_F(MndTestMnode, 01_ShowDnode) { CHECK_SCHEMA(0, TSDB_DATA_TYPE_SMALLINT, 2, "id"); CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN + VARSTR_HEADER_SIZE, "endpoint"); CHECK_SCHEMA(2, TSDB_DATA_TYPE_BINARY, 12 + VARSTR_HEADER_SIZE, "role"); - CHECK_SCHEMA(3, TSDB_DATA_TYPE_TIMESTAMP, 8, "role_time"); - CHECK_SCHEMA(4, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); + CHECK_SCHEMA(3, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); + CHECK_SCHEMA(4, TSDB_DATA_TYPE_TIMESTAMP, 8, "role_time"); test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 1); @@ -54,8 +54,8 @@ TEST_F(MndTestMnode, 01_ShowDnode) { CheckInt16(1); CheckBinary("localhost:9028", TSDB_EP_LEN); CheckBinary("master", 12); - CheckInt64(0); CheckTimestamp(); + IgnoreTimestamp(); } TEST_F(MndTestMnode, 02_Create_Mnode_Invalid_Id) { @@ -124,10 +124,10 @@ TEST_F(MndTestMnode, 04_Create_Mnode) { CheckBinary("localhost:9029", TSDB_EP_LEN); CheckBinary("master", 12); CheckBinary("slave", 12); - CheckInt64(0); - CheckInt64(0); CheckTimestamp(); CheckTimestamp(); + IgnoreTimestamp(); + IgnoreTimestamp(); } { @@ -148,8 +148,8 @@ TEST_F(MndTestMnode, 04_Create_Mnode) { CheckInt16(1); CheckBinary("localhost:9028", TSDB_EP_LEN); CheckBinary("master", 12); - CheckInt64(0); CheckTimestamp(); + IgnoreTimestamp(); } {