From 0a83ecac8150ae69ce2ae1eff7b7a8aeb88ee9e8 Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Tue, 4 Jan 2022 10:40:34 +0800 Subject: [PATCH 01/18] add sub structure --- include/common/tmsg.h | 104 ++++++++++++---- include/util/tdef.h | 1 + source/dnode/mnode/impl/inc/mndDef.h | 103 +++++++++++----- source/dnode/mnode/impl/src/mndConsumer.c | 140 +++++++++++++++++----- 4 files changed, 264 insertions(+), 84 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index ba8bb7ca2f..2b17e6db7a 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -320,14 +320,23 @@ typedef struct SEpSet { } SEpSet; static FORCE_INLINE int taosEncodeSEpSet(void** buf, const SEpSet* pEp) { - if(buf == NULL) return sizeof(SEpSet); - memcpy(buf, pEp, sizeof(SEpSet)); - //TODO: endian conversion - return sizeof(SEpSet); + int tlen = 0; + tlen += taosEncodeFixedI8(buf, pEp->inUse); + tlen += taosEncodeFixedI8(buf, pEp->numOfEps); + for (int i = 0; i < TSDB_MAX_REPLICA; i++) { + tlen += taosEncodeFixedU16(buf, pEp->port[i]); + tlen += taosEncodeString(buf, pEp->fqdn[i]); + } + return tlen; } -static FORCE_INLINE void* taosDecodeSEpSet(void* buf, SEpSet* pEpSet) { - memcpy(pEpSet, buf, sizeof(SEpSet)); +static FORCE_INLINE void* taosDecodeSEpSet(void* buf, SEpSet* pEp) { + buf = taosDecodeFixedI8(buf, &pEp->inUse); + buf = taosDecodeFixedI8(buf, &pEp->numOfEps); + for (int i = 0; i < TSDB_MAX_REPLICA; i++) { + buf = taosDecodeFixedU16(buf, &pEp->port[i]); + buf = taosDecodeStringTo(buf, pEp->fqdn[i]); + } return buf; } @@ -1088,16 +1097,16 @@ typedef struct STaskDropRsp { } STaskDropRsp; typedef struct { - int8_t igExists; - char* name; - char* physicalPlan; - char* logicalPlan; + int8_t igExists; + char* name; + char* physicalPlan; + char* logicalPlan; } SCMCreateTopicReq; static FORCE_INLINE int tSerializeSCMCreateTopicReq(void** buf, const SCMCreateTopicReq* pReq) { int tlen = 0; - tlen += taosEncodeString(buf, pReq->name); tlen += taosEncodeFixedI8(buf, pReq->igExists); + tlen += taosEncodeString(buf, pReq->name); tlen += taosEncodeString(buf, pReq->physicalPlan); tlen += taosEncodeString(buf, pReq->logicalPlan); return tlen; @@ -1127,41 +1136,62 @@ static FORCE_INLINE void* tDeserializeSCMCreateTopicRsp(void* buf, SCMCreateTopi } typedef struct { - char* topicName; - char* consumerGroup; + int32_t topicNum; int64_t consumerId; + char* consumerGroup; + char* topicName[]; } SCMSubscribeReq; static FORCE_INLINE int tSerializeSCMSubscribeReq(void** buf, const SCMSubscribeReq* pReq) { int tlen = 0; - tlen += taosEncodeString(buf, pReq->topicName); - tlen += taosEncodeString(buf, pReq->consumerGroup); + tlen += taosEncodeFixedI32(buf, pReq->topicNum); tlen += taosEncodeFixedI64(buf, pReq->consumerId); + tlen += taosEncodeString(buf, pReq->consumerGroup); + for(int i = 0; i < pReq->topicNum; i++) { + tlen += taosEncodeString(buf, pReq->topicName[i]); + } return tlen; } static FORCE_INLINE void* tDeserializeSCMSubscribeReq(void* buf, SCMSubscribeReq* pReq) { - buf = taosDecodeString(buf, &pReq->topicName); - buf = taosDecodeString(buf, &pReq->consumerGroup); + buf = taosDecodeFixedI32(buf, &pReq->topicNum); buf = taosDecodeFixedI64(buf, &pReq->consumerId); + buf = taosDecodeString(buf, &pReq->consumerGroup); + for(int i = 0; i < pReq->topicNum; i++) { + buf = taosDecodeString(buf, &pReq->topicName[i]); + } return buf; } -typedef struct { +typedef struct SMqSubTopic { int32_t vgId; - SEpSet pEpSet; + int64_t topicId; + SEpSet epSet; +} SMqSubTopic; + +typedef struct { + int32_t topicNum; + SMqSubTopic topics[]; } SCMSubscribeRsp; static FORCE_INLINE int tSerializeSCMSubscribeRsp(void** buf, const SCMSubscribeRsp* pRsp) { int tlen = 0; - tlen += taosEncodeFixedI32(buf, pRsp->vgId); - tlen += taosEncodeSEpSet(buf, &pRsp->pEpSet); + tlen += taosEncodeFixedI32(buf, pRsp->topicNum); + for(int i = 0; i < pRsp->topicNum; i++) { + tlen += taosEncodeFixedI32(buf, pRsp->topics[i].vgId); + tlen += taosEncodeFixedI64(buf, pRsp->topics[i].topicId); + tlen += taosEncodeSEpSet(buf, &pRsp->topics[i].epSet); + } return tlen; } static FORCE_INLINE void* tDeserializeSCMSubscribeRsp(void* buf, SCMSubscribeRsp* pRsp) { - buf = taosDecodeFixedI32(buf, &pRsp->vgId); - buf = taosDecodeSEpSet(buf, &pRsp->pEpSet); + buf = taosDecodeFixedI32(buf, &pRsp->topicNum); + for(int i = 0; i < pRsp->topicNum; i++) { + buf = taosDecodeFixedI32(buf, &pRsp->topics[i].vgId); + buf = taosDecodeFixedI64(buf, &pRsp->topics[i].topicId); + buf = taosDecodeSEpSet(buf, &pRsp->topics[i].epSet); + } return buf; } @@ -1170,10 +1200,36 @@ typedef struct { int64_t consumerId; int64_t consumerGroupId; int64_t offset; + char* sql; + char* logicalPlan; + char* physicalPlan; } SMVSubscribeReq; +static FORCE_INLINE int tSerializeSMVSubscribeReq(void* buf, SMVSubscribeReq* pReq) { + int tlen = 0; + tlen += taosEncodeFixedI64(buf, pReq->topicId); + tlen += taosEncodeFixedI64(buf, pReq->consumerId); + tlen += taosEncodeFixedI64(buf, pReq->consumerGroupId); + tlen += taosEncodeFixedI64(buf, pReq->offset); + tlen += taosEncodeString(buf, pReq->sql); + tlen += taosEncodeString(buf, pReq->logicalPlan); + tlen += taosEncodeString(buf, pReq->physicalPlan); + return tlen; +} + +static FORCE_INLINE void* tDeserializeSMVSubscribeReq(void* buf, SMVSubscribeReq* pReq) { + buf = taosDecodeFixedI64(buf, &pReq->topicId); + buf = taosDecodeFixedI64(buf, &pReq->consumerId); + buf = taosDecodeFixedI64(buf, &pReq->consumerGroupId); + buf = taosDecodeFixedI64(buf, &pReq->offset); + buf = taosDecodeString(buf, &pReq->sql); + buf = taosDecodeString(buf, &pReq->logicalPlan); + buf = taosDecodeString(buf, &pReq->physicalPlan); + return buf; +} + typedef struct { - int64_t newOffset; + int64_t status; } SMVSubscribeRsp; typedef struct { diff --git a/include/util/tdef.h b/include/util/tdef.h index 233e9f0f55..9f16b58e0d 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -177,6 +177,7 @@ do { \ #define TSDB_TYPE_STR_MAX_LEN 32 #define TSDB_TABLE_FNAME_LEN (TSDB_DB_FNAME_LEN + TSDB_TABLE_NAME_LEN + TSDB_NAME_DELIMITER_LEN) #define TSDB_TOPIC_FNAME_LEN TSDB_TABLE_FNAME_LEN +#define TSDB_CONSUMER_GROUP_LEN 192 #define TSDB_COL_NAME_LEN 65 #define TSDB_MAX_SAVED_SQL_LEN TSDB_MAX_COLUMNS * 64 #define TSDB_MAX_SQL_LEN TSDB_PAYLOAD_SIZE diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index a874e67210..986914a8e2 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -22,6 +22,7 @@ #include "sync.h" #include "tmsg.h" #include "thash.h" +#include "tlist.h" #include "tlog.h" #include "trpc.h" #include "ttimer.h" @@ -288,14 +289,81 @@ typedef struct { char payload[]; } SShowObj; +typedef struct SConsumerObj { + uint64_t uid; + int64_t createTime; + int64_t updateTime; + //uint64_t dbUid; + int32_t version; + SRWLatch lock; + SList* topics; +} SConsumerObj; + +typedef struct SMqSubConsumerObj { + int64_t consumerUid; // if -1, unassigned + SList* vgId; //SList +} SMqSubConsumerObj; + +typedef struct SMqSubCGroupObj { + char name[TSDB_CONSUMER_GROUP_LEN]; + SList* consumers; //SList +} SMqSubCGroupObj; + +typedef struct SMqSubTopicObj { + char name[TSDB_TOPIC_FNAME_LEN]; + char db[TSDB_DB_FNAME_LEN]; + int64_t createTime; + int64_t updateTime; + int64_t uid; + int64_t dbUid; + int32_t version; + SRWLatch lock; + int32_t sqlLen; + char* sql; + char* logicalPlan; + char* physicalPlan; + SList* cgroups; //SList +} SMqSubTopicObj; + +typedef struct SMqConsumerSubObj { + int64_t topicUid; + SList* vgIds; //SList +} SMqConsumerSubObj; + +typedef struct SMqConsumerHbObj { + int64_t consumerId; + SList* consumerSubs; //SList +} SMqConsumerHbObj; + +typedef struct SMqVGroupSubObj { + int64_t topicUid; + SList* consumerIds; //SList +} SMqVGroupSubObj; + +typedef struct SMqVGroupHbObj { + int64_t vgId; + SList* vgSubs; //SList +} SMqVGroupHbObj; + +typedef struct SCGroupObj { + char name[TSDB_TOPIC_FNAME_LEN]; + int64_t createTime; + int64_t updateTime; + uint64_t uid; + //uint64_t dbUid; + int32_t version; + SRWLatch lock; + SList* consumerIds; +} SCGroupObj; + typedef struct { - char name[TSDB_TOPIC_FNAME_LEN]; - char db[TSDB_DB_FNAME_LEN]; - int64_t createTime; - int64_t updateTime; + char name[TSDB_TOPIC_FNAME_LEN]; + char db[TSDB_DB_FNAME_LEN]; + int64_t createTime; + int64_t updateTime; uint64_t uid; uint64_t dbUid; - int32_t version; + int32_t version; SRWLatch lock; int32_t execLen; void* executor; @@ -303,32 +371,9 @@ typedef struct { char* sql; char* logicalPlan; char* physicalPlan; + SList* consumerIds; } STopicObj; -typedef struct { - char name[TSDB_TOPIC_FNAME_LEN]; - char db[TSDB_DB_FNAME_LEN]; - int64_t createTime; - int64_t updateTime; - uint64_t uid; - //uint64_t dbUid; - int32_t version; - SRWLatch lock; - -} SConsumerObj; - -typedef struct { - char name[TSDB_TOPIC_FNAME_LEN]; - char db[TSDB_DB_FNAME_LEN]; - int64_t createTime; - int64_t updateTime; - uint64_t uid; - //uint64_t dbUid; - int32_t version; - SRWLatch lock; - -} SCGroupObj; - typedef struct SMnodeMsg { char user[TSDB_USER_LEN]; char db[TSDB_DB_FNAME_LEN]; diff --git a/source/dnode/mnode/impl/src/mndConsumer.c b/source/dnode/mnode/impl/src/mndConsumer.c index 9e7cdbf09e..5391b0f73e 100644 --- a/source/dnode/mnode/impl/src/mndConsumer.c +++ b/source/dnode/mnode/impl/src/mndConsumer.c @@ -66,17 +66,82 @@ int32_t mndInitConsumer(SMnode *pMnode) { void mndCleanupConsumer(SMnode *pMnode) {} +static SSdbRaw *mndCGroupActionEncode(SCGroupObj *pCGroup) { + int32_t size = sizeof(SConsumerObj) + MND_CONSUMER_RESERVE_SIZE; + SSdbRaw *pRaw = sdbAllocRaw(SDB_CONSUMER, MND_CONSUMER_VER_NUMBER, size); + if (pRaw == NULL) return NULL; + + int32_t dataPos = 0; + SDB_SET_BINARY(pRaw, dataPos, pCGroup->name, TSDB_TABLE_FNAME_LEN); + SDB_SET_INT64(pRaw, dataPos, pCGroup->createTime); + SDB_SET_INT64(pRaw, dataPos, pCGroup->updateTime); + SDB_SET_INT64(pRaw, dataPos, pCGroup->uid); + /*SDB_SET_INT64(pRaw, dataPos, pConsumer->dbUid);*/ + SDB_SET_INT32(pRaw, dataPos, pCGroup->version); + + int32_t sz = listNEles(pCGroup->consumerIds); + SDB_SET_INT32(pRaw, dataPos, sz); + + SListIter iter; + tdListInitIter(pCGroup->consumerIds, &iter, TD_LIST_FORWARD); + SListNode *pn = NULL; + while ((pn = tdListNext(&iter)) != NULL) { + int64_t consumerId = *(int64_t *)pn->data; + SDB_SET_INT64(pRaw, dataPos, consumerId); + } + + SDB_SET_RESERVE(pRaw, dataPos, MND_CONSUMER_RESERVE_SIZE); + SDB_SET_DATALEN(pRaw, dataPos); + return pRaw; +} + +static SSdbRow *mndCGroupActionDecode(SSdbRaw *pRaw) { + int8_t sver = 0; + if (sdbGetRawSoftVer(pRaw, &sver) != 0) return NULL; + + if (sver != MND_CONSUMER_VER_NUMBER) { + terrno = TSDB_CODE_SDB_INVALID_DATA_VER; + mError("failed to decode cgroup since %s", terrstr()); + return NULL; + } + + // TODO: maximum size is not known + int32_t size = sizeof(SCGroupObj) + 128 * sizeof(int64_t); + SSdbRow *pRow = sdbAllocRow(size); + SCGroupObj *pCGroup = sdbGetRowObj(pRow); + if (pCGroup == NULL) return NULL; + + int32_t dataPos = 0; + SDB_GET_BINARY(pRaw, pRow, dataPos, pCGroup->name, TSDB_TABLE_FNAME_LEN); + SDB_GET_INT64(pRaw, pRow, dataPos, &pCGroup->createTime); + SDB_GET_INT64(pRaw, pRow, dataPos, &pCGroup->updateTime); + SDB_GET_INT64(pRaw, pRow, dataPos, &pCGroup->uid); + /*SDB_GET_INT64(pRaw, pRow, dataPos, &pConsumer->dbUid);*/ + SDB_GET_INT32(pRaw, pRow, dataPos, &pCGroup->version); + + int32_t sz; + SDB_GET_INT32(pRaw, pRow, dataPos, &sz); + // TODO: free list when failing + tdListInit(pCGroup->consumerIds, sizeof(int64_t)); + for (int i = 0; i < sz; i++) { + int64_t consumerId; + SDB_GET_INT64(pRaw, pRow, dataPos, &consumerId); + tdListAppend(pCGroup->consumerIds, &consumerId); + } + + SDB_GET_RESERVE(pRaw, pRow, dataPos, MND_CONSUMER_RESERVE_SIZE); + return pRow; +} + static SSdbRaw *mndConsumerActionEncode(SConsumerObj *pConsumer) { int32_t size = sizeof(SConsumerObj) + MND_CONSUMER_RESERVE_SIZE; SSdbRaw *pRaw = sdbAllocRaw(SDB_CONSUMER, MND_CONSUMER_VER_NUMBER, size); if (pRaw == NULL) return NULL; int32_t dataPos = 0; - SDB_SET_BINARY(pRaw, dataPos, pConsumer->name, TSDB_TABLE_FNAME_LEN); - SDB_SET_BINARY(pRaw, dataPos, pConsumer->db, TSDB_DB_FNAME_LEN); + SDB_SET_INT64(pRaw, dataPos, pConsumer->uid); SDB_SET_INT64(pRaw, dataPos, pConsumer->createTime); SDB_SET_INT64(pRaw, dataPos, pConsumer->updateTime); - SDB_SET_INT64(pRaw, dataPos, pConsumer->uid); /*SDB_SET_INT64(pRaw, dataPos, pConsumer->dbUid);*/ SDB_SET_INT32(pRaw, dataPos, pConsumer->version); @@ -102,11 +167,9 @@ static SSdbRow *mndConsumerActionDecode(SSdbRaw *pRaw) { if (pConsumer == NULL) return NULL; int32_t dataPos = 0; - SDB_GET_BINARY(pRaw, pRow, dataPos, pConsumer->name, TSDB_TABLE_FNAME_LEN); - SDB_GET_BINARY(pRaw, pRow, dataPos, pConsumer->db, TSDB_DB_FNAME_LEN); + SDB_GET_INT64(pRaw, pRow, dataPos, &pConsumer->uid); SDB_GET_INT64(pRaw, pRow, dataPos, &pConsumer->createTime); SDB_GET_INT64(pRaw, pRow, dataPos, &pConsumer->updateTime); - SDB_GET_INT64(pRaw, pRow, dataPos, &pConsumer->uid); /*SDB_GET_INT64(pRaw, pRow, dataPos, &pConsumer->dbUid);*/ SDB_GET_INT32(pRaw, pRow, dataPos, &pConsumer->version); @@ -116,17 +179,17 @@ static SSdbRow *mndConsumerActionDecode(SSdbRaw *pRaw) { } static int32_t mndConsumerActionInsert(SSdb *pSdb, SConsumerObj *pConsumer) { - mTrace("consumer:%s, perform insert action", pConsumer->name); + mTrace("consumer:%ld, perform insert action", pConsumer->uid); return 0; } static int32_t mndConsumerActionDelete(SSdb *pSdb, SConsumerObj *pConsumer) { - mTrace("consumer:%s, perform delete action", pConsumer->name); + mTrace("consumer:%ld, perform delete action", pConsumer->uid); return 0; } static int32_t mndConsumerActionUpdate(SSdb *pSdb, SConsumerObj *pOldConsumer, SConsumerObj *pNewConsumer) { - mTrace("consumer:%s, perform update action", pOldConsumer->name); + mTrace("consumer:%ld, perform update action", pOldConsumer->uid); atomic_exchange_32(&pOldConsumer->updateTime, pNewConsumer->updateTime); atomic_exchange_32(&pOldConsumer->version, pNewConsumer->version); @@ -157,9 +220,34 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) { char *msgStr = pMsg->rpcMsg.pCont; SCMSubscribeReq *pSubscribe; tDeserializeSCMSubscribeReq(msgStr, pSubscribe); - // add consumerGroupId -> list to sdb - // add consumerId -> list to sdb - // add consumer -> list to sdb + int topicNum = pSubscribe->topicNum; + int64_t consumerId = pSubscribe->consumerId; + char *consumerGroup = pSubscribe->consumerGroup; + // get consumer group and add client into it + SCGroupObj *pCGroup = sdbAcquire(pMnode->pSdb, SDB_CGROUP, consumerGroup); + if (pCGroup != NULL) { + // iterate the list until finding the consumer + // add consumer to cgroup list if not found + // put new record + } + + SConsumerObj *pConsumer = mndAcquireConsumer(pMnode, consumerId); + if (pConsumer != NULL) { + //reset topic list + } + + for (int i = 0; i < topicNum; i++) { + char *topicName = pSubscribe->topicName[i]; + STopicObj *pTopic = mndAcquireTopic(pMnode, topicName); + //get + // consumer id + SList *list = pTopic->consumerIds; + // add the consumer if not in the list + // + SList* topicList = pConsumer->topics; + //add to topic + } + return 0; } @@ -255,9 +343,7 @@ static int32_t mndGetNumOfConsumers(SMnode *pMnode, char *dbName, int32_t *pNumO pIter = sdbFetch(pSdb, SDB_CONSUMER, pIter, (void **)&pConsumer); if (pIter == NULL) break; - if (strcmp(pConsumer->db, dbName) == 0) { - numOfConsumers++; - } + numOfConsumers++; sdbRelease(pSdb, pConsumer); } @@ -316,11 +402,11 @@ static int32_t mndGetConsumerMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMs return 0; } -static int32_t mndRetrieveConsumer(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int32_t rows) { +static int32_t mndRetrieveCGroup(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int32_t rows) { SMnode *pMnode = pMsg->pMnode; SSdb *pSdb = pMnode->pSdb; int32_t numOfRows = 0; - SConsumerObj *pConsumer = NULL; + SCGroupObj *pCGroup = NULL; int32_t cols = 0; char *pWrite; char prefix[64] = {0}; @@ -330,36 +416,28 @@ static int32_t mndRetrieveConsumer(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int32_t prefixLen = (int32_t)strlen(prefix); while (numOfRows < rows) { - pShow->pIter = sdbFetch(pSdb, SDB_CONSUMER, pShow->pIter, (void **)&pConsumer); + pShow->pIter = sdbFetch(pSdb, SDB_CONSUMER, pShow->pIter, (void **)&pCGroup); if (pShow->pIter == NULL) break; - if (strncmp(pConsumer->name, prefix, prefixLen) != 0) { - sdbRelease(pSdb, pConsumer); + if (strncmp(pCGroup->name, prefix, prefixLen) != 0) { + sdbRelease(pSdb, pCGroup); continue; } cols = 0; char consumerName[TSDB_TABLE_NAME_LEN] = {0}; - tstrncpy(consumerName, pConsumer->name + prefixLen, TSDB_TABLE_NAME_LEN); + tstrncpy(consumerName, pCGroup->name + prefixLen, TSDB_TABLE_NAME_LEN); pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; STR_TO_VARSTR(pWrite, consumerName); cols++; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - *(int64_t *)pWrite = pConsumer->createTime; + *(int64_t *)pWrite = pCGroup->createTime; cols++; - /*pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;*/ - /**(int32_t *)pWrite = pConsumer->numOfColumns;*/ - /*cols++;*/ - - /*pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;*/ - /**(int32_t *)pWrite = pConsumer->numOfTags;*/ - /*cols++;*/ - numOfRows++; - sdbRelease(pSdb, pConsumer); + sdbRelease(pSdb, pCGroup); } pShow->numOfReads += numOfRows; From fdca2ec4bfc1ce0f868a405dbae337533e9fc33a Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 5 Jan 2022 02:18:47 -0800 Subject: [PATCH 02/18] minor changes --- source/dnode/mgmt/impl/test/CMakeLists.txt | 2 - .../mgmt/impl/test/cluster/CMakeLists.txt | 11 ----- .../dnode/mgmt/impl/test/cluster/cluster.cpp | 41 ------------------- .../impl/test/show/CMakeLists.txt | 0 .../{mgmt => mnode}/impl/test/show/show.cpp | 0 5 files changed, 54 deletions(-) delete mode 100644 source/dnode/mgmt/impl/test/cluster/CMakeLists.txt delete mode 100644 source/dnode/mgmt/impl/test/cluster/cluster.cpp rename source/dnode/{mgmt => mnode}/impl/test/show/CMakeLists.txt (100%) rename source/dnode/{mgmt => mnode}/impl/test/show/show.cpp (100%) diff --git a/source/dnode/mgmt/impl/test/CMakeLists.txt b/source/dnode/mgmt/impl/test/CMakeLists.txt index da043f8fe2..b13edf7d5a 100644 --- a/source/dnode/mgmt/impl/test/CMakeLists.txt +++ b/source/dnode/mgmt/impl/test/CMakeLists.txt @@ -6,13 +6,11 @@ add_subdirectory(snode) # add_subdirectory(auth) # add_subdirectory(balance) -add_subdirectory(cluster) add_subdirectory(db) add_subdirectory(dnode) # add_subdirectory(func) add_subdirectory(mnode) add_subdirectory(profile) -add_subdirectory(show) add_subdirectory(stb) # add_subdirectory(sync) # add_subdirectory(telem) diff --git a/source/dnode/mgmt/impl/test/cluster/CMakeLists.txt b/source/dnode/mgmt/impl/test/cluster/CMakeLists.txt deleted file mode 100644 index a63f3106e6..0000000000 --- a/source/dnode/mgmt/impl/test/cluster/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -aux_source_directory(. CLUSTER_SRC) -add_executable(dnode_test_cluster ${CLUSTER_SRC}) -target_link_libraries( - dnode_test_cluster - PUBLIC sut -) - -add_test( - NAME dnode_test_cluster - COMMAND dnode_test_cluster -) diff --git a/source/dnode/mgmt/impl/test/cluster/cluster.cpp b/source/dnode/mgmt/impl/test/cluster/cluster.cpp deleted file mode 100644 index 7d9bff7b23..0000000000 --- a/source/dnode/mgmt/impl/test/cluster/cluster.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @file cluster.cpp - * @author slguan (slguan@taosdata.com) - * @brief DNODE module cluster-msg tests - * @version 0.1 - * @date 2021-12-15 - * - * @copyright Copyright (c) 2021 - * - */ - -#include "sut.h" - -class DndTestCluster : public ::testing::Test { - protected: - static void SetUpTestSuite() { test.Init("/tmp/dnode_test_cluster", 9030); } - static void TearDownTestSuite() { test.Cleanup(); } - - static Testbase test; - - public: - void SetUp() override {} - void TearDown() override {} -}; - -Testbase DndTestCluster::test; - -TEST_F(DndTestCluster, 01_ShowCluster) { - test.SendShowMetaMsg(TSDB_MGMT_TABLE_CLUSTER, ""); - CHECK_META( "show cluster", 3); - CHECK_SCHEMA(0, TSDB_DATA_TYPE_BIGINT, 8, "id"); - CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_CLUSTER_ID_LEN + VARSTR_HEADER_SIZE, "name"); - CHECK_SCHEMA(2, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); - - test.SendShowRetrieveMsg(); - EXPECT_EQ(test.GetShowRows(), 1); - - IgnoreInt64(); - IgnoreBinary(TSDB_CLUSTER_ID_LEN); - CheckTimestamp(); -} \ No newline at end of file diff --git a/source/dnode/mgmt/impl/test/show/CMakeLists.txt b/source/dnode/mnode/impl/test/show/CMakeLists.txt similarity index 100% rename from source/dnode/mgmt/impl/test/show/CMakeLists.txt rename to source/dnode/mnode/impl/test/show/CMakeLists.txt diff --git a/source/dnode/mgmt/impl/test/show/show.cpp b/source/dnode/mnode/impl/test/show/show.cpp similarity index 100% rename from source/dnode/mgmt/impl/test/show/show.cpp rename to source/dnode/mnode/impl/test/show/show.cpp From 9e3a6804a9d5ca9e1403f154d0b078803e5d1c61 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 5 Jan 2022 02:20:59 -0800 Subject: [PATCH 03/18] add show test --- source/dnode/mnode/impl/test/CMakeLists.txt | 2 +- .../dnode/mnode/impl/test/show/CMakeLists.txt | 8 ++-- source/dnode/mnode/impl/test/show/show.cpp | 37 +++++++++++++------ 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/source/dnode/mnode/impl/test/CMakeLists.txt b/source/dnode/mnode/impl/test/CMakeLists.txt index 075ff38bc6..6cdc43344d 100644 --- a/source/dnode/mnode/impl/test/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/CMakeLists.txt @@ -6,4 +6,4 @@ add_subdirectory(trans) add_subdirectory(qnode) add_subdirectory(snode) add_subdirectory(bnode) - +add_subdirectory(show) diff --git a/source/dnode/mnode/impl/test/show/CMakeLists.txt b/source/dnode/mnode/impl/test/show/CMakeLists.txt index 9786f65605..cc0706ca50 100644 --- a/source/dnode/mnode/impl/test/show/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/show/CMakeLists.txt @@ -1,11 +1,11 @@ aux_source_directory(. SHOW_SRC) -add_executable(dnode_test_show ${SHOW_SRC}) +add_executable(mnode_test_show ${SHOW_SRC}) target_link_libraries( - dnode_test_show + mnode_test_show PUBLIC sut ) add_test( - NAME dnode_test_show - COMMAND dnode_test_show + NAME mnode_test_show + COMMAND mnode_test_show ) diff --git a/source/dnode/mnode/impl/test/show/show.cpp b/source/dnode/mnode/impl/test/show/show.cpp index 8622672758..6d2c9150f2 100644 --- a/source/dnode/mnode/impl/test/show/show.cpp +++ b/source/dnode/mnode/impl/test/show/show.cpp @@ -1,19 +1,19 @@ /** * @file show.cpp * @author slguan (slguan@taosdata.com) - * @brief DNODE module show-msg tests - * @version 0.1 - * @date 2021-12-15 + * @brief MNODE module show tests + * @version 1.0 + * @date 2022-01-06 * - * @copyright Copyright (c) 2021 + * @copyright Copyright (c) 2022 * */ #include "sut.h" -class DndTestShow : public ::testing::Test { +class MndTestShow : public ::testing::Test { protected: - static void SetUpTestSuite() { test.Init("/tmp/dnode_test_show", 9091); } + static void SetUpTestSuite() { test.Init("/tmp/mnode_test_show", 9020); } static void TearDownTestSuite() { test.Cleanup(); } static Testbase test; @@ -23,9 +23,9 @@ class DndTestShow : public ::testing::Test { void TearDown() override {} }; -Testbase DndTestShow::test; +Testbase MndTestShow::test; -TEST_F(DndTestShow, 01_ShowMsg_InvalidMsgMax) { +TEST_F(MndTestShow, 01_ShowMsg_InvalidMsgMax) { int32_t contLen = sizeof(SShowMsg); SShowMsg* pReq = (SShowMsg*)rpcMallocCont(contLen); @@ -37,7 +37,7 @@ TEST_F(DndTestShow, 01_ShowMsg_InvalidMsgMax) { ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_MSG_TYPE); } -TEST_F(DndTestShow, 02_ShowMsg_InvalidMsgStart) { +TEST_F(MndTestShow, 02_ShowMsg_InvalidMsgStart) { int32_t contLen = sizeof(SShowMsg); SShowMsg* pReq = (SShowMsg*)rpcMallocCont(sizeof(SShowMsg)); @@ -49,12 +49,12 @@ TEST_F(DndTestShow, 02_ShowMsg_InvalidMsgStart) { ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_MSG_TYPE); } -TEST_F(DndTestShow, 02_ShowMsg_Conn) { +TEST_F(MndTestShow, 03_ShowMsg_Conn) { int32_t contLen = sizeof(SConnectMsg); SConnectMsg* pReq = (SConnectMsg*)rpcMallocCont(contLen); pReq->pid = htonl(1234); - strcpy(pReq->app, "dnode_test_show"); + strcpy(pReq->app, "mnode_test_show"); strcpy(pReq->db, ""); SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CONNECT, pReq, contLen); @@ -85,3 +85,18 @@ TEST_F(DndTestShow, 02_ShowMsg_Conn) { EXPECT_EQ(pRetrieveRsp->compressed, 0); EXPECT_EQ(pRetrieveRsp->compLen, 0); } + +TEST_F(MndTestShow, 04_ShowMsg_Cluster) { + test.SendShowMetaMsg(TSDB_MGMT_TABLE_CLUSTER, ""); + CHECK_META( "show cluster", 3); + CHECK_SCHEMA(0, TSDB_DATA_TYPE_BIGINT, 8, "id"); + CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_CLUSTER_ID_LEN + VARSTR_HEADER_SIZE, "name"); + CHECK_SCHEMA(2, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); + + test.SendShowRetrieveMsg(); + EXPECT_EQ(test.GetShowRows(), 1); + + IgnoreInt64(); + IgnoreBinary(TSDB_CLUSTER_ID_LEN); + CheckTimestamp(); +} \ No newline at end of file From 11d6b02aa4fb0c2097c7b17b7986c5d3305d03ac Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 5 Jan 2022 02:35:34 -0800 Subject: [PATCH 04/18] minor changes --- source/dnode/mnode/impl/src/mndAuth.c | 1 - source/dnode/mnode/impl/src/mndCluster.c | 1 - source/dnode/mnode/impl/src/mndShow.c | 22 +++++++++++----------- source/dnode/mnode/impl/src/mndUser.c | 1 - 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndAuth.c b/source/dnode/mnode/impl/src/mndAuth.c index bcefbfde21..a2fc7a57b3 100644 --- a/source/dnode/mnode/impl/src/mndAuth.c +++ b/source/dnode/mnode/impl/src/mndAuth.c @@ -14,7 +14,6 @@ */ #define _DEFAULT_SOURCE -#include "os.h" #include "mndAuth.h" int32_t mndInitAuth(SMnode *pMnode) { return 0; } diff --git a/source/dnode/mnode/impl/src/mndCluster.c b/source/dnode/mnode/impl/src/mndCluster.c index b29f8276fe..8cb98a148f 100644 --- a/source/dnode/mnode/impl/src/mndCluster.c +++ b/source/dnode/mnode/impl/src/mndCluster.c @@ -16,7 +16,6 @@ #define _DEFAULT_SOURCE #include "mndCluster.h" #include "mndShow.h" -#include "mndTrans.h" #define TSDB_CLUSTER_VER_NUMBE 1 #define TSDB_CLUSTER_RESERVE_SIZE 64 diff --git a/source/dnode/mnode/impl/src/mndShow.c b/source/dnode/mnode/impl/src/mndShow.c index 125c250614..81e15497bf 100644 --- a/source/dnode/mnode/impl/src/mndShow.c +++ b/source/dnode/mnode/impl/src/mndShow.c @@ -22,8 +22,8 @@ static SShowObj *mndCreateShowObj(SMnode *pMnode, SShowMsg *pMsg); static void mndFreeShowObj(SShowObj *pShow); static SShowObj *mndAcquireShowObj(SMnode *pMnode, int64_t showId); static void mndReleaseShowObj(SShowObj *pShow, bool forceRemove); -static int32_t mndProcessShowMsg(SMnodeMsg *pMnodeMsg); -static int32_t mndProcessRetrieveMsg(SMnodeMsg *pMsg); +static int32_t mndProcessShowReq(SMnodeMsg *pMsg); +static int32_t mndProcessRetrieveReq(SMnodeMsg *pMsg); static bool mndCheckRetrieveFinished(SShowObj *pShow); int32_t mndInitShow(SMnode *pMnode) { @@ -36,8 +36,8 @@ int32_t mndInitShow(SMnode *pMnode) { return -1; } - mndSetMsgHandle(pMnode, TDMT_MND_SHOW, mndProcessShowMsg); - mndSetMsgHandle(pMnode, TDMT_MND_SHOW_RETRIEVE, mndProcessRetrieveMsg); + mndSetMsgHandle(pMnode, TDMT_MND_SHOW, mndProcessShowReq); + mndSetMsgHandle(pMnode, TDMT_MND_SHOW_RETRIEVE, mndProcessRetrieveReq); return 0; } @@ -115,7 +115,7 @@ static void mndReleaseShowObj(SShowObj *pShow, bool forceRemove) { taosCacheRelease(pMgmt->cache, (void **)(&pShow), forceRemove); } -static int32_t mndProcessShowMsg(SMnodeMsg *pMnodeMsg) { +static int32_t mndProcessShowReq(SMnodeMsg *pMnodeMsg) { SMnode *pMnode = pMnodeMsg->pMnode; SShowMgmt *pMgmt = &pMnode->showMgmt; SShowMsg *pMsg = pMnodeMsg->rpcMsg.pCont; @@ -168,14 +168,14 @@ static int32_t mndProcessShowMsg(SMnodeMsg *pMnodeMsg) { } } -static int32_t mndProcessRetrieveMsg(SMnodeMsg *pMnodeMsg) { - SMnode *pMnode = pMnodeMsg->pMnode; +static int32_t mndProcessRetrieveReq(SMnodeMsg *pMsg) { + SMnode *pMnode = pMsg->pMnode; SShowMgmt *pMgmt = &pMnode->showMgmt; int32_t rowsToRead = 0; int32_t size = 0; int32_t rowsRead = 0; - SRetrieveTableMsg *pRetrieve = pMnodeMsg->rpcMsg.pCont; + SRetrieveTableMsg *pRetrieve = pMsg->rpcMsg.pCont; int64_t showId = htobe64(pRetrieve->showId); SShowObj *pShow = mndAcquireShowObj(pMnode, showId); @@ -227,7 +227,7 @@ static int32_t mndProcessRetrieveMsg(SMnodeMsg *pMnodeMsg) { // if free flag is set, client wants to clean the resources if ((pRetrieve->free & TSDB_QUERY_TYPE_FREE_RESOURCE) != TSDB_QUERY_TYPE_FREE_RESOURCE) { - rowsRead = (*retrieveFp)(pMnodeMsg, pShow, pRsp->data, rowsToRead); + rowsRead = (*retrieveFp)(pMsg, pShow, pRsp->data, rowsToRead); } mDebug("show:0x%" PRIx64 ", stop retrieve data, rowsRead:%d rowsToRead:%d", pShow->id, rowsRead, rowsToRead); @@ -235,8 +235,8 @@ static int32_t mndProcessRetrieveMsg(SMnodeMsg *pMnodeMsg) { pRsp->numOfRows = htonl(rowsRead); pRsp->precision = TSDB_TIME_PRECISION_MILLI; // millisecond time precision - pMnodeMsg->pCont = pRsp; - pMnodeMsg->contLen = size; + pMsg->pCont = pRsp; + pMsg->contLen = size; if (rowsRead == 0 || rowsToRead == 0 || (rowsRead == rowsToRead && pShow->numOfRows == pShow->numOfReads)) { pRsp->completed = 1; diff --git a/source/dnode/mnode/impl/src/mndUser.c b/source/dnode/mnode/impl/src/mndUser.c index 3ffb979ed1..0891cf43b3 100644 --- a/source/dnode/mnode/impl/src/mndUser.c +++ b/source/dnode/mnode/impl/src/mndUser.c @@ -16,7 +16,6 @@ #define _DEFAULT_SOURCE #include "mndUser.h" #include "mndShow.h" -#include "mndSync.h" #include "mndTrans.h" #include "tkey.h" From ad94dff047eaba6671d4c652daab285ca6e78704 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 5 Jan 2022 04:18:56 -0800 Subject: [PATCH 05/18] mionr changes --- include/common/tmsg.h | 4 +- source/client/src/clientMsgHandler.c | 4 +- source/dnode/mgmt/impl/test/bnode/dbnode.cpp | 54 ++++---- source/dnode/mgmt/impl/test/db/db.cpp | 54 ++++---- source/dnode/mgmt/impl/test/dnode/dnode.cpp | 56 ++++----- source/dnode/mgmt/impl/test/mnode/mnode.cpp | 82 ++++++------ .../dnode/mgmt/impl/test/profile/profile.cpp | 58 ++++----- source/dnode/mgmt/impl/test/qnode/dqnode.cpp | 54 ++++---- source/dnode/mgmt/impl/test/snode/dsnode.cpp | 54 ++++---- source/dnode/mgmt/impl/test/stb/stb.cpp | 32 ++--- source/dnode/mgmt/impl/test/sut/inc/client.h | 2 +- source/dnode/mgmt/impl/test/sut/inc/sut.h | 6 +- .../dnode/mgmt/impl/test/sut/src/client.cpp | 10 +- source/dnode/mgmt/impl/test/sut/src/sut.cpp | 24 ++-- source/dnode/mgmt/impl/test/vgroup/vgroup.cpp | 18 +-- source/dnode/mnode/impl/src/mndAcct.c | 12 +- source/dnode/mnode/impl/src/mndBnode.c | 82 ++++++------ source/dnode/mnode/impl/src/mndQnode.c | 82 ++++++------ source/dnode/mnode/impl/src/mndShow.c | 48 +++---- source/dnode/mnode/impl/src/mndSnode.c | 82 ++++++------ source/dnode/mnode/impl/src/mndUser.c | 62 ++++----- source/dnode/mnode/impl/test/acct/acct.cpp | 28 ++--- source/dnode/mnode/impl/test/bnode/bnode.cpp | 110 ++++++++-------- source/dnode/mnode/impl/test/qnode/qnode.cpp | 110 ++++++++-------- source/dnode/mnode/impl/test/show/show.cpp | 34 ++--- source/dnode/mnode/impl/test/snode/snode.cpp | 110 ++++++++-------- source/dnode/mnode/impl/test/trans/trans.cpp | 16 +-- source/dnode/mnode/impl/test/user/user.cpp | 118 +++++++++--------- source/libs/parser/inc/astToMsg.h | 2 +- source/libs/parser/src/astToMsg.c | 4 +- source/libs/parser/src/dCDAstProcess.c | 2 +- src/client/src/tscServer.c | 18 +-- 32 files changed, 716 insertions(+), 716 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 1b2b6a677a..cd8fe7b0d2 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -506,7 +506,7 @@ typedef struct { int64_t qId; }; // query handle int8_t free; -} SRetrieveTableMsg; +} SRetrieveTableReq; typedef struct SRetrieveTableRsp { int64_t useconds; @@ -808,7 +808,7 @@ typedef struct { char db[TSDB_DB_FNAME_LEN]; int16_t payloadLen; char payload[]; -} SShowMsg; +} SShowReq; typedef struct { char db[TSDB_DB_FNAME_LEN]; diff --git a/source/client/src/clientMsgHandler.c b/source/client/src/clientMsgHandler.c index e402403496..1d74de9ab3 100644 --- a/source/client/src/clientMsgHandler.c +++ b/source/client/src/clientMsgHandler.c @@ -87,14 +87,14 @@ SMsgSendInfo* buildMsgInfoImpl(SRequestObj *pRequest) { if (pRequest->type == TDMT_MND_SHOW_RETRIEVE || pRequest->type == TDMT_VND_SHOW_TABLES_FETCH) { if (pRequest->type == TDMT_MND_SHOW_RETRIEVE) { - SRetrieveTableMsg* pRetrieveMsg = calloc(1, sizeof(SRetrieveTableMsg)); + SRetrieveTableReq* pRetrieveMsg = calloc(1, sizeof(SRetrieveTableReq)); if (pRetrieveMsg == NULL) { return NULL; } pRetrieveMsg->showId = htobe64(pRequest->body.showInfo.execId); pMsgSendInfo->msgInfo.pData = pRetrieveMsg; - pMsgSendInfo->msgInfo.len = sizeof(SRetrieveTableMsg); + pMsgSendInfo->msgInfo.len = sizeof(SRetrieveTableReq); } else { SVShowTablesFetchReq* pFetchMsg = calloc(1, sizeof(SVShowTablesFetchReq)); if (pFetchMsg == NULL) { diff --git a/source/dnode/mgmt/impl/test/bnode/dbnode.cpp b/source/dnode/mgmt/impl/test/bnode/dbnode.cpp index dd8c13c4bd..bafe8242a6 100644 --- a/source/dnode/mgmt/impl/test/bnode/dbnode.cpp +++ b/source/dnode/mgmt/impl/test/bnode/dbnode.cpp @@ -32,9 +32,9 @@ TEST_F(DndTestBnode, 01_Create_Bnode) { SDCreateBnodeReq* pReq = (SDCreateBnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_BNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_DND_BNODE_ID_INVALID); + SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_BNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_DND_BNODE_ID_INVALID); } { @@ -43,9 +43,9 @@ TEST_F(DndTestBnode, 01_Create_Bnode) { SDCreateBnodeReq* pReq = (SDCreateBnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(1); - SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_BNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_BNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } { @@ -54,9 +54,9 @@ TEST_F(DndTestBnode, 01_Create_Bnode) { SDCreateBnodeReq* pReq = (SDCreateBnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(1); - SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_BNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_DND_BNODE_ALREADY_DEPLOYED); + SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_BNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_DND_BNODE_ALREADY_DEPLOYED); } test.Restart(); @@ -67,9 +67,9 @@ TEST_F(DndTestBnode, 01_Create_Bnode) { SDCreateBnodeReq* pReq = (SDCreateBnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(1); - SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_BNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_DND_BNODE_ALREADY_DEPLOYED); + SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_BNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_DND_BNODE_ALREADY_DEPLOYED); } } @@ -80,9 +80,9 @@ TEST_F(DndTestBnode, 01_Drop_Bnode) { SDDropBnodeReq* pReq = (SDDropBnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - SRpcMsg* pMsg = test.SendMsg(TDMT_DND_DROP_BNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_DND_BNODE_ID_INVALID); + SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_BNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_DND_BNODE_ID_INVALID); } { @@ -91,9 +91,9 @@ TEST_F(DndTestBnode, 01_Drop_Bnode) { SDDropBnodeReq* pReq = (SDDropBnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(1); - SRpcMsg* pMsg = test.SendMsg(TDMT_DND_DROP_BNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_BNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } { @@ -102,9 +102,9 @@ TEST_F(DndTestBnode, 01_Drop_Bnode) { SDDropBnodeReq* pReq = (SDDropBnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(1); - SRpcMsg* pMsg = test.SendMsg(TDMT_DND_DROP_BNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_DND_BNODE_NOT_DEPLOYED); + SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_BNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_DND_BNODE_NOT_DEPLOYED); } test.Restart(); @@ -115,9 +115,9 @@ TEST_F(DndTestBnode, 01_Drop_Bnode) { SDDropBnodeReq* pReq = (SDDropBnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(1); - SRpcMsg* pMsg = test.SendMsg(TDMT_DND_DROP_BNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_DND_BNODE_NOT_DEPLOYED); + SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_BNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_DND_BNODE_NOT_DEPLOYED); } { @@ -126,8 +126,8 @@ TEST_F(DndTestBnode, 01_Drop_Bnode) { SDCreateBnodeReq* pReq = (SDCreateBnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(1); - SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_BNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_BNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } } \ No newline at end of file diff --git a/source/dnode/mgmt/impl/test/db/db.cpp b/source/dnode/mgmt/impl/test/db/db.cpp index a78b8388c6..3a69ae2305 100644 --- a/source/dnode/mgmt/impl/test/db/db.cpp +++ b/source/dnode/mgmt/impl/test/db/db.cpp @@ -26,7 +26,7 @@ class DndTestDb : public ::testing::Test { Testbase DndTestDb::test; TEST_F(DndTestDb, 01_ShowDb) { - test.SendShowMetaMsg(TSDB_MGMT_TABLE_DB, ""); + test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, ""); CHECK_META("show databases", 18); CHECK_SCHEMA(0, TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN - 1 + VARSTR_HEADER_SIZE, "name"); CHECK_SCHEMA(1, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); @@ -47,7 +47,7 @@ TEST_F(DndTestDb, 01_ShowDb) { CHECK_SCHEMA(16, TSDB_DATA_TYPE_BINARY, 3 + VARSTR_HEADER_SIZE, "precision"); CHECK_SCHEMA(17, TSDB_DATA_TYPE_TINYINT, 1, "update"); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 0); } @@ -77,15 +77,15 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) { pReq->cacheLastRow = 0; pReq->ignoreExist = 1; - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DB, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } - test.SendShowMetaMsg(TSDB_MGMT_TABLE_DB, ""); + test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, ""); CHECK_META("show databases", 18); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 1); CheckBinary("d1", TSDB_DB_NAME_LEN - 1); CheckTimestamp(); @@ -106,14 +106,14 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) { CheckBinary("ms", 3); // precision CheckInt8(0); // update - test.SendShowMetaMsg(TSDB_MGMT_TABLE_VGROUP, "1.d1"); + test.SendShowMetaReq(TSDB_MGMT_TABLE_VGROUP, "1.d1"); CHECK_META("show vgroups", 4); CHECK_SCHEMA(0, TSDB_DATA_TYPE_INT, 4, "vgId"); CHECK_SCHEMA(1, TSDB_DATA_TYPE_INT, 4, "tables"); CHECK_SCHEMA(2, TSDB_DATA_TYPE_SMALLINT, 2, "v1_dnode"); CHECK_SCHEMA(3, TSDB_DATA_TYPE_BINARY, 9 + VARSTR_HEADER_SIZE, "v1_status"); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 2); CheckInt32(2); CheckInt32(3); @@ -138,13 +138,13 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) { pReq->quorum = 2; pReq->cacheLastRow = 1; - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_ALTER_DB, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_DB, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } - test.SendShowMetaMsg(TSDB_MGMT_TABLE_DB, ""); - test.SendShowRetrieveMsg(); + test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, ""); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 1); CheckBinary("d1", TSDB_DB_NAME_LEN - 1); CheckTimestamp(); @@ -168,10 +168,10 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) { // restart test.Restart(); - test.SendShowMetaMsg(TSDB_MGMT_TABLE_DB, ""); + test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, ""); CHECK_META("show databases", 18); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 1); CheckBinary("d1", TSDB_DB_NAME_LEN - 1); @@ -199,15 +199,15 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) { SDropDbMsg* pReq = (SDropDbMsg*)rpcMallocCont(contLen); strcpy(pReq->db, "1.d1"); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_DB, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DB, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } - test.SendShowMetaMsg(TSDB_MGMT_TABLE_DB, ""); + test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, ""); CHECK_META("show databases", 18); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 0); } @@ -237,15 +237,15 @@ TEST_F(DndTestDb, 03_Create_Use_Restart_Use_Db) { pReq->cacheLastRow = 0; pReq->ignoreExist = 1; - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DB, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } - test.SendShowMetaMsg(TSDB_MGMT_TABLE_DB, ""); + test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, ""); CHECK_META("show databases", 18); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 1); CheckBinary("d2", TSDB_DB_NAME_LEN - 1); @@ -256,7 +256,7 @@ TEST_F(DndTestDb, 03_Create_Use_Restart_Use_Db) { strcpy(pReq->db, "1.d2"); pReq->vgVersion = htonl(-1); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_USE_DB, pReq, contLen); + SRpcMsg* pMsg = test.SendReq(TDMT_MND_USE_DB, pReq, contLen); ASSERT_NE(pMsg, nullptr); ASSERT_EQ(pMsg->code, 0); diff --git a/source/dnode/mgmt/impl/test/dnode/dnode.cpp b/source/dnode/mgmt/impl/test/dnode/dnode.cpp index 9041098d71..51af008fc3 100644 --- a/source/dnode/mgmt/impl/test/dnode/dnode.cpp +++ b/source/dnode/mgmt/impl/test/dnode/dnode.cpp @@ -51,7 +51,7 @@ TestServer DndTestDnode::server4; TestServer DndTestDnode::server5; TEST_F(DndTestDnode, 01_ShowDnode) { - test.SendShowMetaMsg(TSDB_MGMT_TABLE_DNODE, ""); + test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, ""); CHECK_META("show dnodes", 7); CHECK_SCHEMA(0, TSDB_DATA_TYPE_SMALLINT, 2, "id"); @@ -62,7 +62,7 @@ TEST_F(DndTestDnode, 01_ShowDnode) { CHECK_SCHEMA(5, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); CHECK_SCHEMA(6, TSDB_DATA_TYPE_BINARY, 24 + VARSTR_HEADER_SIZE, "offline_reason"); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 1); CheckInt16(1); @@ -81,9 +81,9 @@ TEST_F(DndTestDnode, 02_ConfigDnode) { pReq->dnodeId = htonl(1); strcpy(pReq->config, "ddebugflag 131"); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CONFIG_DNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CONFIG_DNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) { @@ -94,16 +94,16 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) { strcpy(pReq->fqdn, "localhost"); pReq->port = htonl(9042); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } taosMsleep(1300); - test.SendShowMetaMsg(TSDB_MGMT_TABLE_DNODE, ""); + test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, ""); CHECK_META("show dnodes", 7); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 2); CheckInt16(1); @@ -127,14 +127,14 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) { SDropDnodeMsg* pReq = (SDropDnodeMsg*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_DNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } - test.SendShowMetaMsg(TSDB_MGMT_TABLE_DNODE, ""); + test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, ""); CHECK_META("show dnodes", 7); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 1); CheckInt16(1); @@ -152,9 +152,9 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) { strcpy(pReq->fqdn, "localhost"); pReq->port = htonl(9043); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } { @@ -164,9 +164,9 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) { strcpy(pReq->fqdn, "localhost"); pReq->port = htonl(9044); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } { @@ -176,15 +176,15 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) { strcpy(pReq->fqdn, "localhost"); pReq->port = htonl(9045); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } taosMsleep(1300); - test.SendShowMetaMsg(TSDB_MGMT_TABLE_DNODE, ""); + test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, ""); CHECK_META("show dnodes", 7); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 4); CheckInt16(1); @@ -225,9 +225,9 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) { server5.Restart(); taosMsleep(1300); - test.SendShowMetaMsg(TSDB_MGMT_TABLE_DNODE, ""); + test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, ""); CHECK_META("show dnodes", 7); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 4); CheckInt16(1); diff --git a/source/dnode/mgmt/impl/test/mnode/mnode.cpp b/source/dnode/mgmt/impl/test/mnode/mnode.cpp index 3d4844c3f6..9a725c20d3 100644 --- a/source/dnode/mgmt/impl/test/mnode/mnode.cpp +++ b/source/dnode/mgmt/impl/test/mnode/mnode.cpp @@ -51,7 +51,7 @@ TestServer DndTestMnode::server4; TestServer DndTestMnode::server5; TEST_F(DndTestMnode, 01_ShowDnode) { - test.SendShowMetaMsg(TSDB_MGMT_TABLE_MNODE, ""); + test.SendShowMetaReq(TSDB_MGMT_TABLE_MNODE, ""); CHECK_META("show mnodes", 5); CHECK_SCHEMA(0, TSDB_DATA_TYPE_SMALLINT, 2, "id"); @@ -60,7 +60,7 @@ TEST_F(DndTestMnode, 01_ShowDnode) { CHECK_SCHEMA(3, TSDB_DATA_TYPE_TIMESTAMP, 8, "role_time"); CHECK_SCHEMA(4, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 1); CheckInt16(1); @@ -77,9 +77,9 @@ TEST_F(DndTestMnode, 02_Create_Mnode_Invalid_Id) { SMCreateMnodeMsg* pReq = (SMCreateMnodeMsg*)rpcMallocCont(contLen); pReq->dnodeId = htonl(1); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_MNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_MND_MNODE_ALREADY_EXIST); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_MNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_MNODE_ALREADY_EXIST); } } @@ -90,9 +90,9 @@ TEST_F(DndTestMnode, 03_Create_Mnode_Invalid_Id) { SMCreateMnodeMsg* pReq = (SMCreateMnodeMsg*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_MNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_MND_DNODE_NOT_EXIST); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_MNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_DNODE_NOT_EXIST); } } @@ -105,13 +105,13 @@ TEST_F(DndTestMnode, 04_Create_Mnode) { strcpy(pReq->fqdn, "localhost"); pReq->port = htonl(9062); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); taosMsleep(1300); - test.SendShowMetaMsg(TSDB_MGMT_TABLE_DNODE, ""); - test.SendShowRetrieveMsg(); + test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, ""); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 2); } @@ -122,12 +122,12 @@ TEST_F(DndTestMnode, 04_Create_Mnode) { SMCreateMnodeMsg* pReq = (SMCreateMnodeMsg*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_MNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_MNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaMsg(TSDB_MGMT_TABLE_MNODE, ""); - test.SendShowRetrieveMsg(); + test.SendShowMetaReq(TSDB_MGMT_TABLE_MNODE, ""); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 2); CheckInt16(1); @@ -149,12 +149,12 @@ TEST_F(DndTestMnode, 04_Create_Mnode) { SMDropMnodeMsg* pReq = (SMDropMnodeMsg*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_MNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_MNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaMsg(TSDB_MGMT_TABLE_MNODE, ""); - test.SendShowRetrieveMsg(); + test.SendShowMetaReq(TSDB_MGMT_TABLE_MNODE, ""); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 1); CheckInt16(1); @@ -170,14 +170,14 @@ TEST_F(DndTestMnode, 04_Create_Mnode) { // SDropDnodeMsg* pReq = (SDropDnodeMsg*)rpcMallocCont(contLen); // pReq->dnodeId = htonl(2); -// SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_DNODE, pReq, contLen); -// ASSERT_NE(pMsg, nullptr); -// ASSERT_EQ(pMsg->code, 0); +// SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DNODE, pReq, contLen); +// ASSERT_NE(pRsp, nullptr); +// ASSERT_EQ(pRsp->code, 0); // } -// test.SendShowMetaMsg(TSDB_MGMT_TABLE_DNODE, ""); +// test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, ""); // CHECK_META("show dnodes", 7); -// test.SendShowRetrieveMsg(); +// test.SendShowRetrieveReq(); // EXPECT_EQ(test.GetShowRows(), 1); // CheckInt16(1); @@ -194,9 +194,9 @@ TEST_F(DndTestMnode, 04_Create_Mnode) { // SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen); // strcpy(pReq->ep, "localhost:9063"); -// SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen); -// ASSERT_NE(pMsg, nullptr); -// ASSERT_EQ(pMsg->code, 0); +// SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen); +// ASSERT_NE(pRsp, nullptr); +// ASSERT_EQ(pRsp->code, 0); // } // { @@ -205,9 +205,9 @@ TEST_F(DndTestMnode, 04_Create_Mnode) { // SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen); // strcpy(pReq->ep, "localhost:9064"); -// SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen); -// ASSERT_NE(pMsg, nullptr); -// ASSERT_EQ(pMsg->code, 0); +// SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen); +// ASSERT_NE(pRsp, nullptr); +// ASSERT_EQ(pRsp->code, 0); // } // { @@ -216,15 +216,15 @@ TEST_F(DndTestMnode, 04_Create_Mnode) { // SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen); // strcpy(pReq->ep, "localhost:9065"); -// SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen); -// ASSERT_NE(pMsg, nullptr); -// ASSERT_EQ(pMsg->code, 0); +// SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen); +// ASSERT_NE(pRsp, nullptr); +// ASSERT_EQ(pRsp->code, 0); // } // taosMsleep(1300); -// test.SendShowMetaMsg(TSDB_MGMT_TABLE_DNODE, ""); +// test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, ""); // CHECK_META("show dnodes", 7); -// test.SendShowRetrieveMsg(); +// test.SendShowRetrieveReq(); // EXPECT_EQ(test.GetShowRows(), 4); // CheckInt16(1); @@ -265,9 +265,9 @@ TEST_F(DndTestMnode, 04_Create_Mnode) { // server5.Restart(); // taosMsleep(1300); -// test.SendShowMetaMsg(TSDB_MGMT_TABLE_DNODE, ""); +// test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, ""); // CHECK_META("show dnodes", 7); -// test.SendShowRetrieveMsg(); +// test.SendShowRetrieveReq(); // EXPECT_EQ(test.GetShowRows(), 4); // CheckInt16(1); diff --git a/source/dnode/mgmt/impl/test/profile/profile.cpp b/source/dnode/mgmt/impl/test/profile/profile.cpp index b705a94af6..29b71f1c27 100644 --- a/source/dnode/mgmt/impl/test/profile/profile.cpp +++ b/source/dnode/mgmt/impl/test/profile/profile.cpp @@ -35,7 +35,7 @@ TEST_F(DndTestProfile, 01_ConnectMsg) { strcpy(pReq->app, "dnode_test_profile"); strcpy(pReq->db, ""); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CONNECT, pReq, contLen); + SRpcMsg* pMsg = test.SendReq(TDMT_MND_CONNECT, pReq, contLen); ASSERT_NE(pMsg, nullptr); ASSERT_EQ(pMsg->code, 0); @@ -67,14 +67,14 @@ TEST_F(DndTestProfile, 02_ConnectMsg_InvalidDB) { strcpy(pReq->app, "dnode_test_profile"); strcpy(pReq->db, "invalid_db"); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CONNECT, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_DB); - ASSERT_EQ(pMsg->contLen, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CONNECT, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_DB); + ASSERT_EQ(pRsp->contLen, 0); } TEST_F(DndTestProfile, 03_ConnectMsg_Show) { - test.SendShowMetaMsg(TSDB_MGMT_TABLE_CONNS, ""); + test.SendShowMetaReq(TSDB_MGMT_TABLE_CONNS, ""); CHECK_META("show connections", 7); CHECK_SCHEMA(0, TSDB_DATA_TYPE_INT, 4, "connId"); CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN + VARSTR_HEADER_SIZE, "user"); @@ -84,7 +84,7 @@ TEST_F(DndTestProfile, 03_ConnectMsg_Show) { CHECK_SCHEMA(5, TSDB_DATA_TYPE_TIMESTAMP, 8, "login_time"); CHECK_SCHEMA(6, TSDB_DATA_TYPE_TIMESTAMP, 8, "last_access"); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 1); CheckInt32(1); CheckBinary("root", TSDB_USER_LEN); @@ -105,7 +105,7 @@ TEST_F(DndTestProfile, 04_HeartBeatMsg) { pReq->numOfStreams = htonl(0); strcpy(pReq->app, "dnode_test_profile"); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_HEARTBEAT, pReq, contLen); + SRpcMsg* pMsg = test.SendReq(TDMT_MND_HEARTBEAT, pReq, contLen); ASSERT_NE(pMsg, nullptr); ASSERT_EQ(pMsg->code, 0); @@ -138,9 +138,9 @@ TEST_F(DndTestProfile, 05_KillConnMsg) { SKillConnMsg* pReq = (SKillConnMsg*)rpcMallocCont(contLen); pReq->connId = htonl(connId); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_KILL_CONN, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_KILL_CONN, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } { @@ -153,10 +153,10 @@ TEST_F(DndTestProfile, 05_KillConnMsg) { pReq->numOfStreams = htonl(0); strcpy(pReq->app, "dnode_test_profile"); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_HEARTBEAT, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_CONNECTION); - ASSERT_EQ(pMsg->contLen, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_HEARTBEAT, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_CONNECTION); + ASSERT_EQ(pRsp->contLen, 0); } { @@ -167,7 +167,7 @@ TEST_F(DndTestProfile, 05_KillConnMsg) { strcpy(pReq->app, "dnode_test_profile"); strcpy(pReq->db, ""); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CONNECT, pReq, contLen); + SRpcMsg* pMsg = test.SendReq(TDMT_MND_CONNECT, pReq, contLen); ASSERT_NE(pMsg, nullptr); ASSERT_EQ(pMsg->code, 0); @@ -198,9 +198,9 @@ TEST_F(DndTestProfile, 06_KillConnMsg_InvalidConn) { SKillConnMsg* pReq = (SKillConnMsg*)rpcMallocCont(contLen); pReq->connId = htonl(2345); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_KILL_CONN, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_CONN_ID); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_KILL_CONN, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_CONN_ID); } TEST_F(DndTestProfile, 07_KillQueryMsg) { @@ -211,10 +211,10 @@ TEST_F(DndTestProfile, 07_KillQueryMsg) { pReq->connId = htonl(connId); pReq->queryId = htonl(1234); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_KILL_QUERY, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); - ASSERT_EQ(pMsg->contLen, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_KILL_QUERY, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); + ASSERT_EQ(pRsp->contLen, 0); } { @@ -227,7 +227,7 @@ TEST_F(DndTestProfile, 07_KillQueryMsg) { pReq->numOfStreams = htonl(0); strcpy(pReq->app, "dnode_test_profile"); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_HEARTBEAT, pReq, contLen); + SRpcMsg* pMsg = test.SendReq(TDMT_MND_HEARTBEAT, pReq, contLen); ASSERT_NE(pMsg, nullptr); ASSERT_EQ(pMsg->code, 0); @@ -261,13 +261,13 @@ TEST_F(DndTestProfile, 08_KillQueryMsg_InvalidConn) { pReq->connId = htonl(2345); pReq->queryId = htonl(1234); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_KILL_QUERY, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_CONN_ID); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_KILL_QUERY, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_CONN_ID); } TEST_F(DndTestProfile, 09_KillQueryMsg) { - test.SendShowMetaMsg(TSDB_MGMT_TABLE_QUERIES, ""); + test.SendShowMetaReq(TSDB_MGMT_TABLE_QUERIES, ""); CHECK_META("show queries", 14); CHECK_SCHEMA(0, TSDB_DATA_TYPE_INT, 4, "queryId"); @@ -285,6 +285,6 @@ TEST_F(DndTestProfile, 09_KillQueryMsg) { CHECK_SCHEMA(12, TSDB_DATA_TYPE_BINARY, TSDB_SHOW_SUBQUERY_LEN + VARSTR_HEADER_SIZE, "sub_query_info"); CHECK_SCHEMA(13, TSDB_DATA_TYPE_BINARY, TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, "sql"); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 0); } diff --git a/source/dnode/mgmt/impl/test/qnode/dqnode.cpp b/source/dnode/mgmt/impl/test/qnode/dqnode.cpp index 48de6e03eb..e609783eb0 100644 --- a/source/dnode/mgmt/impl/test/qnode/dqnode.cpp +++ b/source/dnode/mgmt/impl/test/qnode/dqnode.cpp @@ -32,9 +32,9 @@ TEST_F(DndTestQnode, 01_Create_Qnode) { SDCreateQnodeReq* pReq = (SDCreateQnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_QNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_DND_QNODE_ID_INVALID); + SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_QNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_DND_QNODE_ID_INVALID); } { @@ -43,9 +43,9 @@ TEST_F(DndTestQnode, 01_Create_Qnode) { SDCreateQnodeReq* pReq = (SDCreateQnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(1); - SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_QNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_QNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } { @@ -54,9 +54,9 @@ TEST_F(DndTestQnode, 01_Create_Qnode) { SDCreateQnodeReq* pReq = (SDCreateQnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(1); - SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_QNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED); + SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_QNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED); } test.Restart(); @@ -67,9 +67,9 @@ TEST_F(DndTestQnode, 01_Create_Qnode) { SDCreateQnodeReq* pReq = (SDCreateQnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(1); - SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_QNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED); + SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_QNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED); } } @@ -80,9 +80,9 @@ TEST_F(DndTestQnode, 01_Drop_Qnode) { SDDropQnodeReq* pReq = (SDDropQnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - SRpcMsg* pMsg = test.SendMsg(TDMT_DND_DROP_QNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_DND_QNODE_ID_INVALID); + SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_QNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_DND_QNODE_ID_INVALID); } { @@ -91,9 +91,9 @@ TEST_F(DndTestQnode, 01_Drop_Qnode) { SDDropQnodeReq* pReq = (SDDropQnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(1); - SRpcMsg* pMsg = test.SendMsg(TDMT_DND_DROP_QNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_QNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } { @@ -102,9 +102,9 @@ TEST_F(DndTestQnode, 01_Drop_Qnode) { SDDropQnodeReq* pReq = (SDDropQnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(1); - SRpcMsg* pMsg = test.SendMsg(TDMT_DND_DROP_QNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_DND_QNODE_NOT_DEPLOYED); + SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_QNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_DND_QNODE_NOT_DEPLOYED); } test.Restart(); @@ -115,9 +115,9 @@ TEST_F(DndTestQnode, 01_Drop_Qnode) { SDDropQnodeReq* pReq = (SDDropQnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(1); - SRpcMsg* pMsg = test.SendMsg(TDMT_DND_DROP_QNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_DND_QNODE_NOT_DEPLOYED); + SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_QNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_DND_QNODE_NOT_DEPLOYED); } { @@ -126,8 +126,8 @@ TEST_F(DndTestQnode, 01_Drop_Qnode) { SDCreateQnodeReq* pReq = (SDCreateQnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(1); - SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_QNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_QNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } } \ No newline at end of file diff --git a/source/dnode/mgmt/impl/test/snode/dsnode.cpp b/source/dnode/mgmt/impl/test/snode/dsnode.cpp index 2ec624b942..1e6bcdb3fb 100644 --- a/source/dnode/mgmt/impl/test/snode/dsnode.cpp +++ b/source/dnode/mgmt/impl/test/snode/dsnode.cpp @@ -32,9 +32,9 @@ TEST_F(DndTestSnode, 01_Create_Snode) { SDCreateSnodeReq* pReq = (SDCreateSnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_SNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_DND_SNODE_ID_INVALID); + SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_SNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_DND_SNODE_ID_INVALID); } { @@ -43,9 +43,9 @@ TEST_F(DndTestSnode, 01_Create_Snode) { SDCreateSnodeReq* pReq = (SDCreateSnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(1); - SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_SNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_SNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } { @@ -54,9 +54,9 @@ TEST_F(DndTestSnode, 01_Create_Snode) { SDCreateSnodeReq* pReq = (SDCreateSnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(1); - SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_SNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_DND_SNODE_ALREADY_DEPLOYED); + SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_SNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_DND_SNODE_ALREADY_DEPLOYED); } test.Restart(); @@ -67,9 +67,9 @@ TEST_F(DndTestSnode, 01_Create_Snode) { SDCreateSnodeReq* pReq = (SDCreateSnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(1); - SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_SNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_DND_SNODE_ALREADY_DEPLOYED); + SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_SNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_DND_SNODE_ALREADY_DEPLOYED); } } @@ -80,9 +80,9 @@ TEST_F(DndTestSnode, 01_Drop_Snode) { SDDropSnodeReq* pReq = (SDDropSnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - SRpcMsg* pMsg = test.SendMsg(TDMT_DND_DROP_SNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_DND_SNODE_ID_INVALID); + SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_SNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_DND_SNODE_ID_INVALID); } { @@ -91,9 +91,9 @@ TEST_F(DndTestSnode, 01_Drop_Snode) { SDDropSnodeReq* pReq = (SDDropSnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(1); - SRpcMsg* pMsg = test.SendMsg(TDMT_DND_DROP_SNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_SNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } { @@ -102,9 +102,9 @@ TEST_F(DndTestSnode, 01_Drop_Snode) { SDDropSnodeReq* pReq = (SDDropSnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(1); - SRpcMsg* pMsg = test.SendMsg(TDMT_DND_DROP_SNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_DND_SNODE_NOT_DEPLOYED); + SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_SNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_DND_SNODE_NOT_DEPLOYED); } test.Restart(); @@ -115,9 +115,9 @@ TEST_F(DndTestSnode, 01_Drop_Snode) { SDDropSnodeReq* pReq = (SDDropSnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(1); - SRpcMsg* pMsg = test.SendMsg(TDMT_DND_DROP_SNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_DND_SNODE_NOT_DEPLOYED); + SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_SNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_DND_SNODE_NOT_DEPLOYED); } { @@ -126,8 +126,8 @@ TEST_F(DndTestSnode, 01_Drop_Snode) { SDCreateSnodeReq* pReq = (SDCreateSnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(1); - SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_SNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_SNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } } \ No newline at end of file diff --git a/source/dnode/mgmt/impl/test/stb/stb.cpp b/source/dnode/mgmt/impl/test/stb/stb.cpp index 40af751e33..b3d5d29785 100644 --- a/source/dnode/mgmt/impl/test/stb/stb.cpp +++ b/source/dnode/mgmt/impl/test/stb/stb.cpp @@ -51,9 +51,9 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) { pReq->cacheLastRow = 0; pReq->ignoreExist = 1; - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DB, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } { @@ -101,12 +101,12 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) { strcpy(pSchema->name, "tag3"); } - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_STB, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_STB, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } - test.SendShowMetaMsg(TSDB_MGMT_TABLE_STB, "1.d1"); + test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, "1.d1"); CHECK_META("show stables", 4); CHECK_SCHEMA(0, TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE, "name"); @@ -114,7 +114,7 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) { CHECK_SCHEMA(2, TSDB_DATA_TYPE_INT, 4, "columns"); CHECK_SCHEMA(3, TSDB_DATA_TYPE_INT, 4, "tags"); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 1); CheckBinary("stb", TSDB_TABLE_NAME_LEN); CheckTimestamp(); @@ -128,7 +128,7 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) { STableInfoMsg* pReq = (STableInfoMsg*)rpcMallocCont(contLen); strcpy(pReq->tableFname, "1.d1.stb"); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_STB_META, pReq, contLen); + SRpcMsg* pMsg = test.SendReq(TDMT_MND_STB_META, pReq, contLen); ASSERT_NE(pMsg, nullptr); ASSERT_EQ(pMsg->code, 0); @@ -203,9 +203,9 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) { // restart test.Restart(); - test.SendShowMetaMsg(TSDB_MGMT_TABLE_STB, "1.d1"); + test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, "1.d1"); CHECK_META("show stables", 4); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 1); CheckBinary("stb", TSDB_TABLE_NAME_LEN); @@ -219,13 +219,13 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) { SDropStbMsg* pReq = (SDropStbMsg*)rpcMallocCont(contLen); strcpy(pReq->name, "1.d1.stb"); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_STB, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_STB, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } - test.SendShowMetaMsg(TSDB_MGMT_TABLE_STB, "1.d1"); + test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, "1.d1"); CHECK_META("show stables", 4); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 0); } diff --git a/source/dnode/mgmt/impl/test/sut/inc/client.h b/source/dnode/mgmt/impl/test/sut/inc/client.h index e1e430318e..9cf688fc02 100644 --- a/source/dnode/mgmt/impl/test/sut/inc/client.h +++ b/source/dnode/mgmt/impl/test/sut/inc/client.h @@ -21,7 +21,7 @@ class TestClient { bool Init(const char* user, const char* pass, const char* fqdn, uint16_t port); void Cleanup(); - SRpcMsg* SendMsg(SRpcMsg* pMsg); + SRpcMsg* SendReq(SRpcMsg* pReq); void SetRpcRsp(SRpcMsg* pRsp); tsem_t* GetSem(); diff --git a/source/dnode/mgmt/impl/test/sut/inc/sut.h b/source/dnode/mgmt/impl/test/sut/inc/sut.h index 24278a73f7..fd9c1cd93e 100644 --- a/source/dnode/mgmt/impl/test/sut/inc/sut.h +++ b/source/dnode/mgmt/impl/test/sut/inc/sut.h @@ -39,7 +39,7 @@ class Testbase { void Restart(); void ServerStop(); void ServerStart(); - SRpcMsg* SendMsg(tmsg_t msgType, void* pCont, int32_t contLen); + SRpcMsg* SendReq(tmsg_t msgType, void* pCont, int32_t contLen); private: void InitLog(const char* path); @@ -50,8 +50,8 @@ class Testbase { int32_t connId; public: - void SendShowMetaMsg(int8_t showType, const char* db); - void SendShowRetrieveMsg(); + void SendShowMetaReq(int8_t showType, const char* db); + void SendShowRetrieveReq(); STableMetaMsg* GetShowMeta(); SRetrieveTableRsp* GetRetrieveRsp(); diff --git a/source/dnode/mgmt/impl/test/sut/src/client.cpp b/source/dnode/mgmt/impl/test/sut/src/client.cpp index 086ba7bb0f..fd5dcd77d9 100644 --- a/source/dnode/mgmt/impl/test/sut/src/client.cpp +++ b/source/dnode/mgmt/impl/test/sut/src/client.cpp @@ -15,10 +15,10 @@ #include "sut.h" -static void processClientRsp(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) { +static void processClientRsp(void* parent, SRpcMsg* pRsp, SEpSet* pEpSet) { TestClient* client = (TestClient*)parent; - client->SetRpcRsp(pMsg); - uInfo("response:%s from dnode, code:0x%x", TMSG_INFO(pMsg->msgType), pMsg->code); + client->SetRpcRsp(pRsp); + uInfo("response:%s from dnode, code:0x%x", TMSG_INFO(pRsp->msgType), pRsp->code); tsem_post(client->GetSem()); } @@ -59,14 +59,14 @@ void TestClient::Cleanup() { rpcClose(clientRpc); } -SRpcMsg* TestClient::SendMsg(SRpcMsg* pMsg) { +SRpcMsg* TestClient::SendReq(SRpcMsg* pReq) { SEpSet epSet = {0}; epSet.inUse = 0; epSet.numOfEps = 1; epSet.port[0] = port; memcpy(epSet.fqdn[0], fqdn, TSDB_FQDN_LEN); - rpcSendRequest(clientRpc, &epSet, pMsg, NULL); + rpcSendRequest(clientRpc, &epSet, pReq, NULL); tsem_wait(&sem); return pRsp; diff --git a/source/dnode/mgmt/impl/test/sut/src/sut.cpp b/source/dnode/mgmt/impl/test/sut/src/sut.cpp index 46ced254c6..72a6416e22 100644 --- a/source/dnode/mgmt/impl/test/sut/src/sut.cpp +++ b/source/dnode/mgmt/impl/test/sut/src/sut.cpp @@ -64,23 +64,23 @@ void Testbase::ServerStop() { server.Stop(); } void Testbase::ServerStart() { server.DoStart(); } -SRpcMsg* Testbase::SendMsg(tmsg_t msgType, void* pCont, int32_t contLen) { +SRpcMsg* Testbase::SendReq(tmsg_t msgType, void* pCont, int32_t contLen) { SRpcMsg rpcMsg = {0}; rpcMsg.pCont = pCont; rpcMsg.contLen = contLen; rpcMsg.msgType = msgType; - return client.SendMsg(&rpcMsg); + return client.SendReq(&rpcMsg); } -void Testbase::SendShowMetaMsg(int8_t showType, const char* db) { - int32_t contLen = sizeof(SShowMsg); - SShowMsg* pShow = (SShowMsg*)rpcMallocCont(contLen); +void Testbase::SendShowMetaReq(int8_t showType, const char* db) { + int32_t contLen = sizeof(SShowReq); + SShowReq* pShow = (SShowReq*)rpcMallocCont(contLen); pShow->type = showType; strcpy(pShow->db, db); - SRpcMsg* pMsg = SendMsg(TDMT_MND_SHOW, pShow, contLen); - SShowRsp* pShowRsp = (SShowRsp*)pMsg->pCont; + SRpcMsg* pRsp = SendReq(TDMT_MND_SHOW, pShow, contLen); + SShowRsp* pShowRsp = (SShowRsp*)pRsp->pCont; ASSERT(pShowRsp != nullptr); pShowRsp->showId = htobe64(pShowRsp->showId); @@ -121,15 +121,15 @@ int32_t Testbase::GetMetaNum() { return pMeta->numOfColumns; } const char* Testbase::GetMetaTbName() { return pMeta->tbFname; } -void Testbase::SendShowRetrieveMsg() { - int32_t contLen = sizeof(SRetrieveTableMsg); +void Testbase::SendShowRetrieveReq() { + int32_t contLen = sizeof(SRetrieveTableReq); - SRetrieveTableMsg* pRetrieve = (SRetrieveTableMsg*)rpcMallocCont(contLen); + SRetrieveTableReq* pRetrieve = (SRetrieveTableReq*)rpcMallocCont(contLen); pRetrieve->showId = htobe64(showId); pRetrieve->free = 0; - SRpcMsg* pMsg = SendMsg(TDMT_MND_SHOW_RETRIEVE, pRetrieve, contLen); - pRetrieveRsp = (SRetrieveTableRsp*)pMsg->pCont; + SRpcMsg* pRsp = SendReq(TDMT_MND_SHOW_RETRIEVE, pRetrieve, contLen); + pRetrieveRsp = (SRetrieveTableRsp*)pRsp->pCont; pRetrieveRsp->numOfRows = htonl(pRetrieveRsp->numOfRows); pRetrieveRsp->useconds = htobe64(pRetrieveRsp->useconds); pRetrieveRsp->compLen = htonl(pRetrieveRsp->compLen); diff --git a/source/dnode/mgmt/impl/test/vgroup/vgroup.cpp b/source/dnode/mgmt/impl/test/vgroup/vgroup.cpp index 15a0c8087c..7fa3b4ab61 100644 --- a/source/dnode/mgmt/impl/test/vgroup/vgroup.cpp +++ b/source/dnode/mgmt/impl/test/vgroup/vgroup.cpp @@ -60,9 +60,9 @@ TEST_F(DndTestVgroup, 01_Create_Restart_Drop_Vnode) { pReplica->port = htons(9150); } - SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_VNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_VNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } } @@ -100,9 +100,9 @@ TEST_F(DndTestVgroup, 01_Create_Restart_Drop_Vnode) { pReplica->port = htons(9150); } - SRpcMsg* pMsg = test.SendMsg(TDMT_DND_ALTER_VNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_DND_ALTER_VNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } } @@ -121,9 +121,9 @@ TEST_F(DndTestVgroup, 01_Create_Restart_Drop_Vnode) { rpcMsg.contLen = sizeof(SDropVnodeMsg); rpcMsg.msgType = TDMT_DND_DROP_VNODE; - SRpcMsg* pMsg = test.SendMsg(TDMT_DND_DROP_VNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_VNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } } } diff --git a/source/dnode/mnode/impl/src/mndAcct.c b/source/dnode/mnode/impl/src/mndAcct.c index 0cf940b987..945a6523ef 100644 --- a/source/dnode/mnode/impl/src/mndAcct.c +++ b/source/dnode/mnode/impl/src/mndAcct.c @@ -26,9 +26,9 @@ static SSdbRow *mndAcctActionDecode(SSdbRaw *pRaw); static int32_t mndAcctActionInsert(SSdb *pSdb, SAcctObj *pAcct); static int32_t mndAcctActionDelete(SSdb *pSdb, SAcctObj *pAcct); static int32_t mndAcctActionUpdate(SSdb *pSdb, SAcctObj *pOld, SAcctObj *pNew); -static int32_t mndProcessCreateAcctReq(SMnodeMsg *pMsg); -static int32_t mndProcessAlterAcctReq(SMnodeMsg *pMsg); -static int32_t mndProcessDropAcctReq(SMnodeMsg *pMsg); +static int32_t mndProcessCreateAcctReq(SMnodeMsg *pReq); +static int32_t mndProcessAlterAcctReq(SMnodeMsg *pReq); +static int32_t mndProcessDropAcctReq(SMnodeMsg *pReq); int32_t mndInitAcct(SMnode *pMnode) { SSdbTable table = {.sdbType = SDB_ACCT, @@ -185,19 +185,19 @@ static int32_t mndAcctActionUpdate(SSdb *pSdb, SAcctObj *pOld, SAcctObj *pNew) { return 0; } -static int32_t mndProcessCreateAcctReq(SMnodeMsg *pMsg) { +static int32_t mndProcessCreateAcctReq(SMnodeMsg *pReq) { terrno = TSDB_CODE_MND_MSG_NOT_PROCESSED; mError("failed to process create acct request since %s", terrstr()); return -1; } -static int32_t mndProcessAlterAcctReq(SMnodeMsg *pMsg) { +static int32_t mndProcessAlterAcctReq(SMnodeMsg *pReq) { terrno = TSDB_CODE_MND_MSG_NOT_PROCESSED; mError("failed to process create acct request since %s", terrstr()); return -1; } -static int32_t mndProcessDropAcctReq(SMnodeMsg *pMsg) { +static int32_t mndProcessDropAcctReq(SMnodeMsg *pReq) { terrno = TSDB_CODE_MND_MSG_NOT_PROCESSED; mError("failed to process create acct request since %s", terrstr()); return -1; diff --git a/source/dnode/mnode/impl/src/mndBnode.c b/source/dnode/mnode/impl/src/mndBnode.c index 14d49213e9..6325bbb6fd 100644 --- a/source/dnode/mnode/impl/src/mndBnode.c +++ b/source/dnode/mnode/impl/src/mndBnode.c @@ -27,12 +27,12 @@ static SSdbRow *mndBnodeActionDecode(SSdbRaw *pRaw); static int32_t mndBnodeActionInsert(SSdb *pSdb, SBnodeObj *pObj); static int32_t mndBnodeActionDelete(SSdb *pSdb, SBnodeObj *pObj); static int32_t mndBnodeActionUpdate(SSdb *pSdb, SBnodeObj *pOld, SBnodeObj *pNew); -static int32_t mndProcessCreateBnodeReq(SMnodeMsg *pMsg); -static int32_t mndProcessDropBnodeReq(SMnodeMsg *pMsg); -static int32_t mndProcessCreateBnodeRsp(SMnodeMsg *pMsg); -static int32_t mndProcessDropBnodeRsp(SMnodeMsg *pMsg); -static int32_t mndGetBnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pMeta); -static int32_t mndRetrieveBnodes(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int32_t rows); +static int32_t mndProcessCreateBnodeReq(SMnodeMsg *pReq); +static int32_t mndProcessDropBnodeReq(SMnodeMsg *pReq); +static int32_t mndProcessCreateBnodeRsp(SMnodeMsg *pRsp); +static int32_t mndProcessDropBnodeRsp(SMnodeMsg *pRsp); +static int32_t mndGetBnodeMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaMsg *pMeta); +static int32_t mndRetrieveBnodes(SMnodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows); static void mndCancelGetNextBnode(SMnode *pMnode, void *pIter); int32_t mndInitBnode(SMnode *pMnode) { @@ -185,22 +185,22 @@ static int32_t mndSetCreateBnodeCommitLogs(STrans *pTrans, SBnodeObj *pObj) { } static int32_t mndSetCreateBnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SBnodeObj *pObj) { - SDCreateBnodeReq *pMsg = malloc(sizeof(SDCreateBnodeReq)); - if (pMsg == NULL) { + SDCreateBnodeReq *pReq = malloc(sizeof(SDCreateBnodeReq)); + if (pReq == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; } - pMsg->dnodeId = htonl(pDnode->id); + pReq->dnodeId = htonl(pDnode->id); STransAction action = {0}; action.epSet = mndGetDnodeEpset(pDnode); - action.pCont = pMsg; + action.pCont = pReq; action.contLen = sizeof(SDCreateBnodeReq); action.msgType = TDMT_DND_CREATE_BNODE; action.acceptableCode = TSDB_CODE_DND_BNODE_ALREADY_DEPLOYED; if (mndTransAppendRedoAction(pTrans, &action) != 0) { - free(pMsg); + free(pReq); return -1; } @@ -208,29 +208,29 @@ static int32_t mndSetCreateBnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S } static int32_t mndSetCreateBnodeUndoActions(STrans *pTrans, SDnodeObj *pDnode, SBnodeObj *pObj) { - SDDropBnodeReq *pMsg = malloc(sizeof(SDDropBnodeReq)); - if (pMsg == NULL) { + SDDropBnodeReq *pReq = malloc(sizeof(SDDropBnodeReq)); + if (pReq == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; } - pMsg->dnodeId = htonl(pDnode->id); + pReq->dnodeId = htonl(pDnode->id); STransAction action = {0}; action.epSet = mndGetDnodeEpset(pDnode); - action.pCont = pMsg; + action.pCont = pReq; action.contLen = sizeof(SDDropBnodeReq); action.msgType = TDMT_DND_DROP_BNODE; action.acceptableCode = TSDB_CODE_DND_BNODE_NOT_DEPLOYED; if (mndTransAppendUndoAction(pTrans, &action) != 0) { - free(pMsg); + free(pReq); return -1; } return 0; } -static int32_t mndCreateBnode(SMnode *pMnode, SMnodeMsg *pMsg, SDnodeObj *pDnode, SMCreateBnodeReq *pCreate) { +static int32_t mndCreateBnode(SMnode *pMnode, SMnodeMsg *pReq, SDnodeObj *pDnode, SMCreateBnodeReq *pCreate) { int32_t code = -1; SBnodeObj bnodeObj = {0}; @@ -238,7 +238,7 @@ static int32_t mndCreateBnode(SMnode *pMnode, SMnodeMsg *pMsg, SDnodeObj *pDnode bnodeObj.createdTime = taosGetTimestampMs(); bnodeObj.updateTime = bnodeObj.createdTime; - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pMsg->rpcMsg); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pReq->rpcMsg); if (pTrans == NULL) goto CREATE_BNODE_OVER; mDebug("trans:%d, used to create bnode:%d", pTrans->id, pCreate->dnodeId); @@ -256,9 +256,9 @@ CREATE_BNODE_OVER: return code; } -static int32_t mndProcessCreateBnodeReq(SMnodeMsg *pMsg) { - SMnode *pMnode = pMsg->pMnode; - SMCreateBnodeReq *pCreate = pMsg->rpcMsg.pCont; +static int32_t mndProcessCreateBnodeReq(SMnodeMsg *pReq) { + SMnode *pMnode = pReq->pMnode; + SMCreateBnodeReq *pCreate = pReq->rpcMsg.pCont; pCreate->dnodeId = htonl(pCreate->dnodeId); @@ -282,7 +282,7 @@ static int32_t mndProcessCreateBnodeReq(SMnodeMsg *pMsg) { return -1; } - int32_t code = mndCreateBnode(pMnode, pMsg, pDnode, pCreate); + int32_t code = mndCreateBnode(pMnode, pReq, pDnode, pCreate); mndReleaseDnode(pMnode, pDnode); if (code != 0) { @@ -310,32 +310,32 @@ static int32_t mndSetDropBnodeCommitLogs(STrans *pTrans, SBnodeObj *pObj) { } static int32_t mndSetDropBnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SBnodeObj *pObj) { - SDDropBnodeReq *pMsg = malloc(sizeof(SDDropBnodeReq)); - if (pMsg == NULL) { + SDDropBnodeReq *pReq = malloc(sizeof(SDDropBnodeReq)); + if (pReq == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; } - pMsg->dnodeId = htonl(pDnode->id); + pReq->dnodeId = htonl(pDnode->id); STransAction action = {0}; action.epSet = mndGetDnodeEpset(pDnode); - action.pCont = pMsg; + action.pCont = pReq; action.contLen = sizeof(SDDropBnodeReq); action.msgType = TDMT_DND_DROP_BNODE; action.acceptableCode = TSDB_CODE_DND_BNODE_NOT_DEPLOYED; if (mndTransAppendRedoAction(pTrans, &action) != 0) { - free(pMsg); + free(pReq); return -1; } return 0; } -static int32_t mndDropBnode(SMnode *pMnode, SMnodeMsg *pMsg, SBnodeObj *pObj) { +static int32_t mndDropBnode(SMnode *pMnode, SMnodeMsg *pReq, SBnodeObj *pObj) { int32_t code = -1; - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, &pMsg->rpcMsg); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, &pReq->rpcMsg); if (pTrans == NULL) goto DROP_BNODE_OVER; mDebug("trans:%d, used to drop bnode:%d", pTrans->id, pObj->id); @@ -351,9 +351,9 @@ DROP_BNODE_OVER: return code; } -static int32_t mndProcessDropBnodeReq(SMnodeMsg *pMsg) { - SMnode *pMnode = pMsg->pMnode; - SMDropBnodeReq *pDrop = pMsg->rpcMsg.pCont; +static int32_t mndProcessDropBnodeReq(SMnodeMsg *pReq) { + SMnode *pMnode = pReq->pMnode; + SMDropBnodeReq *pDrop = pReq->rpcMsg.pCont; pDrop->dnodeId = htonl(pDrop->dnodeId); mDebug("bnode:%d, start to drop", pDrop->dnodeId); @@ -370,7 +370,7 @@ static int32_t mndProcessDropBnodeReq(SMnodeMsg *pMsg) { return -1; } - int32_t code = mndDropBnode(pMnode, pMsg, pObj); + int32_t code = mndDropBnode(pMnode, pReq, pObj); if (code != 0) { sdbRelease(pMnode->pSdb, pObj); mError("bnode:%d, failed to drop since %s", pMnode->dnodeId, terrstr()); @@ -381,18 +381,18 @@ static int32_t mndProcessDropBnodeReq(SMnodeMsg *pMsg) { return TSDB_CODE_MND_ACTION_IN_PROGRESS; } -static int32_t mndProcessCreateBnodeRsp(SMnodeMsg *pMsg) { - mndTransProcessRsp(pMsg); +static int32_t mndProcessCreateBnodeRsp(SMnodeMsg *pRsp) { + mndTransProcessRsp(pRsp); return 0; } -static int32_t mndProcessDropBnodeRsp(SMnodeMsg *pMsg) { - mndTransProcessRsp(pMsg); +static int32_t mndProcessDropBnodeRsp(SMnodeMsg *pRsp) { + mndTransProcessRsp(pRsp); return 0; } -static int32_t mndGetBnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pMeta) { - SMnode *pMnode = pMsg->pMnode; +static int32_t mndGetBnodeMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaMsg *pMeta) { + SMnode *pMnode = pReq->pMnode; SSdb *pSdb = pMnode->pSdb; int32_t cols = 0; @@ -431,8 +431,8 @@ static int32_t mndGetBnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg * return 0; } -static int32_t mndRetrieveBnodes(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int32_t rows) { - SMnode *pMnode = pMsg->pMnode; +static int32_t mndRetrieveBnodes(SMnodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows) { + SMnode *pMnode = pReq->pMnode; SSdb *pSdb = pMnode->pSdb; int32_t numOfRows = 0; int32_t cols = 0; diff --git a/source/dnode/mnode/impl/src/mndQnode.c b/source/dnode/mnode/impl/src/mndQnode.c index 6951aa8717..a223890e8c 100644 --- a/source/dnode/mnode/impl/src/mndQnode.c +++ b/source/dnode/mnode/impl/src/mndQnode.c @@ -27,12 +27,12 @@ static SSdbRow *mndQnodeActionDecode(SSdbRaw *pRaw); static int32_t mndQnodeActionInsert(SSdb *pSdb, SQnodeObj *pObj); static int32_t mndQnodeActionDelete(SSdb *pSdb, SQnodeObj *pObj); static int32_t mndQnodeActionUpdate(SSdb *pSdb, SQnodeObj *pOld, SQnodeObj *pNew); -static int32_t mndProcessCreateQnodeReq(SMnodeMsg *pMsg); -static int32_t mndProcessDropQnodeReq(SMnodeMsg *pMsg); -static int32_t mndProcessCreateQnodeRsp(SMnodeMsg *pMsg); -static int32_t mndProcessDropQnodeRsp(SMnodeMsg *pMsg); -static int32_t mndGetQnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pMeta); -static int32_t mndRetrieveQnodes(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int32_t rows); +static int32_t mndProcessCreateQnodeReq(SMnodeMsg *pReq); +static int32_t mndProcessDropQnodeReq(SMnodeMsg *pReq); +static int32_t mndProcessCreateQnodeRsp(SMnodeMsg *pRsp); +static int32_t mndProcessDropQnodeRsp(SMnodeMsg *pRsp); +static int32_t mndGetQnodeMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaMsg *pMeta); +static int32_t mndRetrieveQnodes(SMnodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows); static void mndCancelGetNextQnode(SMnode *pMnode, void *pIter); int32_t mndInitQnode(SMnode *pMnode) { @@ -185,22 +185,22 @@ static int32_t mndSetCreateQnodeCommitLogs(STrans *pTrans, SQnodeObj *pObj) { } static int32_t mndSetCreateQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SQnodeObj *pObj) { - SDCreateQnodeReq *pMsg = malloc(sizeof(SDCreateQnodeReq)); - if (pMsg == NULL) { + SDCreateQnodeReq *pReq = malloc(sizeof(SDCreateQnodeReq)); + if (pReq == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; } - pMsg->dnodeId = htonl(pDnode->id); + pReq->dnodeId = htonl(pDnode->id); STransAction action = {0}; action.epSet = mndGetDnodeEpset(pDnode); - action.pCont = pMsg; + action.pCont = pReq; action.contLen = sizeof(SDCreateQnodeReq); action.msgType = TDMT_DND_CREATE_QNODE; action.acceptableCode = TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED; if (mndTransAppendRedoAction(pTrans, &action) != 0) { - free(pMsg); + free(pReq); return -1; } @@ -208,29 +208,29 @@ static int32_t mndSetCreateQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S } static int32_t mndSetCreateQnodeUndoActions(STrans *pTrans, SDnodeObj *pDnode, SQnodeObj *pObj) { - SDDropQnodeReq *pMsg = malloc(sizeof(SDDropQnodeReq)); - if (pMsg == NULL) { + SDDropQnodeReq *pReq = malloc(sizeof(SDDropQnodeReq)); + if (pReq == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; } - pMsg->dnodeId = htonl(pDnode->id); + pReq->dnodeId = htonl(pDnode->id); STransAction action = {0}; action.epSet = mndGetDnodeEpset(pDnode); - action.pCont = pMsg; + action.pCont = pReq; action.contLen = sizeof(SDDropQnodeReq); action.msgType = TDMT_DND_DROP_QNODE; action.acceptableCode = TSDB_CODE_DND_QNODE_NOT_DEPLOYED; if (mndTransAppendUndoAction(pTrans, &action) != 0) { - free(pMsg); + free(pReq); return -1; } return 0; } -static int32_t mndCreateQnode(SMnode *pMnode, SMnodeMsg *pMsg, SDnodeObj *pDnode, SMCreateQnodeReq *pCreate) { +static int32_t mndCreateQnode(SMnode *pMnode, SMnodeMsg *pReq, SDnodeObj *pDnode, SMCreateQnodeReq *pCreate) { int32_t code = -1; SQnodeObj qnodeObj = {0}; @@ -238,7 +238,7 @@ static int32_t mndCreateQnode(SMnode *pMnode, SMnodeMsg *pMsg, SDnodeObj *pDnode qnodeObj.createdTime = taosGetTimestampMs(); qnodeObj.updateTime = qnodeObj.createdTime; - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pMsg->rpcMsg); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pReq->rpcMsg); if (pTrans == NULL) goto CREATE_QNODE_OVER; mDebug("trans:%d, used to create qnode:%d", pTrans->id, pCreate->dnodeId); @@ -256,9 +256,9 @@ CREATE_QNODE_OVER: return code; } -static int32_t mndProcessCreateQnodeReq(SMnodeMsg *pMsg) { - SMnode *pMnode = pMsg->pMnode; - SMCreateQnodeReq *pCreate = pMsg->rpcMsg.pCont; +static int32_t mndProcessCreateQnodeReq(SMnodeMsg *pReq) { + SMnode *pMnode = pReq->pMnode; + SMCreateQnodeReq *pCreate = pReq->rpcMsg.pCont; pCreate->dnodeId = htonl(pCreate->dnodeId); @@ -282,7 +282,7 @@ static int32_t mndProcessCreateQnodeReq(SMnodeMsg *pMsg) { return -1; } - int32_t code = mndCreateQnode(pMnode, pMsg, pDnode, pCreate); + int32_t code = mndCreateQnode(pMnode, pReq, pDnode, pCreate); mndReleaseDnode(pMnode, pDnode); if (code != 0) { @@ -310,32 +310,32 @@ static int32_t mndSetDropQnodeCommitLogs(STrans *pTrans, SQnodeObj *pObj) { } static int32_t mndSetDropQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SQnodeObj *pObj) { - SDDropQnodeReq *pMsg = malloc(sizeof(SDDropQnodeReq)); - if (pMsg == NULL) { + SDDropQnodeReq *pReq = malloc(sizeof(SDDropQnodeReq)); + if (pReq == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; } - pMsg->dnodeId = htonl(pDnode->id); + pReq->dnodeId = htonl(pDnode->id); STransAction action = {0}; action.epSet = mndGetDnodeEpset(pDnode); - action.pCont = pMsg; + action.pCont = pReq; action.contLen = sizeof(SDDropQnodeReq); action.msgType = TDMT_DND_DROP_QNODE; action.acceptableCode = TSDB_CODE_DND_QNODE_NOT_DEPLOYED; if (mndTransAppendRedoAction(pTrans, &action) != 0) { - free(pMsg); + free(pReq); return -1; } return 0; } -static int32_t mndDropQnode(SMnode *pMnode, SMnodeMsg *pMsg, SQnodeObj *pObj) { +static int32_t mndDropQnode(SMnode *pMnode, SMnodeMsg *pReq, SQnodeObj *pObj) { int32_t code = -1; - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, &pMsg->rpcMsg); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, &pReq->rpcMsg); if (pTrans == NULL) goto DROP_QNODE_OVER; mDebug("trans:%d, used to drop qnode:%d", pTrans->id, pObj->id); @@ -351,9 +351,9 @@ DROP_QNODE_OVER: return code; } -static int32_t mndProcessDropQnodeReq(SMnodeMsg *pMsg) { - SMnode *pMnode = pMsg->pMnode; - SMDropQnodeReq *pDrop = pMsg->rpcMsg.pCont; +static int32_t mndProcessDropQnodeReq(SMnodeMsg *pReq) { + SMnode *pMnode = pReq->pMnode; + SMDropQnodeReq *pDrop = pReq->rpcMsg.pCont; pDrop->dnodeId = htonl(pDrop->dnodeId); mDebug("qnode:%d, start to drop", pDrop->dnodeId); @@ -370,7 +370,7 @@ static int32_t mndProcessDropQnodeReq(SMnodeMsg *pMsg) { return -1; } - int32_t code = mndDropQnode(pMnode, pMsg, pObj); + int32_t code = mndDropQnode(pMnode, pReq, pObj); if (code != 0) { sdbRelease(pMnode->pSdb, pObj); mError("qnode:%d, failed to drop since %s", pMnode->dnodeId, terrstr()); @@ -381,18 +381,18 @@ static int32_t mndProcessDropQnodeReq(SMnodeMsg *pMsg) { return TSDB_CODE_MND_ACTION_IN_PROGRESS; } -static int32_t mndProcessCreateQnodeRsp(SMnodeMsg *pMsg) { - mndTransProcessRsp(pMsg); +static int32_t mndProcessCreateQnodeRsp(SMnodeMsg *pRsp) { + mndTransProcessRsp(pRsp); return 0; } -static int32_t mndProcessDropQnodeRsp(SMnodeMsg *pMsg) { - mndTransProcessRsp(pMsg); +static int32_t mndProcessDropQnodeRsp(SMnodeMsg *pRsp) { + mndTransProcessRsp(pRsp); return 0; } -static int32_t mndGetQnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pMeta) { - SMnode *pMnode = pMsg->pMnode; +static int32_t mndGetQnodeMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaMsg *pMeta) { + SMnode *pMnode = pReq->pMnode; SSdb *pSdb = pMnode->pSdb; int32_t cols = 0; @@ -431,8 +431,8 @@ static int32_t mndGetQnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg * return 0; } -static int32_t mndRetrieveQnodes(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int32_t rows) { - SMnode *pMnode = pMsg->pMnode; +static int32_t mndRetrieveQnodes(SMnodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows) { + SMnode *pMnode = pReq->pMnode; SSdb *pSdb = pMnode->pSdb; int32_t numOfRows = 0; int32_t cols = 0; diff --git a/source/dnode/mnode/impl/src/mndShow.c b/source/dnode/mnode/impl/src/mndShow.c index 81e15497bf..9c145f6445 100644 --- a/source/dnode/mnode/impl/src/mndShow.c +++ b/source/dnode/mnode/impl/src/mndShow.c @@ -18,12 +18,12 @@ #define SHOW_STEP_SIZE 100 -static SShowObj *mndCreateShowObj(SMnode *pMnode, SShowMsg *pMsg); +static SShowObj *mndCreateShowObj(SMnode *pMnode, SShowReq *pReq); static void mndFreeShowObj(SShowObj *pShow); static SShowObj *mndAcquireShowObj(SMnode *pMnode, int64_t showId); static void mndReleaseShowObj(SShowObj *pShow, bool forceRemove); -static int32_t mndProcessShowReq(SMnodeMsg *pMsg); -static int32_t mndProcessRetrieveReq(SMnodeMsg *pMsg); +static int32_t mndProcessShowReq(SMnodeMsg *pReq); +static int32_t mndProcessRetrieveReq(SMnodeMsg *pReq); static bool mndCheckRetrieveFinished(SShowObj *pShow); int32_t mndInitShow(SMnode *pMnode) { @@ -49,20 +49,20 @@ void mndCleanupShow(SMnode *pMnode) { } } -static SShowObj *mndCreateShowObj(SMnode *pMnode, SShowMsg *pMsg) { +static SShowObj *mndCreateShowObj(SMnode *pMnode, SShowReq *pReq) { SShowMgmt *pMgmt = &pMnode->showMgmt; int64_t showId = atomic_add_fetch_64(&pMgmt->showId, 1); if (showId == 0) atomic_add_fetch_64(&pMgmt->showId, 1); - int32_t size = sizeof(SShowObj) + pMsg->payloadLen; + int32_t size = sizeof(SShowObj) + pReq->payloadLen; SShowObj showObj = {0}; showObj.id = showId; showObj.pMnode = pMnode; - showObj.type = pMsg->type; - showObj.payloadLen = pMsg->payloadLen; - memcpy(showObj.db, pMsg->db, TSDB_DB_FNAME_LEN); - memcpy(showObj.payload, pMsg->payload, pMsg->payloadLen); + showObj.type = pReq->type; + showObj.payloadLen = pReq->payloadLen; + memcpy(showObj.db, pReq->db, TSDB_DB_FNAME_LEN); + memcpy(showObj.payload, pReq->payload, pReq->payloadLen); int32_t keepTime = pMnode->cfg.shellActivityTimer * 6 * 1000; SShowObj *pShow = taosCachePut(pMgmt->cache, &showId, sizeof(int64_t), &showObj, size, keepTime); @@ -115,12 +115,12 @@ static void mndReleaseShowObj(SShowObj *pShow, bool forceRemove) { taosCacheRelease(pMgmt->cache, (void **)(&pShow), forceRemove); } -static int32_t mndProcessShowReq(SMnodeMsg *pMnodeMsg) { - SMnode *pMnode = pMnodeMsg->pMnode; +static int32_t mndProcessShowReq(SMnodeMsg *pReq) { + SMnode *pMnode = pReq->pMnode; SShowMgmt *pMgmt = &pMnode->showMgmt; - SShowMsg *pMsg = pMnodeMsg->rpcMsg.pCont; - int8_t type = pMsg->type; - int16_t payloadLen = htonl(pMsg->payloadLen); + SShowReq *pShowReq = pReq->rpcMsg.pCont; + int8_t type = pShowReq->type; + int16_t payloadLen = htonl(pShowReq->payloadLen); if (type <= TSDB_MGMT_TABLE_START || type >= TSDB_MGMT_TABLE_MAX) { terrno = TSDB_CODE_MND_INVALID_MSG_TYPE; @@ -135,7 +135,7 @@ static int32_t mndProcessShowReq(SMnodeMsg *pMnodeMsg) { return -1; } - SShowObj *pShow = mndCreateShowObj(pMnode, pMsg); + SShowObj *pShow = mndCreateShowObj(pMnode, pShowReq); if (pShow == NULL) { mError("failed to process show-meta msg:%s since %s", mndShowStr(type), terrstr()); return -1; @@ -151,13 +151,13 @@ static int32_t mndProcessShowReq(SMnodeMsg *pMnodeMsg) { return -1; } - int32_t code = (*metaFp)(pMnodeMsg, pShow, &pRsp->tableMeta); + int32_t code = (*metaFp)(pReq, pShow, &pRsp->tableMeta); mDebug("show:0x%" PRIx64 ", get meta finished, numOfRows:%d cols:%d type:%s, result:%s", pShow->id, pShow->numOfRows, pShow->numOfColumns, mndShowStr(type), tstrerror(code)); if (code == TSDB_CODE_SUCCESS) { - pMnodeMsg->contLen = sizeof(SShowRsp) + sizeof(SSchema) * pShow->numOfColumns; - pMnodeMsg->pCont = pRsp; + pReq->contLen = sizeof(SShowRsp) + sizeof(SSchema) * pShow->numOfColumns; + pReq->pCont = pRsp; pRsp->showId = htobe64(pShow->id); mndReleaseShowObj(pShow, false); return TSDB_CODE_SUCCESS; @@ -168,14 +168,14 @@ static int32_t mndProcessShowReq(SMnodeMsg *pMnodeMsg) { } } -static int32_t mndProcessRetrieveReq(SMnodeMsg *pMsg) { - SMnode *pMnode = pMsg->pMnode; +static int32_t mndProcessRetrieveReq(SMnodeMsg *pReq) { + SMnode *pMnode = pReq->pMnode; SShowMgmt *pMgmt = &pMnode->showMgmt; int32_t rowsToRead = 0; int32_t size = 0; int32_t rowsRead = 0; - SRetrieveTableMsg *pRetrieve = pMsg->rpcMsg.pCont; + SRetrieveTableReq *pRetrieve = pReq->rpcMsg.pCont; int64_t showId = htobe64(pRetrieve->showId); SShowObj *pShow = mndAcquireShowObj(pMnode, showId); @@ -227,7 +227,7 @@ static int32_t mndProcessRetrieveReq(SMnodeMsg *pMsg) { // if free flag is set, client wants to clean the resources if ((pRetrieve->free & TSDB_QUERY_TYPE_FREE_RESOURCE) != TSDB_QUERY_TYPE_FREE_RESOURCE) { - rowsRead = (*retrieveFp)(pMsg, pShow, pRsp->data, rowsToRead); + rowsRead = (*retrieveFp)(pReq, pShow, pRsp->data, rowsToRead); } mDebug("show:0x%" PRIx64 ", stop retrieve data, rowsRead:%d rowsToRead:%d", pShow->id, rowsRead, rowsToRead); @@ -235,8 +235,8 @@ static int32_t mndProcessRetrieveReq(SMnodeMsg *pMsg) { pRsp->numOfRows = htonl(rowsRead); pRsp->precision = TSDB_TIME_PRECISION_MILLI; // millisecond time precision - pMsg->pCont = pRsp; - pMsg->contLen = size; + pReq->pCont = pRsp; + pReq->contLen = size; if (rowsRead == 0 || rowsToRead == 0 || (rowsRead == rowsToRead && pShow->numOfRows == pShow->numOfReads)) { pRsp->completed = 1; diff --git a/source/dnode/mnode/impl/src/mndSnode.c b/source/dnode/mnode/impl/src/mndSnode.c index 7221a2fbf4..1b66bedbcc 100644 --- a/source/dnode/mnode/impl/src/mndSnode.c +++ b/source/dnode/mnode/impl/src/mndSnode.c @@ -27,12 +27,12 @@ static SSdbRow *mndSnodeActionDecode(SSdbRaw *pRaw); static int32_t mndSnodeActionInsert(SSdb *pSdb, SSnodeObj *pObj); static int32_t mndSnodeActionDelete(SSdb *pSdb, SSnodeObj *pObj); static int32_t mndSnodeActionUpdate(SSdb *pSdb, SSnodeObj *pOld, SSnodeObj *pNew); -static int32_t mndProcessCreateSnodeReq(SMnodeMsg *pMsg); -static int32_t mndProcessDropSnodeReq(SMnodeMsg *pMsg); -static int32_t mndProcessCreateSnodeRsp(SMnodeMsg *pMsg); -static int32_t mndProcessDropSnodeRsp(SMnodeMsg *pMsg); -static int32_t mndGetSnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pMeta); -static int32_t mndRetrieveSnodes(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int32_t rows); +static int32_t mndProcessCreateSnodeReq(SMnodeMsg *pReq); +static int32_t mndProcessDropSnodeReq(SMnodeMsg *pReq); +static int32_t mndProcessCreateSnodeRsp(SMnodeMsg *pRsp); +static int32_t mndProcessDropSnodeRsp(SMnodeMsg *pRsp); +static int32_t mndGetSnodeMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaMsg *pMeta); +static int32_t mndRetrieveSnodes(SMnodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows); static void mndCancelGetNextSnode(SMnode *pMnode, void *pIter); int32_t mndInitSnode(SMnode *pMnode) { @@ -185,22 +185,22 @@ static int32_t mndSetCreateSnodeCommitLogs(STrans *pTrans, SSnodeObj *pObj) { } static int32_t mndSetCreateSnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SSnodeObj *pObj) { - SDCreateSnodeReq *pMsg = malloc(sizeof(SDCreateSnodeReq)); - if (pMsg == NULL) { + SDCreateSnodeReq *pReq = malloc(sizeof(SDCreateSnodeReq)); + if (pReq == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; } - pMsg->dnodeId = htonl(pDnode->id); + pReq->dnodeId = htonl(pDnode->id); STransAction action = {0}; action.epSet = mndGetDnodeEpset(pDnode); - action.pCont = pMsg; + action.pCont = pReq; action.contLen = sizeof(SDCreateSnodeReq); action.msgType = TDMT_DND_CREATE_SNODE; action.acceptableCode = TSDB_CODE_DND_SNODE_ALREADY_DEPLOYED; if (mndTransAppendRedoAction(pTrans, &action) != 0) { - free(pMsg); + free(pReq); return -1; } @@ -208,29 +208,29 @@ static int32_t mndSetCreateSnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S } static int32_t mndSetCreateSnodeUndoActions(STrans *pTrans, SDnodeObj *pDnode, SSnodeObj *pObj) { - SDDropSnodeReq *pMsg = malloc(sizeof(SDDropSnodeReq)); - if (pMsg == NULL) { + SDDropSnodeReq *pReq = malloc(sizeof(SDDropSnodeReq)); + if (pReq == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; } - pMsg->dnodeId = htonl(pDnode->id); + pReq->dnodeId = htonl(pDnode->id); STransAction action = {0}; action.epSet = mndGetDnodeEpset(pDnode); - action.pCont = pMsg; + action.pCont = pReq; action.contLen = sizeof(SDDropSnodeReq); action.msgType = TDMT_DND_DROP_SNODE; action.acceptableCode = TSDB_CODE_DND_SNODE_NOT_DEPLOYED; if (mndTransAppendUndoAction(pTrans, &action) != 0) { - free(pMsg); + free(pReq); return -1; } return 0; } -static int32_t mndCreateSnode(SMnode *pMnode, SMnodeMsg *pMsg, SDnodeObj *pDnode, SMCreateSnodeReq *pCreate) { +static int32_t mndCreateSnode(SMnode *pMnode, SMnodeMsg *pReq, SDnodeObj *pDnode, SMCreateSnodeReq *pCreate) { int32_t code = -1; SSnodeObj snodeObj = {0}; @@ -238,7 +238,7 @@ static int32_t mndCreateSnode(SMnode *pMnode, SMnodeMsg *pMsg, SDnodeObj *pDnode snodeObj.createdTime = taosGetTimestampMs(); snodeObj.updateTime = snodeObj.createdTime; - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pMsg->rpcMsg); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pReq->rpcMsg); if (pTrans == NULL) goto CREATE_SNODE_OVER; mDebug("trans:%d, used to create snode:%d", pTrans->id, pCreate->dnodeId); @@ -257,9 +257,9 @@ CREATE_SNODE_OVER: return code; } -static int32_t mndProcessCreateSnodeReq(SMnodeMsg *pMsg) { - SMnode *pMnode = pMsg->pMnode; - SMCreateSnodeReq *pCreate = pMsg->rpcMsg.pCont; +static int32_t mndProcessCreateSnodeReq(SMnodeMsg *pReq) { + SMnode *pMnode = pReq->pMnode; + SMCreateSnodeReq *pCreate = pReq->rpcMsg.pCont; pCreate->dnodeId = htonl(pCreate->dnodeId); @@ -283,7 +283,7 @@ static int32_t mndProcessCreateSnodeReq(SMnodeMsg *pMsg) { return -1; } - int32_t code = mndCreateSnode(pMnode, pMsg, pDnode, pCreate); + int32_t code = mndCreateSnode(pMnode, pReq, pDnode, pCreate); mndReleaseDnode(pMnode, pDnode); if (code != 0) { @@ -311,32 +311,32 @@ static int32_t mndSetDropSnodeCommitLogs(STrans *pTrans, SSnodeObj *pObj) { } static int32_t mndSetDropSnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SSnodeObj *pObj) { - SDDropSnodeReq *pMsg = malloc(sizeof(SDDropSnodeReq)); - if (pMsg == NULL) { + SDDropSnodeReq *pReq = malloc(sizeof(SDDropSnodeReq)); + if (pReq == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; } - pMsg->dnodeId = htonl(pDnode->id); + pReq->dnodeId = htonl(pDnode->id); STransAction action = {0}; action.epSet = mndGetDnodeEpset(pDnode); - action.pCont = pMsg; + action.pCont = pReq; action.contLen = sizeof(SDDropSnodeReq); action.msgType = TDMT_DND_DROP_SNODE; action.acceptableCode = TSDB_CODE_DND_SNODE_NOT_DEPLOYED; if (mndTransAppendRedoAction(pTrans, &action) != 0) { - free(pMsg); + free(pReq); return -1; } return 0; } -static int32_t mndDropSnode(SMnode *pMnode, SMnodeMsg *pMsg, SSnodeObj *pObj) { +static int32_t mndDropSnode(SMnode *pMnode, SMnodeMsg *pReq, SSnodeObj *pObj) { int32_t code = -1; - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, &pMsg->rpcMsg); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, &pReq->rpcMsg); if (pTrans == NULL) goto DROP_SNODE_OVER; mDebug("trans:%d, used to drop snode:%d", pTrans->id, pObj->id); @@ -353,9 +353,9 @@ DROP_SNODE_OVER: return code; } -static int32_t mndProcessDropSnodeReq(SMnodeMsg *pMsg) { - SMnode *pMnode = pMsg->pMnode; - SMDropSnodeReq *pDrop = pMsg->rpcMsg.pCont; +static int32_t mndProcessDropSnodeReq(SMnodeMsg *pReq) { + SMnode *pMnode = pReq->pMnode; + SMDropSnodeReq *pDrop = pReq->rpcMsg.pCont; pDrop->dnodeId = htonl(pDrop->dnodeId); mDebug("snode:%d, start to drop", pDrop->dnodeId); @@ -372,7 +372,7 @@ static int32_t mndProcessDropSnodeReq(SMnodeMsg *pMsg) { return -1; } - int32_t code = mndDropSnode(pMnode, pMsg, pObj); + int32_t code = mndDropSnode(pMnode, pReq, pObj); if (code != 0) { sdbRelease(pMnode->pSdb, pObj); mError("snode:%d, failed to drop since %s", pMnode->dnodeId, terrstr()); @@ -383,18 +383,18 @@ static int32_t mndProcessDropSnodeReq(SMnodeMsg *pMsg) { return TSDB_CODE_MND_ACTION_IN_PROGRESS; } -static int32_t mndProcessCreateSnodeRsp(SMnodeMsg *pMsg) { - mndTransProcessRsp(pMsg); +static int32_t mndProcessCreateSnodeRsp(SMnodeMsg *pRsp) { + mndTransProcessRsp(pRsp); return 0; } -static int32_t mndProcessDropSnodeRsp(SMnodeMsg *pMsg) { - mndTransProcessRsp(pMsg); +static int32_t mndProcessDropSnodeRsp(SMnodeMsg *pRsp) { + mndTransProcessRsp(pRsp); return 0; } -static int32_t mndGetSnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pMeta) { - SMnode *pMnode = pMsg->pMnode; +static int32_t mndGetSnodeMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaMsg *pMeta) { + SMnode *pMnode = pReq->pMnode; SSdb *pSdb = pMnode->pSdb; int32_t cols = 0; @@ -433,8 +433,8 @@ static int32_t mndGetSnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg * return 0; } -static int32_t mndRetrieveSnodes(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int32_t rows) { - SMnode *pMnode = pMsg->pMnode; +static int32_t mndRetrieveSnodes(SMnodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows) { + SMnode *pMnode = pReq->pMnode; SSdb *pSdb = pMnode->pSdb; int32_t numOfRows = 0; int32_t cols = 0; diff --git a/source/dnode/mnode/impl/src/mndUser.c b/source/dnode/mnode/impl/src/mndUser.c index 0891cf43b3..e73b34e688 100644 --- a/source/dnode/mnode/impl/src/mndUser.c +++ b/source/dnode/mnode/impl/src/mndUser.c @@ -28,12 +28,12 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw); static int32_t mndUserActionInsert(SSdb *pSdb, SUserObj *pUser); static int32_t mndUserActionDelete(SSdb *pSdb, SUserObj *pUser); static int32_t mndUserActionUpdate(SSdb *pSdb, SUserObj *pOld, SUserObj *pNew); -static int32_t mndCreateUser(SMnode *pMnode, char *acct, char *user, char *pass, SMnodeMsg *pMsg); -static int32_t mndProcessCreateUserReq(SMnodeMsg *pMsg); -static int32_t mndProcessAlterUserReq(SMnodeMsg *pMsg); -static int32_t mndProcessDropUserReq(SMnodeMsg *pMsg); -static int32_t mndGetUserMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pMeta); -static int32_t mndRetrieveUsers(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int32_t rows); +static int32_t mndCreateUser(SMnode *pMnode, char *acct, char *user, char *pass, SMnodeMsg *pReq); +static int32_t mndProcessCreateUserReq(SMnodeMsg *pReq); +static int32_t mndProcessAlterUserReq(SMnodeMsg *pReq); +static int32_t mndProcessDropUserReq(SMnodeMsg *pReq); +static int32_t mndGetUserMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaMsg *pMeta); +static int32_t mndRetrieveUsers(SMnodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows); static void mndCancelGetNextUser(SMnode *pMnode, void *pIter); int32_t mndInitUser(SMnode *pMnode) { @@ -212,7 +212,7 @@ void mndReleaseUser(SMnode *pMnode, SUserObj *pUser) { sdbRelease(pSdb, pUser); } -static int32_t mndCreateUser(SMnode *pMnode, char *acct, char *user, char *pass, SMnodeMsg *pMsg) { +static int32_t mndCreateUser(SMnode *pMnode, char *acct, char *user, char *pass, SMnodeMsg *pReq) { SUserObj userObj = {0}; tstrncpy(userObj.user, user, TSDB_USER_LEN); tstrncpy(userObj.acct, acct, TSDB_USER_LEN); @@ -221,7 +221,7 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, char *user, char *pass, userObj.updateTime = userObj.createdTime; userObj.superUser = 0; - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pMsg->rpcMsg); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pReq->rpcMsg); if (pTrans == NULL) { mError("user:%s, failed to create since %s", user, terrstr()); return -1; @@ -246,9 +246,9 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, char *user, char *pass, return 0; } -static int32_t mndProcessCreateUserReq(SMnodeMsg *pMsg) { - SMnode *pMnode = pMsg->pMnode; - SCreateUserReq *pCreate = pMsg->rpcMsg.pCont; +static int32_t mndProcessCreateUserReq(SMnodeMsg *pReq) { + SMnode *pMnode = pReq->pMnode; + SCreateUserReq *pCreate = pReq->rpcMsg.pCont; mDebug("user:%s, start to create", pCreate->user); @@ -272,14 +272,14 @@ static int32_t mndProcessCreateUserReq(SMnodeMsg *pMsg) { return -1; } - SUserObj *pOperUser = mndAcquireUser(pMnode, pMsg->user); + SUserObj *pOperUser = mndAcquireUser(pMnode, pReq->user); if (pOperUser == NULL) { terrno = TSDB_CODE_MND_NO_USER_FROM_CONN; mError("user:%s, failed to create since %s", pCreate->user, terrstr()); return -1; } - int32_t code = mndCreateUser(pMnode, pOperUser->acct, pCreate->user, pCreate->pass, pMsg); + int32_t code = mndCreateUser(pMnode, pOperUser->acct, pCreate->user, pCreate->pass, pReq); mndReleaseUser(pMnode, pOperUser); if (code != 0) { @@ -290,8 +290,8 @@ static int32_t mndProcessCreateUserReq(SMnodeMsg *pMsg) { return TSDB_CODE_MND_ACTION_IN_PROGRESS; } -static int32_t mndUpdateUser(SMnode *pMnode, SUserObj *pOld, SUserObj *pNew, SMnodeMsg *pMsg) { - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pMsg->rpcMsg); +static int32_t mndUpdateUser(SMnode *pMnode, SUserObj *pOld, SUserObj *pNew, SMnodeMsg *pReq) { + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pReq->rpcMsg); if (pTrans == NULL) { mError("user:%s, failed to update since %s", pOld->user, terrstr()); return -1; @@ -316,9 +316,9 @@ static int32_t mndUpdateUser(SMnode *pMnode, SUserObj *pOld, SUserObj *pNew, SMn return 0; } -static int32_t mndProcessAlterUserReq(SMnodeMsg *pMsg) { - SMnode *pMnode = pMsg->pMnode; - SAlterUserReq *pAlter = pMsg->rpcMsg.pCont; +static int32_t mndProcessAlterUserReq(SMnodeMsg *pReq) { + SMnode *pMnode = pReq->pMnode; + SAlterUserReq *pAlter = pReq->rpcMsg.pCont; mDebug("user:%s, start to alter", pAlter->user); @@ -341,7 +341,7 @@ static int32_t mndProcessAlterUserReq(SMnodeMsg *pMsg) { return -1; } - SUserObj *pOperUser = mndAcquireUser(pMnode, pMsg->user); + SUserObj *pOperUser = mndAcquireUser(pMnode, pReq->user); if (pOperUser == NULL) { mndReleaseUser(pMnode, pUser); terrno = TSDB_CODE_MND_NO_USER_FROM_CONN; @@ -355,7 +355,7 @@ static int32_t mndProcessAlterUserReq(SMnodeMsg *pMsg) { taosEncryptPass((uint8_t *)pAlter->pass, strlen(pAlter->pass), pUser->pass); newUser.updateTime = taosGetTimestampMs(); - int32_t code = mndUpdateUser(pMnode, pUser, &newUser, pMsg); + int32_t code = mndUpdateUser(pMnode, pUser, &newUser, pReq); mndReleaseUser(pMnode, pOperUser); mndReleaseUser(pMnode, pUser); @@ -367,8 +367,8 @@ static int32_t mndProcessAlterUserReq(SMnodeMsg *pMsg) { return TSDB_CODE_MND_ACTION_IN_PROGRESS; } -static int32_t mndDropUser(SMnode *pMnode, SMnodeMsg *pMsg, SUserObj *pUser) { - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pMsg->rpcMsg); +static int32_t mndDropUser(SMnode *pMnode, SMnodeMsg *pReq, SUserObj *pUser) { + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pReq->rpcMsg); if (pTrans == NULL) { mError("user:%s, failed to drop since %s", pUser->user, terrstr()); return -1; @@ -393,9 +393,9 @@ static int32_t mndDropUser(SMnode *pMnode, SMnodeMsg *pMsg, SUserObj *pUser) { return 0; } -static int32_t mndProcessDropUserReq(SMnodeMsg *pMsg) { - SMnode *pMnode = pMsg->pMnode; - SDropUserReq *pDrop = pMsg->rpcMsg.pCont; +static int32_t mndProcessDropUserReq(SMnodeMsg *pReq) { + SMnode *pMnode = pReq->pMnode; + SDropUserReq *pDrop = pReq->rpcMsg.pCont; mDebug("user:%s, start to drop", pDrop->user); @@ -412,7 +412,7 @@ static int32_t mndProcessDropUserReq(SMnodeMsg *pMsg) { return -1; } - SUserObj *pOperUser = mndAcquireUser(pMnode, pMsg->user); + SUserObj *pOperUser = mndAcquireUser(pMnode, pReq->user); if (pOperUser == NULL) { mndReleaseUser(pMnode, pUser); terrno = TSDB_CODE_MND_NO_USER_FROM_CONN; @@ -420,7 +420,7 @@ static int32_t mndProcessDropUserReq(SMnodeMsg *pMsg) { return -1; } - int32_t code = mndDropUser(pMnode, pMsg, pUser); + int32_t code = mndDropUser(pMnode, pReq, pUser); mndReleaseUser(pMnode, pOperUser); mndReleaseUser(pMnode, pUser); @@ -432,8 +432,8 @@ static int32_t mndProcessDropUserReq(SMnodeMsg *pMsg) { return TSDB_CODE_MND_ACTION_IN_PROGRESS; } -static int32_t mndGetUserMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pMeta) { - SMnode *pMnode = pMsg->pMnode; +static int32_t mndGetUserMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaMsg *pMeta) { + SMnode *pMnode = pReq->pMnode; SSdb *pSdb = pMnode->pSdb; int32_t cols = 0; @@ -478,8 +478,8 @@ static int32_t mndGetUserMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *p return 0; } -static int32_t mndRetrieveUsers(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int32_t rows) { - SMnode *pMnode = pMsg->pMnode; +static int32_t mndRetrieveUsers(SMnodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows) { + SMnode *pMnode = pReq->pMnode; SSdb *pSdb = pMnode->pSdb; int32_t numOfRows = 0; SUserObj *pUser = NULL; diff --git a/source/dnode/mnode/impl/test/acct/acct.cpp b/source/dnode/mnode/impl/test/acct/acct.cpp index 906a066f74..315f23f798 100644 --- a/source/dnode/mnode/impl/test/acct/acct.cpp +++ b/source/dnode/mnode/impl/test/acct/acct.cpp @@ -30,9 +30,9 @@ TEST_F(MndTestAcct, 01_Create_Acct) { SCreateAcctReq* pReq = (SCreateAcctReq*)rpcMallocCont(contLen); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_ACCT, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_MND_MSG_NOT_PROCESSED); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_ACCT, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_MSG_NOT_PROCESSED); } TEST_F(MndTestAcct, 02_Alter_Acct) { @@ -40,9 +40,9 @@ TEST_F(MndTestAcct, 02_Alter_Acct) { SAlterAcctReq* pReq = (SAlterAcctReq*)rpcMallocCont(contLen); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_ALTER_ACCT, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_MND_MSG_NOT_PROCESSED); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_ACCT, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_MSG_NOT_PROCESSED); } TEST_F(MndTestAcct, 03_Drop_Acct) { @@ -50,18 +50,18 @@ TEST_F(MndTestAcct, 03_Drop_Acct) { SDropAcctReq* pReq = (SDropAcctReq*)rpcMallocCont(contLen); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_ACCT, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_MND_MSG_NOT_PROCESSED); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_ACCT, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_MSG_NOT_PROCESSED); } TEST_F(MndTestAcct, 04_Show_Acct) { - int32_t contLen = sizeof(SShowMsg); + int32_t contLen = sizeof(SShowReq); - SShowMsg* pReq = (SShowMsg*)rpcMallocCont(contLen); + SShowReq* pReq = (SShowReq*)rpcMallocCont(contLen); pReq->type = TSDB_MGMT_TABLE_ACCT; - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_SHOW, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_MSG_TYPE); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_SHOW, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_MSG_TYPE); } \ No newline at end of file diff --git a/source/dnode/mnode/impl/test/bnode/bnode.cpp b/source/dnode/mnode/impl/test/bnode/bnode.cpp index 07dc163df5..e32c0e7f91 100644 --- a/source/dnode/mnode/impl/test/bnode/bnode.cpp +++ b/source/dnode/mnode/impl/test/bnode/bnode.cpp @@ -39,14 +39,14 @@ Testbase MndTestBnode::test; TestServer MndTestBnode::server2; TEST_F(MndTestBnode, 01_Show_Bnode) { - test.SendShowMetaMsg(TSDB_MGMT_TABLE_BNODE, ""); + test.SendShowMetaReq(TSDB_MGMT_TABLE_BNODE, ""); CHECK_META("show bnodes", 3); 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_TIMESTAMP, 8, "create_time"); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 0); } @@ -57,9 +57,9 @@ TEST_F(MndTestBnode, 02_Create_Bnode) { SMCreateBnodeReq* pReq = (SMCreateBnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_BNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_MND_DNODE_NOT_EXIST); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_DNODE_NOT_EXIST); } { @@ -68,13 +68,13 @@ TEST_F(MndTestBnode, 02_Create_Bnode) { SMCreateBnodeReq* pReq = (SMCreateBnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(1); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_BNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaMsg(TSDB_MGMT_TABLE_BNODE, ""); + test.SendShowMetaReq(TSDB_MGMT_TABLE_BNODE, ""); CHECK_META("show bnodes", 3); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 1); CheckInt16(1); @@ -88,9 +88,9 @@ TEST_F(MndTestBnode, 02_Create_Bnode) { SMCreateBnodeReq* pReq = (SMCreateBnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(1); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_BNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_MND_BNODE_ALREADY_EXIST); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_BNODE_ALREADY_EXIST); } } @@ -102,13 +102,13 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) { strcpy(pReq->fqdn, "localhost"); pReq->port = htonl(9019); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); taosMsleep(1300); - test.SendShowMetaMsg(TSDB_MGMT_TABLE_DNODE, ""); - test.SendShowRetrieveMsg(); + test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, ""); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 2); } @@ -118,12 +118,12 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) { SMCreateBnodeReq* pReq = (SMCreateBnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_BNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaMsg(TSDB_MGMT_TABLE_BNODE, ""); - test.SendShowRetrieveMsg(); + test.SendShowMetaReq(TSDB_MGMT_TABLE_BNODE, ""); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 2); CheckInt16(1); @@ -140,12 +140,12 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) { SMDropBnodeReq* pReq = (SMDropBnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_BNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_BNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaMsg(TSDB_MGMT_TABLE_BNODE, ""); - test.SendShowRetrieveMsg(); + test.SendShowMetaReq(TSDB_MGMT_TABLE_BNODE, ""); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 1); CheckInt16(1); @@ -159,9 +159,9 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) { SMDropBnodeReq* pReq = (SMDropBnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_BNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_MND_BNODE_NOT_EXIST); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_BNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_BNODE_NOT_EXIST); } } @@ -174,9 +174,9 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) { pReq->dnodeId = htonl(2); server2.Stop(); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_BNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_RPC_NETWORK_UNAVAIL); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_RPC_NETWORK_UNAVAIL); } { @@ -187,9 +187,9 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) { pReq->dnodeId = htonl(2); server2.Stop(); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_BNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_SDB_OBJ_CREATING); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_CREATING); } { @@ -200,9 +200,9 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) { pReq->dnodeId = htonl(2); server2.Stop(); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_BNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_SDB_OBJ_CREATING); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_BNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_CREATING); } { @@ -219,9 +219,9 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) { SMCreateBnodeReq* pReq = (SMCreateBnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_BNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - if (pMsg->code == 0) break; + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + if (pRsp->code == 0) break; taosMsleep(1000); } @@ -238,9 +238,9 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) { pReq->dnodeId = htonl(2); server2.Stop(); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_BNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_RPC_NETWORK_UNAVAIL); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_BNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_RPC_NETWORK_UNAVAIL); } { @@ -251,9 +251,9 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) { pReq->dnodeId = htonl(2); server2.Stop(); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_BNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_SDB_OBJ_DROPPING); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_DROPPING); } { @@ -264,9 +264,9 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) { pReq->dnodeId = htonl(2); server2.Stop(); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_BNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_SDB_OBJ_DROPPING); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_BNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_DROPPING); } { @@ -283,9 +283,9 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) { SMCreateBnodeReq* pReq = (SMCreateBnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_BNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - if (pMsg->code == 0) break; + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + if (pRsp->code == 0) break; taosMsleep(1000); } diff --git a/source/dnode/mnode/impl/test/qnode/qnode.cpp b/source/dnode/mnode/impl/test/qnode/qnode.cpp index 612b138ccc..55806dca4d 100644 --- a/source/dnode/mnode/impl/test/qnode/qnode.cpp +++ b/source/dnode/mnode/impl/test/qnode/qnode.cpp @@ -39,14 +39,14 @@ Testbase MndTestQnode::test; TestServer MndTestQnode::server2; TEST_F(MndTestQnode, 01_Show_Qnode) { - test.SendShowMetaMsg(TSDB_MGMT_TABLE_QNODE, ""); + test.SendShowMetaReq(TSDB_MGMT_TABLE_QNODE, ""); CHECK_META("show qnodes", 3); 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_TIMESTAMP, 8, "create_time"); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 0); } @@ -57,9 +57,9 @@ TEST_F(MndTestQnode, 02_Create_Qnode) { SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_QNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_MND_DNODE_NOT_EXIST); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_DNODE_NOT_EXIST); } { @@ -68,13 +68,13 @@ TEST_F(MndTestQnode, 02_Create_Qnode) { SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(1); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_QNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaMsg(TSDB_MGMT_TABLE_QNODE, ""); + test.SendShowMetaReq(TSDB_MGMT_TABLE_QNODE, ""); CHECK_META("show qnodes", 3); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 1); CheckInt16(1); @@ -88,9 +88,9 @@ TEST_F(MndTestQnode, 02_Create_Qnode) { SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(1); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_QNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_MND_QNODE_ALREADY_EXIST); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_QNODE_ALREADY_EXIST); } } @@ -102,13 +102,13 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) { strcpy(pReq->fqdn, "localhost"); pReq->port = htonl(9015); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); taosMsleep(1300); - test.SendShowMetaMsg(TSDB_MGMT_TABLE_DNODE, ""); - test.SendShowRetrieveMsg(); + test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, ""); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 2); } @@ -118,12 +118,12 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) { SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_QNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaMsg(TSDB_MGMT_TABLE_QNODE, ""); - test.SendShowRetrieveMsg(); + test.SendShowMetaReq(TSDB_MGMT_TABLE_QNODE, ""); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 2); CheckInt16(1); @@ -140,12 +140,12 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) { SMDropQnodeReq* pReq = (SMDropQnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_QNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_QNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaMsg(TSDB_MGMT_TABLE_QNODE, ""); - test.SendShowRetrieveMsg(); + test.SendShowMetaReq(TSDB_MGMT_TABLE_QNODE, ""); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 1); CheckInt16(1); @@ -159,9 +159,9 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) { SMDropQnodeReq* pReq = (SMDropQnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_QNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_MND_QNODE_NOT_EXIST); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_QNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_QNODE_NOT_EXIST); } } @@ -174,9 +174,9 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) { pReq->dnodeId = htonl(2); server2.Stop(); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_QNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_RPC_NETWORK_UNAVAIL); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_RPC_NETWORK_UNAVAIL); } { @@ -187,9 +187,9 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) { pReq->dnodeId = htonl(2); server2.Stop(); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_QNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_SDB_OBJ_CREATING); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_CREATING); } { @@ -200,9 +200,9 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) { pReq->dnodeId = htonl(2); server2.Stop(); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_QNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_SDB_OBJ_CREATING); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_QNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_CREATING); } { @@ -219,9 +219,9 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) { SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_QNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - if (pMsg->code == 0) break; + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + if (pRsp->code == 0) break; taosMsleep(1000); } @@ -238,9 +238,9 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) { pReq->dnodeId = htonl(2); server2.Stop(); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_QNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_RPC_NETWORK_UNAVAIL); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_QNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_RPC_NETWORK_UNAVAIL); } { @@ -251,9 +251,9 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) { pReq->dnodeId = htonl(2); server2.Stop(); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_QNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_SDB_OBJ_DROPPING); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_DROPPING); } { @@ -264,9 +264,9 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) { pReq->dnodeId = htonl(2); server2.Stop(); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_QNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_SDB_OBJ_DROPPING); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_QNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_DROPPING); } { @@ -283,9 +283,9 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) { SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_QNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - if (pMsg->code == 0) break; + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + if (pRsp->code == 0) break; taosMsleep(1000); } diff --git a/source/dnode/mnode/impl/test/show/show.cpp b/source/dnode/mnode/impl/test/show/show.cpp index 6d2c9150f2..b4a625d8be 100644 --- a/source/dnode/mnode/impl/test/show/show.cpp +++ b/source/dnode/mnode/impl/test/show/show.cpp @@ -26,27 +26,27 @@ class MndTestShow : public ::testing::Test { Testbase MndTestShow::test; TEST_F(MndTestShow, 01_ShowMsg_InvalidMsgMax) { - int32_t contLen = sizeof(SShowMsg); + int32_t contLen = sizeof(SShowReq); - SShowMsg* pReq = (SShowMsg*)rpcMallocCont(contLen); + SShowReq* pReq = (SShowReq*)rpcMallocCont(contLen); pReq->type = TSDB_MGMT_TABLE_MAX; strcpy(pReq->db, ""); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_SHOW, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_MSG_TYPE); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_SHOW, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_MSG_TYPE); } TEST_F(MndTestShow, 02_ShowMsg_InvalidMsgStart) { - int32_t contLen = sizeof(SShowMsg); + int32_t contLen = sizeof(SShowReq); - SShowMsg* pReq = (SShowMsg*)rpcMallocCont(sizeof(SShowMsg)); + SShowReq* pReq = (SShowReq*)rpcMallocCont(sizeof(SShowReq)); pReq->type = TSDB_MGMT_TABLE_START; strcpy(pReq->db, ""); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_SHOW, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_MSG_TYPE); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_SHOW, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_MSG_TYPE); } TEST_F(MndTestShow, 03_ShowMsg_Conn) { @@ -57,11 +57,11 @@ TEST_F(MndTestShow, 03_ShowMsg_Conn) { strcpy(pReq->app, "mnode_test_show"); strcpy(pReq->db, ""); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CONNECT, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CONNECT, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaMsg(TSDB_MGMT_TABLE_CONNS, ""); + test.SendShowMetaReq(TSDB_MGMT_TABLE_CONNS, ""); STableMetaMsg* pMeta = test.GetShowMeta(); EXPECT_STREQ(pMeta->tbFname, "show connections"); @@ -75,7 +75,7 @@ TEST_F(MndTestShow, 03_ShowMsg_Conn) { EXPECT_EQ(pMeta->tuid, 0); EXPECT_EQ(pMeta->suid, 0); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); SRetrieveTableRsp* pRetrieveRsp = test.GetRetrieveRsp(); EXPECT_EQ(pRetrieveRsp->numOfRows, 1); @@ -87,13 +87,13 @@ TEST_F(MndTestShow, 03_ShowMsg_Conn) { } TEST_F(MndTestShow, 04_ShowMsg_Cluster) { - test.SendShowMetaMsg(TSDB_MGMT_TABLE_CLUSTER, ""); + test.SendShowMetaReq(TSDB_MGMT_TABLE_CLUSTER, ""); CHECK_META( "show cluster", 3); CHECK_SCHEMA(0, TSDB_DATA_TYPE_BIGINT, 8, "id"); CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_CLUSTER_ID_LEN + VARSTR_HEADER_SIZE, "name"); CHECK_SCHEMA(2, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 1); IgnoreInt64(); diff --git a/source/dnode/mnode/impl/test/snode/snode.cpp b/source/dnode/mnode/impl/test/snode/snode.cpp index cebb5fe113..9e07be842f 100644 --- a/source/dnode/mnode/impl/test/snode/snode.cpp +++ b/source/dnode/mnode/impl/test/snode/snode.cpp @@ -39,14 +39,14 @@ Testbase MndTestSnode::test; TestServer MndTestSnode::server2; TEST_F(MndTestSnode, 01_Show_Snode) { - test.SendShowMetaMsg(TSDB_MGMT_TABLE_SNODE, ""); + test.SendShowMetaReq(TSDB_MGMT_TABLE_SNODE, ""); CHECK_META("show snodes", 3); 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_TIMESTAMP, 8, "create_time"); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 0); } @@ -57,9 +57,9 @@ TEST_F(MndTestSnode, 02_Create_Snode) { SMCreateSnodeReq* pReq = (SMCreateSnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_SNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_MND_DNODE_NOT_EXIST); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_DNODE_NOT_EXIST); } { @@ -68,13 +68,13 @@ TEST_F(MndTestSnode, 02_Create_Snode) { SMCreateSnodeReq* pReq = (SMCreateSnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(1); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_SNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaMsg(TSDB_MGMT_TABLE_SNODE, ""); + test.SendShowMetaReq(TSDB_MGMT_TABLE_SNODE, ""); CHECK_META("show snodes", 3); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 1); CheckInt16(1); @@ -88,9 +88,9 @@ TEST_F(MndTestSnode, 02_Create_Snode) { SMCreateSnodeReq* pReq = (SMCreateSnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(1); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_SNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_MND_SNODE_ALREADY_EXIST); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_SNODE_ALREADY_EXIST); } } @@ -102,13 +102,13 @@ TEST_F(MndTestSnode, 03_Drop_Snode) { strcpy(pReq->fqdn, "localhost"); pReq->port = htonl(9017); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); taosMsleep(1300); - test.SendShowMetaMsg(TSDB_MGMT_TABLE_DNODE, ""); - test.SendShowRetrieveMsg(); + test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, ""); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 2); } @@ -118,12 +118,12 @@ TEST_F(MndTestSnode, 03_Drop_Snode) { SMCreateSnodeReq* pReq = (SMCreateSnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_SNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaMsg(TSDB_MGMT_TABLE_SNODE, ""); - test.SendShowRetrieveMsg(); + test.SendShowMetaReq(TSDB_MGMT_TABLE_SNODE, ""); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 2); CheckInt16(1); @@ -140,12 +140,12 @@ TEST_F(MndTestSnode, 03_Drop_Snode) { SMDropSnodeReq* pReq = (SMDropSnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_SNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_SNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaMsg(TSDB_MGMT_TABLE_SNODE, ""); - test.SendShowRetrieveMsg(); + test.SendShowMetaReq(TSDB_MGMT_TABLE_SNODE, ""); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 1); CheckInt16(1); @@ -159,9 +159,9 @@ TEST_F(MndTestSnode, 03_Drop_Snode) { SMDropSnodeReq* pReq = (SMDropSnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_SNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_MND_SNODE_NOT_EXIST); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_SNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_SNODE_NOT_EXIST); } } @@ -174,9 +174,9 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) { pReq->dnodeId = htonl(2); server2.Stop(); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_SNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_RPC_NETWORK_UNAVAIL); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_RPC_NETWORK_UNAVAIL); } { @@ -187,9 +187,9 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) { pReq->dnodeId = htonl(2); server2.Stop(); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_SNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_SDB_OBJ_CREATING); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_CREATING); } { @@ -200,9 +200,9 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) { pReq->dnodeId = htonl(2); server2.Stop(); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_SNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_SDB_OBJ_CREATING); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_SNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_CREATING); } { @@ -219,9 +219,9 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) { SMCreateSnodeReq* pReq = (SMCreateSnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_SNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - if (pMsg->code == 0) break; + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + if (pRsp->code == 0) break; taosMsleep(1000); } @@ -238,9 +238,9 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) { pReq->dnodeId = htonl(2); server2.Stop(); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_SNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_RPC_NETWORK_UNAVAIL); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_SNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_RPC_NETWORK_UNAVAIL); } { @@ -251,9 +251,9 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) { pReq->dnodeId = htonl(2); server2.Stop(); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_SNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_SDB_OBJ_DROPPING); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_DROPPING); } { @@ -264,9 +264,9 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) { pReq->dnodeId = htonl(2); server2.Stop(); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_SNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_SDB_OBJ_DROPPING); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_SNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_DROPPING); } { @@ -283,9 +283,9 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) { SMCreateSnodeReq* pReq = (SMCreateSnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_SNODE, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - if (pMsg->code == 0) break; + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + if (pRsp->code == 0) break; taosMsleep(1000); } diff --git a/source/dnode/mnode/impl/test/trans/trans.cpp b/source/dnode/mnode/impl/test/trans/trans.cpp index 97a8bd2caf..37c426f573 100644 --- a/source/dnode/mnode/impl/test/trans/trans.cpp +++ b/source/dnode/mnode/impl/test/trans/trans.cpp @@ -58,21 +58,21 @@ TEST_F(MndTestTrans, 01_Create_User_Crash) { strcpy(pReq->user, "u1"); strcpy(pReq->pass, "p1"); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_USER, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } - test.SendShowMetaMsg(TSDB_MGMT_TABLE_USER, ""); + test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); CHECK_META("show users", 4); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 2); KillThenRestartServer(); - test.SendShowMetaMsg(TSDB_MGMT_TABLE_USER, ""); + test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); CHECK_META("show users", 4); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 2); CheckBinary("u1", TSDB_USER_LEN); @@ -83,4 +83,4 @@ TEST_F(MndTestTrans, 01_Create_User_Crash) { CheckTimestamp(); CheckBinary("root", TSDB_USER_LEN); CheckBinary("root", TSDB_USER_LEN); -} \ No newline at end of file +} diff --git a/source/dnode/mnode/impl/test/user/user.cpp b/source/dnode/mnode/impl/test/user/user.cpp index 76954db213..a696158d2b 100644 --- a/source/dnode/mnode/impl/test/user/user.cpp +++ b/source/dnode/mnode/impl/test/user/user.cpp @@ -26,7 +26,7 @@ class MndTestUser : public ::testing::Test { Testbase MndTestUser::test; TEST_F(MndTestUser, 01_Show_User) { - test.SendShowMetaMsg(TSDB_MGMT_TABLE_USER, ""); + test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); CHECK_META("show users", 4); CHECK_SCHEMA(0, TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN + VARSTR_HEADER_SIZE, "name"); @@ -34,7 +34,7 @@ TEST_F(MndTestUser, 01_Show_User) { CHECK_SCHEMA(2, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); CHECK_SCHEMA(3, TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN + VARSTR_HEADER_SIZE, "account"); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 1); CheckBinary("root", TSDB_USER_LEN); @@ -51,9 +51,9 @@ TEST_F(MndTestUser, 02_Create_User) { strcpy(pReq->user, ""); strcpy(pReq->pass, "p1"); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_USER, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_USER_FORMAT); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_USER_FORMAT); } { @@ -63,9 +63,9 @@ TEST_F(MndTestUser, 02_Create_User) { strcpy(pReq->user, "u1"); strcpy(pReq->pass, ""); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_USER, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_PASS_FORMAT); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_PASS_FORMAT); } { @@ -75,9 +75,9 @@ TEST_F(MndTestUser, 02_Create_User) { strcpy(pReq->user, "root"); strcpy(pReq->pass, "1"); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_USER, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_MND_USER_ALREADY_EXIST); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_USER_ALREADY_EXIST); } { @@ -87,15 +87,15 @@ TEST_F(MndTestUser, 02_Create_User) { strcpy(pReq->user, "u1"); strcpy(pReq->pass, "p1"); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_USER, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } - test.SendShowMetaMsg(TSDB_MGMT_TABLE_USER, ""); + test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); CHECK_META("show users", 4); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 2); } @@ -107,9 +107,9 @@ TEST_F(MndTestUser, 03_Alter_User) { strcpy(pReq->user, ""); strcpy(pReq->pass, "p1"); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_ALTER_USER, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_USER_FORMAT); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_USER_FORMAT); } { @@ -119,9 +119,9 @@ TEST_F(MndTestUser, 03_Alter_User) { strcpy(pReq->user, "u1"); strcpy(pReq->pass, ""); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_ALTER_USER, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_PASS_FORMAT); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_PASS_FORMAT); } { @@ -131,9 +131,9 @@ TEST_F(MndTestUser, 03_Alter_User) { strcpy(pReq->user, "u4"); strcpy(pReq->pass, "1"); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_ALTER_USER, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_MND_USER_NOT_EXIST); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_USER_NOT_EXIST); } { @@ -143,9 +143,9 @@ TEST_F(MndTestUser, 03_Alter_User) { strcpy(pReq->user, "u1"); strcpy(pReq->pass, "1"); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_ALTER_USER, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } } @@ -156,9 +156,9 @@ TEST_F(MndTestUser, 04_Drop_User) { SDropUserReq* pReq = (SDropUserReq*)rpcMallocCont(contLen); strcpy(pReq->user, ""); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_USER, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_MND_INVALID_USER_FORMAT); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_USER_FORMAT); } { @@ -167,9 +167,9 @@ TEST_F(MndTestUser, 04_Drop_User) { SDropUserReq* pReq = (SDropUserReq*)rpcMallocCont(contLen); strcpy(pReq->user, "u4"); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_USER, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, TSDB_CODE_MND_USER_NOT_EXIST); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_USER_NOT_EXIST); } { @@ -178,15 +178,15 @@ TEST_F(MndTestUser, 04_Drop_User) { SDropUserReq* pReq = (SDropUserReq*)rpcMallocCont(contLen); strcpy(pReq->user, "u1"); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_USER, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } - test.SendShowMetaMsg(TSDB_MGMT_TABLE_USER, ""); + test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); CHECK_META("show users", 4); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 1); } @@ -198,9 +198,9 @@ TEST_F(MndTestUser, 05_Create_Drop_Alter_User) { strcpy(pReq->user, "u1"); strcpy(pReq->pass, "p1"); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_USER, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } { @@ -210,15 +210,15 @@ TEST_F(MndTestUser, 05_Create_Drop_Alter_User) { strcpy(pReq->user, "u2"); strcpy(pReq->pass, "p2"); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_USER, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } - test.SendShowMetaMsg(TSDB_MGMT_TABLE_USER, ""); + test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); CHECK_META("show users", 4); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 3); CheckBinary("u1", TSDB_USER_LEN); @@ -241,15 +241,15 @@ TEST_F(MndTestUser, 05_Create_Drop_Alter_User) { strcpy(pReq->user, "u1"); strcpy(pReq->pass, "p2"); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_ALTER_USER, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } - test.SendShowMetaMsg(TSDB_MGMT_TABLE_USER, ""); + test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); CHECK_META("show users", 4); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 3); CheckBinary("u1", TSDB_USER_LEN); @@ -271,15 +271,15 @@ TEST_F(MndTestUser, 05_Create_Drop_Alter_User) { SDropUserReq* pReq = (SDropUserReq*)rpcMallocCont(contLen); strcpy(pReq->user, "u1"); - SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_USER, pReq, contLen); - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); } - test.SendShowMetaMsg(TSDB_MGMT_TABLE_USER, ""); + test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); CHECK_META("show users", 4); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 2); CheckBinary("root", TSDB_USER_LEN); @@ -294,10 +294,10 @@ TEST_F(MndTestUser, 05_Create_Drop_Alter_User) { // restart test.Restart(); - test.SendShowMetaMsg(TSDB_MGMT_TABLE_USER, ""); + test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); CHECK_META("show users", 4); - test.SendShowRetrieveMsg(); + test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 2); CheckBinary("root", TSDB_USER_LEN); diff --git a/source/libs/parser/inc/astToMsg.h b/source/libs/parser/inc/astToMsg.h index 30919d25dd..bbb7731261 100644 --- a/source/libs/parser/inc/astToMsg.h +++ b/source/libs/parser/inc/astToMsg.h @@ -8,7 +8,7 @@ SCreateUserReq* buildUserManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id, char* msgBuf, int32_t msgLen); SCreateAcctReq* buildAcctManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id, char* msgBuf, int32_t msgLen); SDropUserReq* buildDropUserMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id, char* msgBuf, int32_t msgLen); -SShowMsg* buildShowMsg(SShowInfo* pShowInfo, SParseBasicCtx* pParseCtx, char* msgBuf, int32_t msgLen); +SShowReq* buildShowMsg(SShowInfo* pShowInfo, SParseBasicCtx* pParseCtx, char* msgBuf, int32_t msgLen); SCreateDbMsg* buildCreateDbMsg(SCreateDbInfo* pCreateDbInfo, SParseBasicCtx *pCtx, SMsgBuf* pMsgBuf); SCreateStbMsg* buildCreateTableMsg(SCreateTableSql* pCreateTableSql, int32_t* len, SParseBasicCtx* pParseCtx, SMsgBuf* pMsgBuf); SDropStbMsg* buildDropStableMsg(SSqlInfo* pInfo, int32_t* len, SParseBasicCtx* pParseCtx, SMsgBuf* pMsgBuf); diff --git a/source/libs/parser/src/astToMsg.c b/source/libs/parser/src/astToMsg.c index ab8c9b8094..81181c34dc 100644 --- a/source/libs/parser/src/astToMsg.c +++ b/source/libs/parser/src/astToMsg.c @@ -85,8 +85,8 @@ SDropUserReq* buildDropUserMsg(SSqlInfo* pInfo, int32_t *msgLen, int64_t id, cha return pMsg; } -SShowMsg* buildShowMsg(SShowInfo* pShowInfo, SParseBasicCtx *pCtx, char* msgBuf, int32_t msgLen) { - SShowMsg* pShowMsg = calloc(1, sizeof(SShowMsg)); +SShowReq* buildShowMsg(SShowInfo* pShowInfo, SParseBasicCtx *pCtx, char* msgBuf, int32_t msgLen) { + SShowReq* pShowMsg = calloc(1, sizeof(SShowReq)); pShowMsg->type = pShowInfo->showType; if (pShowInfo->showType != TSDB_MGMT_TABLE_VNODES) { diff --git a/source/libs/parser/src/dCDAstProcess.c b/source/libs/parser/src/dCDAstProcess.c index 6007fc300c..faaa9924f6 100644 --- a/source/libs/parser/src/dCDAstProcess.c +++ b/source/libs/parser/src/dCDAstProcess.c @@ -109,7 +109,7 @@ static int32_t setShowInfo(SShowInfo* pShowInfo, SParseBasicCtx* pCtx, void** ou *pEpSet = pCtx->mgmtEpSet; *output = buildShowMsg(pShowInfo, pCtx, pMsgBuf->buf, pMsgBuf->len); - *outputLen = sizeof(SShowMsg) /* + htons(pShowMsg->payloadLen)*/; + *outputLen = sizeof(SShowReq) /* + htons(pShowMsg->payloadLen)*/; } return TSDB_CODE_SUCCESS; diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 48127147f8..e0489a76d2 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -603,7 +603,7 @@ int tscBuildAndSendRequest(SSqlObj *pSql, SQueryInfo* pQueryInfo) { } int tscBuildFetchMsg(SSqlObj *pSql, SSqlInfo *pInfo) { - SRetrieveTableMsg *pRetrieveMsg = (SRetrieveTableMsg *) pSql->cmd.payload; + SRetrieveTableReq *pRetrieveMsg = (SRetrieveTableReq *) pSql->cmd.payload; SQueryInfo *pQueryInfo = tscGetQueryInfo(&pSql->cmd); @@ -638,10 +638,10 @@ int tscBuildFetchMsg(SSqlObj *pSql, SSqlInfo *pInfo) { pSql->res.qId); } - pSql->cmd.payloadLen = sizeof(SRetrieveTableMsg); + pSql->cmd.payloadLen = sizeof(SRetrieveTableReq); pSql->cmd.msgType = TDMT_VND_FETCH; - pRetrieveMsg->header.contLen = htonl(sizeof(SRetrieveTableMsg)); + pRetrieveMsg->header.contLen = htonl(sizeof(SRetrieveTableReq)); return TSDB_CODE_SUCCESS; } @@ -1420,7 +1420,7 @@ int32_t tscBuildSyncDbReplicaMsg(SSqlObj* pSql, SSqlInfo *pInfo) { int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) { SSqlCmd *pCmd = &pSql->cmd; pCmd->msgType = TDMT_MND_SHOW; - pCmd->payloadLen = sizeof(SShowMsg) + 100; + pCmd->payloadLen = sizeof(SShowReq) + 100; if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, pCmd->payloadLen)) { tscError("0x%"PRIx64" failed to malloc for query msg", pSql->self); @@ -1428,13 +1428,13 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) { } SShowInfo *pShowInfo = &pInfo->pMiscInfo->showOpt; - SShowMsg *pShowMsg = (SShowMsg *)pCmd->payload; + SShowReq *pShowMsg = (SShowReq *)pCmd->payload; STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, 0); if (pShowInfo->showType == TSDB_MGMT_TABLE_FUNCTION) { pShowMsg->type = pShowInfo->showType; pShowMsg->payloadLen = 0; - pCmd->payloadLen = sizeof(SShowMsg); + pCmd->payloadLen = sizeof(SShowReq); return TSDB_CODE_SUCCESS; } @@ -1463,7 +1463,7 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) { pShowMsg->payloadLen = htons(pEpAddr->n); } - pCmd->payloadLen = sizeof(SShowMsg) + htons(pShowMsg->payloadLen); + pCmd->payloadLen = sizeof(SShowReq) + htons(pShowMsg->payloadLen); return TSDB_CODE_SUCCESS; } @@ -1742,7 +1742,7 @@ int tscBuildCompactMsg(SSqlObj *pSql, SSqlInfo *pInfo) { int tscBuildRetrieveFromMgmtMsg(SSqlObj *pSql, SSqlInfo *pInfo) { SSqlCmd *pCmd = &pSql->cmd; pCmd->msgType = TDMT_MND_SHOW_RETRIEVE; - pCmd->payloadLen = sizeof(SRetrieveTableMsg); + pCmd->payloadLen = sizeof(SRetrieveTableReq); if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, pCmd->payloadLen)) { tscError("0x%"PRIx64" failed to malloc for query msg", pSql->self); @@ -1750,7 +1750,7 @@ int tscBuildRetrieveFromMgmtMsg(SSqlObj *pSql, SSqlInfo *pInfo) { } SQueryInfo *pQueryInfo = tscGetQueryInfo(pCmd); - SRetrieveTableMsg *pRetrieveMsg = (SRetrieveTableMsg*)pCmd->payload; + SRetrieveTableReq *pRetrieveMsg = (SRetrieveTableReq*)pCmd->payload; pRetrieveMsg->qId = htobe64(pSql->res.qId); pRetrieveMsg->free = htons(pQueryInfo->type); From 3c3f32bdae4aa21aa8e37e162817a229269a64f2 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 5 Jan 2022 05:17:16 -0800 Subject: [PATCH 06/18] minor changes --- source/dnode/mgmt/impl/test/qnode/dqnode.cpp | 2 +- source/dnode/mnode/impl/src/mndTrans.c | 21 +++++----- source/dnode/mnode/impl/test/trans/trans.cpp | 42 +++++++++++++++++++- 3 files changed, 53 insertions(+), 12 deletions(-) diff --git a/source/dnode/mgmt/impl/test/qnode/dqnode.cpp b/source/dnode/mgmt/impl/test/qnode/dqnode.cpp index e609783eb0..e64a0543fc 100644 --- a/source/dnode/mgmt/impl/test/qnode/dqnode.cpp +++ b/source/dnode/mgmt/impl/test/qnode/dqnode.cpp @@ -73,7 +73,7 @@ TEST_F(DndTestQnode, 01_Create_Qnode) { } } -TEST_F(DndTestQnode, 01_Drop_Qnode) { +TEST_F(DndTestQnode, 02_Drop_Qnode) { { int32_t contLen = sizeof(SDDropQnodeReq); diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index c1686c2923..11bd15d270 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -24,7 +24,7 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans); static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw); static int32_t mndTransActionInsert(SSdb *pSdb, STrans *pTrans); -static int32_t mndTransActionUpdate(SSdb *pSdb, STrans *OldTrans, STrans *pOldTrans); +static int32_t mndTransActionUpdate(SSdb *pSdb, STrans *OldTrans, STrans *pOld); static int32_t mndTransActionDelete(SSdb *pSdb, STrans *pTrans); static int32_t mndTransAppendLog(SArray *pArray, SSdbRaw *pRaw); @@ -314,9 +314,10 @@ static int32_t mndTransActionDelete(SSdb *pSdb, STrans *pTrans) { return 0; } -static int32_t mndTransActionUpdate(SSdb *pSdb, STrans *pOldTrans, STrans *pNewTrans) { - mTrace("trans:%d, perform update action, old_row:%p new_row:%p", pOldTrans->id, pOldTrans, pNewTrans); - pOldTrans->stage = pNewTrans->stage; +static int32_t mndTransActionUpdate(SSdb *pSdb, STrans *pOld, STrans *pNew) { + mTrace("trans:%d, perform update action, old row:%p stage:%d, new row:%p stage:%d", pOld->id, pOld, pOld->stage, pNew, + pNew->stage); + pOld->stage = pNew->stage; return 0; } @@ -464,16 +465,16 @@ int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans) { } mDebug("trans:%d, prepare finished", pTrans->id); - STrans *pNewTrans = mndAcquireTrans(pMnode, pTrans->id); - if (pNewTrans == NULL) { + STrans *pNew = mndAcquireTrans(pMnode, pTrans->id); + if (pNew == NULL) { mError("trans:%d, failed to read from sdb since %s", pTrans->id, terrstr()); return -1; } - pNewTrans->rpcHandle = pTrans->rpcHandle; - pNewTrans->rpcAHandle = pTrans->rpcAHandle; - mndTransExecute(pMnode, pNewTrans); - mndReleaseTrans(pMnode, pNewTrans); + pNew->rpcHandle = pTrans->rpcHandle; + pNew->rpcAHandle = pTrans->rpcAHandle; + mndTransExecute(pMnode, pNew); + mndReleaseTrans(pMnode, pNew); return 0; } diff --git a/source/dnode/mnode/impl/test/trans/trans.cpp b/source/dnode/mnode/impl/test/trans/trans.cpp index 37c426f573..eef94436b7 100644 --- a/source/dnode/mnode/impl/test/trans/trans.cpp +++ b/source/dnode/mnode/impl/test/trans/trans.cpp @@ -10,7 +10,6 @@ */ #include "sut.h" -#include "os.h" class MndTestTrans : public ::testing::Test { protected: @@ -84,3 +83,44 @@ TEST_F(MndTestTrans, 01_Create_User_Crash) { CheckBinary("root", TSDB_USER_LEN); CheckBinary("root", TSDB_USER_LEN); } + +TEST_F(MndTestTrans, 02_Create_Qnode_Crash) { + { + int32_t contLen = sizeof(SMCreateQnodeReq); + + SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen); + pReq->dnodeId = htonl(1); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); + + test.SendShowMetaReq(TSDB_MGMT_TABLE_QNODE, ""); + CHECK_META("show qnodes", 3); + test.SendShowRetrieveReq(); + EXPECT_EQ(test.GetShowRows(), 1); + } + + KillThenRestartServer(); + { + int32_t retry = 0; + int32_t retryMax = 10; + + for (retry = 0; retry < retryMax; retry++) { + int32_t contLen = sizeof(SMCreateQnodeReq); + + SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen); + pReq->dnodeId = htonl(2); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + if (pRsp->code == 0) break; + taosMsleep(1000); + } + + test.SendShowMetaReq(TSDB_MGMT_TABLE_QNODE, ""); + CHECK_META("show qnodes", 3); + test.SendShowRetrieveReq(); + EXPECT_EQ(test.GetShowRows(), 1); + } +} \ No newline at end of file From 2e0dc58890c07708074bfe29a022a60a9573ae4e Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 5 Jan 2022 22:56:08 +0800 Subject: [PATCH 07/18] refactor code --- source/libs/index/inc/index_cache.h | 2 +- source/libs/index/src/index_cache.c | 13 ++++++++----- source/libs/index/src/index_tfile.c | 3 --- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/source/libs/index/inc/index_cache.h b/source/libs/index/inc/index_cache.h index 805137ccaf..58082294a9 100644 --- a/source/libs/index/inc/index_cache.h +++ b/source/libs/index/inc/index_cache.h @@ -40,7 +40,7 @@ typedef struct IndexCache { SIndex* index; char* colName; int32_t version; - int32_t nTerm; + int64_t occupiedMem; int8_t type; uint64_t suid; diff --git a/source/libs/index/src/index_cache.c b/source/libs/index/src/index_cache.c index ca1d9e3fa4..7a4beb2119 100644 --- a/source/libs/index/src/index_cache.c +++ b/source/libs/index/src/index_cache.c @@ -21,6 +21,8 @@ #define MAX_INDEX_KEY_LEN 256 // test only, change later #define MEM_TERM_LIMIT 10 * 10000 +#define MEM_THRESHOLD 1024 * 1024 * 2 +#define MEM_ESTIMATE_RADIO 1.5 static void indexMemRef(MemTable* tbl); static void indexMemUnRef(MemTable* tbl); @@ -50,6 +52,7 @@ IndexCache* indexCacheCreate(SIndex* idx, uint64_t suid, const char* colName, in cache->index = idx; cache->version = 0; cache->suid = suid; + cache->occupiedMem = 0; pthread_mutex_init(&cache->mtx, NULL); indexCacheRef(cache); return cache; @@ -173,8 +176,7 @@ int indexCacheSchedToMerge(IndexCache* pCache) { } static void indexCacheMakeRoomForWrite(IndexCache* cache) { while (true) { - if (cache->nTerm < MEM_TERM_LIMIT) { - cache->nTerm += 1; + if (cache->occupiedMem * MEM_ESTIMATE_RADIO < MEM_THRESHOLD) { break; } else if (cache->imm != NULL) { // TODO: wake up by condition variable @@ -185,7 +187,7 @@ static void indexCacheMakeRoomForWrite(IndexCache* cache) { indexCacheRef(cache); cache->imm = cache->mem; cache->mem = indexInternalCacheCreate(cache->type); - cache->nTerm = 1; + cache->occupiedMem = 0; // sched to merge // unref cache in bgwork indexCacheSchedToMerge(cache); @@ -211,8 +213,9 @@ int indexCachePut(void* cache, SIndexTerm* term, uint64_t uid) { ct->operaType = term->operType; // ugly code, refactor later + int64_t estimate = sizeof(ct) + strlen(ct->colVal); pthread_mutex_lock(&pCache->mtx); - + pCache->occupiedMem += estimate; indexCacheMakeRoomForWrite(pCache); MemTable* tbl = pCache->mem; indexMemRef(tbl); @@ -333,7 +336,7 @@ static int32_t compareKey(const void* l, const void* r) { static MemTable* indexInternalCacheCreate(int8_t type) { MemTable* tbl = calloc(1, sizeof(MemTable)); indexMemRef(tbl); - if (type == TSDB_DATA_TYPE_BINARY) { + if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) { tbl->mem = tSkipListCreate(MAX_SKIP_LIST_LEVEL, type, MAX_INDEX_KEY_LEN, compareKey, SL_ALLOW_DUP_KEY, getIndexKey); } return tbl; diff --git a/source/libs/index/src/index_tfile.c b/source/libs/index/src/index_tfile.c index 6437991358..90a730d3a9 100644 --- a/source/libs/index/src/index_tfile.c +++ b/source/libs/index/src/index_tfile.c @@ -346,9 +346,6 @@ int indexTFilePut(void* tfile, SIndexTerm* term, uint64_t uid) { } static bool tfileIteratorNext(Iterate* iiter) { IterateValue* iv = &iiter->val; - if (iv->colVal != NULL && iv->val != NULL) { - // indexError("value in fst: colVal: %s, size: %d", iv->colVal, (int)taosArrayGetSize(iv->val)); - } iterateValueDestroy(iv, false); char* colVal = NULL; From ccbbac4eefdc79bef9c6387d7c54e7adc4c46b52 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 5 Jan 2022 23:54:05 +0800 Subject: [PATCH 08/18] refactor code --- source/libs/index/inc/index_cache.h | 1 + source/libs/index/src/index.c | 17 +++++++++++++++-- source/libs/index/src/index_cache.c | 14 +++++++++++--- source/libs/index/test/indexTests.cc | 6 +++--- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/source/libs/index/inc/index_cache.h b/source/libs/index/inc/index_cache.h index 58082294a9..544849ff2f 100644 --- a/source/libs/index/inc/index_cache.h +++ b/source/libs/index/inc/index_cache.h @@ -45,6 +45,7 @@ typedef struct IndexCache { uint64_t suid; pthread_mutex_t mtx; + pthread_cond_t finished; } IndexCache; #define CACHE_VERSION(cache) atomic_load_32(&cache->version) diff --git a/source/libs/index/src/index.c b/source/libs/index/src/index.c index 9b7f1c8383..0bf30d6efa 100644 --- a/source/libs/index/src/index.c +++ b/source/libs/index/src/index.c @@ -399,6 +399,8 @@ int indexFlushCacheTFile(SIndex* sIdx, void* cache) { if (sIdx == NULL) { return -1; } indexInfo("suid %" PRIu64 " merge cache into tindex", sIdx->suid); + int64_t st = taosGetTimestampUs(); + IndexCache* pCache = (IndexCache*)cache; TFileReader* pReader = tfileGetReaderByCol(sIdx->tindex, pCache->suid, pCache->colName); if (pReader == NULL) { indexWarn("empty tfile reader found"); } @@ -458,6 +460,7 @@ int indexFlushCacheTFile(SIndex* sIdx, void* cache) { } int ret = indexGenTFile(sIdx, pCache, result); indexDestroyTempResult(result); + indexCacheDestroyImm(pCache); indexCacheIteratorDestroy(cacheIter); @@ -465,7 +468,14 @@ int indexFlushCacheTFile(SIndex* sIdx, void* cache) { tfileReaderUnRef(pReader); indexCacheUnRef(pCache); - return 0; + + int64_t cost = taosGetTimestampUs() - st; + if (ret != 0) { + indexError("failed to merge, time cost: %" PRId64 "ms", cost / 1000); + } else { + indexInfo("success to merge , time cost: %" PRId64 "ms", cost / 1000); + } + return ret; } void iterateValueDestroy(IterateValue* value, bool destroy) { if (destroy) { @@ -506,7 +516,10 @@ static int indexGenTFile(SIndex* sIdx, IndexCache* cache, SArray* batch) { pthread_mutex_unlock(&sIdx->mtx); return ret; END: - tfileWriterClose(tw); + if (tw != NULL) { + writerCtxDestroy(tw->ctx, true); + free(tw); + } return -1; } diff --git a/source/libs/index/src/index_cache.c b/source/libs/index/src/index_cache.c index 7a4beb2119..d43c9f9cce 100644 --- a/source/libs/index/src/index_cache.c +++ b/source/libs/index/src/index_cache.c @@ -53,7 +53,10 @@ IndexCache* indexCacheCreate(SIndex* idx, uint64_t suid, const char* colName, in cache->version = 0; cache->suid = suid; cache->occupiedMem = 0; + pthread_mutex_init(&cache->mtx, NULL); + pthread_cond_init(&cache->finished, NULL); + indexCacheRef(cache); return cache; } @@ -124,6 +127,7 @@ void indexCacheDestroyImm(IndexCache* cache) { pthread_mutex_lock(&cache->mtx); tbl = cache->imm; cache->imm = NULL; // or throw int bg thread + pthread_cond_broadcast(&cache->finished); pthread_mutex_unlock(&cache->mtx); indexMemUnRef(tbl); @@ -136,6 +140,9 @@ void indexCacheDestroy(void* cache) { indexMemUnRef(pCache->imm); free(pCache->colName); + pthread_mutex_destroy(&pCache->mtx); + pthread_cond_destroy(&pCache->finished); + free(pCache); } @@ -180,9 +187,10 @@ static void indexCacheMakeRoomForWrite(IndexCache* cache) { break; } else if (cache->imm != NULL) { // TODO: wake up by condition variable - pthread_mutex_unlock(&cache->mtx); - taosMsleep(50); - pthread_mutex_lock(&cache->mtx); + // pthread_mutex_unlock(&cache->mtx); + pthread_cond_wait(&cache->finished, &cache->mtx); + // taosMsleep(50); + // pthread_mutex_lock(&cache->mtx); } else { indexCacheRef(cache); cache->imm = cache->mem; diff --git a/source/libs/index/test/indexTests.cc b/source/libs/index/test/indexTests.cc index 9c92af26a2..5438f88b76 100644 --- a/source/libs/index/test/indexTests.cc +++ b/source/libs/index/test/indexTests.cc @@ -28,7 +28,7 @@ #include "tutil.h" using namespace std; -#define NUM_OF_THREAD 5 +#define NUM_OF_THREAD 10 class DebugInfo { public: @@ -882,8 +882,8 @@ static void single_write_and_search(IndexObj* idx) { static void multi_write_and_search(IndexObj* idx) { int target = idx->SearchOne("tag1", "Hello"); target = idx->SearchOne("tag2", "Test"); - idx->WriteMultiMillonData("tag1", "Hello", 100 * 10000); - idx->WriteMultiMillonData("tag2", "Test", 100 * 10000); + idx->WriteMultiMillonData("tag1", "hello world test", 100 * 10000); + idx->WriteMultiMillonData("tag2", "world test nothing", 100 * 10000); } TEST_F(IndexEnv2, testIndex_serarch_cache_and_tfile) { std::string path = "/tmp/cache_and_tfile"; From 308faffccd9dd33237fba50816a0ab21da420c88 Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Thu, 6 Jan 2022 10:18:17 +0800 Subject: [PATCH 09/18] [TD-12758]add unit test in 3.0 CI --- Jenkinsfile | 221 +----------------- .../dnode/mgmt/impl/test/profile/profile.cpp | 2 +- 2 files changed, 3 insertions(+), 220 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c47d37a9a0..ef6e7d67b2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -109,228 +109,11 @@ pipeline { sh''' cd ${WKC}/tests ./test-all.sh b1fq + cd ${WKC}/debug + ctest ''' } } - // stage('Parallel test stage') { - // skip defaultCheckout - // options { skipDefaultCheckout() } - // when { - // allOf{ - // changeRequest() - - // } - // } - // parallel { - // stage('python_1_s1') { - // agent{label " slave1 || slave11 "} - // steps { - - // pre_test() - // // timeout(time: 55, unit: 'MINUTES'){ - // // sh ''' - // // date - // // cd ${WKC}/tests - // // ./test-all.sh p1 - // // date''' - // // } - - // } - // } - // stage('python_2_s5') { - // agent{label " slave5 || slave15 "} - // steps { - - // pre_test() - // // timeout(time: 55, unit: 'MINUTES'){ - // // sh ''' - // // date - // // cd ${WKC}/tests - // // ./test-all.sh p2 - // // date''' - // // } - // } - // } - // stage('python_3_s6') { - // agent{label " slave6 || slave16 "} - // steps { - // pre_test() - // // timeout(time: 55, unit: 'MINUTES'){ - - // // sh ''' - // // date - // // cd ${WKC}/tests - // // ./test-all.sh p3 - // // date''' - // // } - // } - // } - // stage('test_b1_s2') { - // agent{label " slave2 || slave12 "} - // steps { - // pre_test() - // // timeout(time: 55, unit: 'MINUTES'){ - - // // sh ''' - // // rm -rf /var/lib/taos/* - // // rm -rf /var/log/taos/* - // // nohup taosd >/dev/null & - // // sleep 10 - // // ''' - // // sh ''' - // // cd ${WKC}/tests/examples/nodejs - // // npm install td2.0-connector > /dev/null 2>&1 - // // node nodejsChecker.js host=localhost - // // node test1970.js - // // cd ${WKC}/tests/connectorTest/nodejsTest/nanosupport - // // npm install td2.0-connector > /dev/null 2>&1 - // // node nanosecondTest.js - - // // ''' - // // sh ''' - // // cd ${WKC}/tests/examples/C#/taosdemo - // // mcs -out:taosdemo *.cs > /dev/null 2>&1 - // // echo '' |./taosdemo -c /etc/taos - // // cd ${WKC}/tests/connectorTest/C#Test/nanosupport - // // mcs -out:nano *.cs > /dev/null 2>&1 - // // echo '' |./nano - // // ''' - // // sh ''' - // // cd ${WKC}/tests/gotest - // // bash batchtest.sh - // // ''' - // // sh ''' - // // cd ${WKC}/tests - // // ./test-all.sh b1fq - // // date''' - // // } - // } - // } - // stage('test_crash_gen_s3') { - // agent{label " slave3 || slave13 "} - - // steps { - // pre_test() - // // timeout(time: 60, unit: 'MINUTES'){ - // // sh ''' - // // cd ${WKC}/tests/pytest - // // ./crash_gen.sh -a -p -t 4 -s 2000 - // // ''' - // // } - // // timeout(time: 60, unit: 'MINUTES'){ - // // // sh ''' - // // // cd ${WKC}/tests/pytest - // // // rm -rf /var/lib/taos/* - // // // rm -rf /var/log/taos/* - // // // ./handle_crash_gen_val_log.sh - // // // ''' - // // sh ''' - // // cd ${WKC}/tests/pytest - // // rm -rf /var/lib/taos/* - // // rm -rf /var/log/taos/* - // // ./handle_taosd_val_log.sh - // // ''' - // // } - // // timeout(time: 55, unit: 'MINUTES'){ - // // sh ''' - // // date - // // cd ${WKC}/tests - // // ./test-all.sh b2fq - // // date - // // ''' - // // } - // } - // } - // stage('test_valgrind_s4') { - // agent{label " slave4 || slave14 "} - - // steps { - // pre_test() - // // catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { - // // sh ''' - // // cd ${WKC}/tests/pytest - // // ./valgrind-test.sh 2>&1 > mem-error-out.log - // // ./handle_val_log.sh - // // ''' - // // } - // // timeout(time: 55, unit: 'MINUTES'){ - // // sh ''' - // // date - // // cd ${WKC}/tests - // // ./test-all.sh b3fq - // // date''' - // // sh ''' - // // date - // // cd ${WKC}/tests - // // ./test-all.sh full example - // // date''' - // // } - // } - // } - // stage('test_b4_s7') { - // agent{label " slave7 || slave17 "} - // steps { - // pre_test() - // // timeout(time: 55, unit: 'MINUTES'){ - - // // sh ''' - // // date - // // cd ${WKC}/tests - // // ./test-all.sh b4fq - // // cd ${WKC}/tests - // // ./test-all.sh p4 - // // cd ${WKC}/tests - // // ./test-all.sh full jdbc - // // cd ${WKC}/tests - // // ./test-all.sh full unit - // // date''' - // // } - // } - // } - // stage('test_b5_s8') { - // agent{label " slave8 || slave18 "} - // steps { - // pre_test() - // // timeout(time: 55, unit: 'MINUTES'){ - - // // sh ''' - // // date - // // cd ${WKC}/tests - // // ./test-all.sh b5fq - // // date''' - // // } - // } - // } - // stage('test_b6_s9') { - // agent{label " slave9 || slave19 "} - // steps { - // pre_test() - // // timeout(time: 55, unit: 'MINUTES'){ - - // // sh ''' - // // date - // // cd ${WKC}/tests - // // ./test-all.sh b6fq - // // date''' - // // } - // } - // } - // stage('test_b7_s10') { - // agent{label " slave10 || slave20 "} - // steps { - // pre_test() - // // timeout(time: 55, unit: 'MINUTES'){ - - // // sh ''' - // // date - // // cd ${WKC}/tests - // // ./test-all.sh b7fq - // // date''' - // // } - // } - // } - // } - // } } post { success { diff --git a/source/dnode/mgmt/impl/test/profile/profile.cpp b/source/dnode/mgmt/impl/test/profile/profile.cpp index 29b71f1c27..48bd0d1bbf 100644 --- a/source/dnode/mgmt/impl/test/profile/profile.cpp +++ b/source/dnode/mgmt/impl/test/profile/profile.cpp @@ -117,7 +117,7 @@ TEST_F(DndTestProfile, 04_HeartBeatMsg) { pRsp->totalDnodes = htonl(pRsp->totalDnodes); pRsp->onlineDnodes = htonl(pRsp->onlineDnodes); pRsp->epSet.port[0] = htons(pRsp->epSet.port[0]); - + EXPECT_EQ(1,0); EXPECT_EQ(pRsp->connId, connId); EXPECT_EQ(pRsp->queryId, 0); EXPECT_EQ(pRsp->streamId, 0); From d7fc6e17f99753c6e8f5d0666b322139e7a3b770 Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Thu, 6 Jan 2022 10:26:22 +0800 Subject: [PATCH 10/18] revert --- source/dnode/mgmt/impl/test/profile/profile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/dnode/mgmt/impl/test/profile/profile.cpp b/source/dnode/mgmt/impl/test/profile/profile.cpp index 48bd0d1bbf..29b71f1c27 100644 --- a/source/dnode/mgmt/impl/test/profile/profile.cpp +++ b/source/dnode/mgmt/impl/test/profile/profile.cpp @@ -117,7 +117,7 @@ TEST_F(DndTestProfile, 04_HeartBeatMsg) { pRsp->totalDnodes = htonl(pRsp->totalDnodes); pRsp->onlineDnodes = htonl(pRsp->onlineDnodes); pRsp->epSet.port[0] = htons(pRsp->epSet.port[0]); - EXPECT_EQ(1,0); + EXPECT_EQ(pRsp->connId, connId); EXPECT_EQ(pRsp->queryId, 0); EXPECT_EQ(pRsp->streamId, 0); From 0d4169102caf196ce3dc3003f9bd07033924fd4f Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Thu, 6 Jan 2022 10:27:00 +0800 Subject: [PATCH 11/18] udpate --- Jenkinsfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index ef6e7d67b2..23dc54d963 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -109,6 +109,8 @@ pipeline { sh''' cd ${WKC}/tests ./test-all.sh b1fq + ''' + sh''' cd ${WKC}/debug ctest ''' From 0ba5427a9bef40ee25b047c9302732600c30dcd9 Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Thu, 6 Jan 2022 10:28:34 +0800 Subject: [PATCH 12/18] handle subscribe --- include/common/tmsgdef.h | 1 + include/util/taoserror.h | 2 + source/dnode/mnode/impl/inc/mndConsumer.h | 7 +- source/dnode/mnode/impl/inc/mndDef.h | 85 +++-- source/dnode/mnode/impl/inc/mndTopic.h | 7 +- source/dnode/mnode/impl/src/mndConsumer.c | 416 +++++++++++++--------- source/dnode/mnode/impl/src/mndTopic.c | 105 +++--- source/libs/wal/src/walMeta.c | 3 + source/libs/wal/src/walRead.c | 13 +- source/libs/wal/src/walSeek.c | 9 +- source/libs/wal/src/walWrite.c | 2 + 11 files changed, 385 insertions(+), 265 deletions(-) diff --git a/include/common/tmsgdef.h b/include/common/tmsgdef.h index d6071ebcf3..592672b32b 100644 --- a/include/common/tmsgdef.h +++ b/include/common/tmsgdef.h @@ -159,6 +159,7 @@ enum { TD_DEF_MSG_TYPE(TDMT_VND_MQ_QUERY, "vnode-mq-query", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_MQ_CONNECT, "vnode-mq-connect", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_MQ_DISCONNECT, "vnode-mq-disconnect", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_VND_MQ_SET_CONN, "vnode-mq-set-conn", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_MQ_SET_CUR, "vnode-mq-set-cur", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_RES_READY, "vnode-res-ready", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_TASKS_STATUS, "vnode-tasks-status", NULL, NULL) diff --git a/include/util/taoserror.h b/include/util/taoserror.h index ae36ac7216..a10dd8eda2 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -400,6 +400,8 @@ int32_t* taosGetErrno(); #define TSDB_CODE_WAL_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x1000) //"Unexpected generic error in wal") #define TSDB_CODE_WAL_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x1001) //"WAL file is corrupted") #define TSDB_CODE_WAL_SIZE_LIMIT TAOS_DEF_ERROR_CODE(0, 0x1002) //"WAL size exceeds limit") +#define TSDB_CODE_WAL_INVALID_VER TAOS_DEF_ERROR_CODE(0, 0x1003) //"WAL invalid version") +#define TSDB_CODE_WAL_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x1004) //"WAL out of memory") // tfs #define TSDB_CODE_FS_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x2200) //"tfs out of memory") diff --git a/source/dnode/mnode/impl/inc/mndConsumer.h b/source/dnode/mnode/impl/inc/mndConsumer.h index 60f186d7d2..68ba08b66e 100644 --- a/source/dnode/mnode/impl/inc/mndConsumer.h +++ b/source/dnode/mnode/impl/inc/mndConsumer.h @@ -25,11 +25,8 @@ extern "C" { int32_t mndInitConsumer(SMnode *pMnode); void mndCleanupConsumer(SMnode *pMnode); -SConsumerObj *mndAcquireConsumer(SMnode *pMnode, int32_t consumerId); -void mndReleaseConsumer(SMnode *pMnode, SConsumerObj *pConsumer); - -SCGroupObj *mndAcquireCGroup(SMnode *pMnode, char *consumerGroup); -void mndReleaseCGroup(SMnode *pMnode, SCGroupObj *pCGroup); +SMqConsumerObj *mndAcquireConsumer(SMnode *pMnode, int32_t consumerId); +void mndReleaseConsumer(SMnode *pMnode, SMqConsumerObj *pConsumer); #ifdef __cplusplus } diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index 1af9b840a9..b490eeac96 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -302,6 +302,7 @@ typedef struct { char payload[]; } SShowObj; +#if 0 typedef struct SConsumerObj { uint64_t uid; int64_t createTime; @@ -309,17 +310,59 @@ typedef struct SConsumerObj { //uint64_t dbUid; int32_t version; SRWLatch lock; - SList* topics; + SArray* topics; } SConsumerObj; +typedef struct SMqTopicConsumer { + int64_t consumerId; + SList* topicList; +} SMqTopicConsumer; +#endif + +typedef struct SMqCGroup { + char name[TSDB_CONSUMER_GROUP_LEN]; + int32_t status; // 0 - uninitialized, 1 - wait rebalance, 2- normal + SList *consumerIds; // SList + SList *idleVGroups; // SList +} SMqCGroup; + +typedef struct SMqTopicObj { + char name[TSDB_TOPIC_FNAME_LEN]; + char db[TSDB_DB_FNAME_LEN]; + int64_t createTime; + int64_t updateTime; + uint64_t uid; + uint64_t dbUid; + int32_t version; + SRWLatch lock; + int32_t sqlLen; + char *sql; + char *logicalPlan; + char *physicalPlan; + SHashObj *cgroups; // SHashObj +} SMqTopicObj; + +// TODO: add cache and change name to id +typedef struct SMqConsumerTopic { + char name[TSDB_TOPIC_FNAME_LEN]; + SList *vgroups; // SList +} SMqConsumerTopic; + +typedef struct SMqConsumerObj { + SRWLatch lock; + int64_t consumerId; + char cgroup[TSDB_CONSUMER_GROUP_LEN]; + SArray *topics; // SArray +} SMqConsumerObj; + typedef struct SMqSubConsumerObj { int64_t consumerUid; // if -1, unassigned - SList* vgId; //SList + SList *vgId; // SList } SMqSubConsumerObj; typedef struct SMqSubCGroupObj { char name[TSDB_CONSUMER_GROUP_LEN]; - SList* consumers; //SList + SList *consumers; // SList } SMqSubCGroupObj; typedef struct SMqSubTopicObj { @@ -332,32 +375,33 @@ typedef struct SMqSubTopicObj { int32_t version; SRWLatch lock; int32_t sqlLen; - char* sql; - char* logicalPlan; - char* physicalPlan; - SList* cgroups; //SList + char *sql; + char *logicalPlan; + char *physicalPlan; + SList *cgroups; // SList } SMqSubTopicObj; typedef struct SMqConsumerSubObj { int64_t topicUid; - SList* vgIds; //SList + SList *vgIds; // SList } SMqConsumerSubObj; typedef struct SMqConsumerHbObj { int64_t consumerId; - SList* consumerSubs; //SList + SList *consumerSubs; // SList } SMqConsumerHbObj; typedef struct SMqVGroupSubObj { int64_t topicUid; - SList* consumerIds; //SList + SList *consumerIds; // SList } SMqVGroupSubObj; typedef struct SMqVGroupHbObj { int64_t vgId; - SList* vgSubs; //SList + SList *vgSubs; // SList } SMqVGroupHbObj; +#if 0 typedef struct SCGroupObj { char name[TSDB_TOPIC_FNAME_LEN]; int64_t createTime; @@ -368,24 +412,7 @@ typedef struct SCGroupObj { SRWLatch lock; SList* consumerIds; } SCGroupObj; - -typedef struct { - char name[TSDB_TOPIC_FNAME_LEN]; - char db[TSDB_DB_FNAME_LEN]; - int64_t createTime; - int64_t updateTime; - uint64_t uid; - uint64_t dbUid; - int32_t version; - SRWLatch lock; - int32_t execLen; - void* executor; - int32_t sqlLen; - char* sql; - char* logicalPlan; - char* physicalPlan; - SList* consumerIds; -} STopicObj; +#endif typedef struct SMnodeMsg { char user[TSDB_USER_LEN]; diff --git a/source/dnode/mnode/impl/inc/mndTopic.h b/source/dnode/mnode/impl/inc/mndTopic.h index d092f47d4b..fd82c60d37 100644 --- a/source/dnode/mnode/impl/inc/mndTopic.h +++ b/source/dnode/mnode/impl/inc/mndTopic.h @@ -25,8 +25,11 @@ extern "C" { int32_t mndInitTopic(SMnode *pMnode); void mndCleanupTopic(SMnode *pMnode); -STopicObj *mndAcquireTopic(SMnode *pMnode, char *topicName); -void mndReleaseTopic(SMnode *pMnode, STopicObj *pTopic); +SMqTopicObj *mndAcquireTopic(SMnode *pMnode, char *topicName); +void mndReleaseTopic(SMnode *pMnode, SMqTopicObj *pTopic); + +SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic); +SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw); #ifdef __cplusplus } diff --git a/source/dnode/mnode/impl/src/mndConsumer.c b/source/dnode/mnode/impl/src/mndConsumer.c index 5391b0f73e..eeb011c084 100644 --- a/source/dnode/mnode/impl/src/mndConsumer.c +++ b/source/dnode/mnode/impl/src/mndConsumer.c @@ -24,16 +24,17 @@ #include "mndTrans.h" #include "mndUser.h" #include "mndVgroup.h" +#include "tcompare.h" #include "tname.h" #define MND_CONSUMER_VER_NUMBER 1 #define MND_CONSUMER_RESERVE_SIZE 64 -static SSdbRaw *mndConsumerActionEncode(SConsumerObj *pConsumer); +static SSdbRaw *mndConsumerActionEncode(SMqConsumerObj *pConsumer); static SSdbRow *mndConsumerActionDecode(SSdbRaw *pRaw); -static int32_t mndConsumerActionInsert(SSdb *pSdb, SConsumerObj *pConsumer); -static int32_t mndConsumerActionDelete(SSdb *pSdb, SConsumerObj *pConsumer); -static int32_t mndConsumerActionUpdate(SSdb *pSdb, SConsumerObj *pConsumer, SConsumerObj *pNewConsumer); +static int32_t mndConsumerActionInsert(SSdb *pSdb, SMqConsumerObj *pConsumer); +static int32_t mndConsumerActionDelete(SSdb *pSdb, SMqConsumerObj *pConsumer); +static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pConsumer, SMqConsumerObj *pNewConsumer); static int32_t mndProcessCreateConsumerMsg(SMnodeMsg *pMsg); static int32_t mndProcessDropConsumerMsg(SMnodeMsg *pMsg); static int32_t mndProcessDropConsumerInRsp(SMnodeMsg *pMsg); @@ -57,8 +58,8 @@ int32_t mndInitConsumer(SMnode *pMnode) { .deleteFp = (SdbDeleteFp)mndConsumerActionDelete}; mndSetMsgHandle(pMnode, TDMT_MND_SUBSCRIBE, mndProcessSubscribeReq); - mndSetMsgHandle(pMnode, TDMT_MND_SUBSCRIBE_RSP, mndProcessSubscribeRsp); - mndSetMsgHandle(pMnode, TDMT_VND_SUBSCRIBE, mndProcessSubscribeInternalReq); + /*mndSetMsgHandle(pMnode, TDMT_MND_SUBSCRIBE_RSP, mndProcessSubscribeRsp);*/ + /*mndSetMsgHandle(pMnode, TDMT_VND_SUBSCRIBE, mndProcessSubscribeInternalReq);*/ mndSetMsgHandle(pMnode, TDMT_VND_SUBSCRIBE_RSP, mndProcessSubscribeInternalRsp); return sdbSetTable(pMnode->pSdb, table); @@ -66,85 +67,41 @@ int32_t mndInitConsumer(SMnode *pMnode) { void mndCleanupConsumer(SMnode *pMnode) {} -static SSdbRaw *mndCGroupActionEncode(SCGroupObj *pCGroup) { - int32_t size = sizeof(SConsumerObj) + MND_CONSUMER_RESERVE_SIZE; +static void *mndBuildMqVGroupSetReq(SMnode *pMnode, char *topicName, int32_t vgId, int64_t consumerId, char *cgroup) { + return 0; +} + +static SSdbRaw *mndConsumerActionEncode(SMqConsumerObj *pConsumer) { + int32_t size = sizeof(SMqConsumerObj) + MND_CONSUMER_RESERVE_SIZE; SSdbRaw *pRaw = sdbAllocRaw(SDB_CONSUMER, MND_CONSUMER_VER_NUMBER, size); if (pRaw == NULL) return NULL; int32_t dataPos = 0; - SDB_SET_BINARY(pRaw, dataPos, pCGroup->name, TSDB_TABLE_FNAME_LEN); - SDB_SET_INT64(pRaw, dataPos, pCGroup->createTime); - SDB_SET_INT64(pRaw, dataPos, pCGroup->updateTime); - SDB_SET_INT64(pRaw, dataPos, pCGroup->uid); - /*SDB_SET_INT64(pRaw, dataPos, pConsumer->dbUid);*/ - SDB_SET_INT32(pRaw, dataPos, pCGroup->version); - - int32_t sz = listNEles(pCGroup->consumerIds); - SDB_SET_INT32(pRaw, dataPos, sz); - - SListIter iter; - tdListInitIter(pCGroup->consumerIds, &iter, TD_LIST_FORWARD); - SListNode *pn = NULL; - while ((pn = tdListNext(&iter)) != NULL) { - int64_t consumerId = *(int64_t *)pn->data; - SDB_SET_INT64(pRaw, dataPos, consumerId); + int32_t topicNum = taosArrayGetSize(pConsumer->topics); + SDB_SET_INT64(pRaw, dataPos, pConsumer->consumerId); + int32_t len = strlen(pConsumer->cgroup); + SDB_SET_INT32(pRaw, dataPos, len); + SDB_SET_BINARY(pRaw, dataPos, pConsumer->cgroup, len); + SDB_SET_INT32(pRaw, dataPos, topicNum); + for (int i = 0; i < topicNum; i++) { + int32_t len; + SMqConsumerTopic *pConsumerTopic = taosArrayGet(pConsumer->topics, i); + len = strlen(pConsumerTopic->name); + SDB_SET_INT32(pRaw, dataPos, len); + SDB_SET_BINARY(pRaw, dataPos, pConsumerTopic->name, len); + int vgSize; + if (pConsumerTopic->vgroups == NULL) { + vgSize = 0; + } else { + vgSize = listNEles(pConsumerTopic->vgroups); + } + SDB_SET_INT32(pRaw, dataPos, vgSize); + for (int j = 0; j < vgSize; j++) { + // SList* head; + /*SDB_SET_INT64(pRaw, dataPos, 0[> change to list item <]);*/ + } } - SDB_SET_RESERVE(pRaw, dataPos, MND_CONSUMER_RESERVE_SIZE); - SDB_SET_DATALEN(pRaw, dataPos); - return pRaw; -} - -static SSdbRow *mndCGroupActionDecode(SSdbRaw *pRaw) { - int8_t sver = 0; - if (sdbGetRawSoftVer(pRaw, &sver) != 0) return NULL; - - if (sver != MND_CONSUMER_VER_NUMBER) { - terrno = TSDB_CODE_SDB_INVALID_DATA_VER; - mError("failed to decode cgroup since %s", terrstr()); - return NULL; - } - - // TODO: maximum size is not known - int32_t size = sizeof(SCGroupObj) + 128 * sizeof(int64_t); - SSdbRow *pRow = sdbAllocRow(size); - SCGroupObj *pCGroup = sdbGetRowObj(pRow); - if (pCGroup == NULL) return NULL; - - int32_t dataPos = 0; - SDB_GET_BINARY(pRaw, pRow, dataPos, pCGroup->name, TSDB_TABLE_FNAME_LEN); - SDB_GET_INT64(pRaw, pRow, dataPos, &pCGroup->createTime); - SDB_GET_INT64(pRaw, pRow, dataPos, &pCGroup->updateTime); - SDB_GET_INT64(pRaw, pRow, dataPos, &pCGroup->uid); - /*SDB_GET_INT64(pRaw, pRow, dataPos, &pConsumer->dbUid);*/ - SDB_GET_INT32(pRaw, pRow, dataPos, &pCGroup->version); - - int32_t sz; - SDB_GET_INT32(pRaw, pRow, dataPos, &sz); - // TODO: free list when failing - tdListInit(pCGroup->consumerIds, sizeof(int64_t)); - for (int i = 0; i < sz; i++) { - int64_t consumerId; - SDB_GET_INT64(pRaw, pRow, dataPos, &consumerId); - tdListAppend(pCGroup->consumerIds, &consumerId); - } - - SDB_GET_RESERVE(pRaw, pRow, dataPos, MND_CONSUMER_RESERVE_SIZE); - return pRow; -} - -static SSdbRaw *mndConsumerActionEncode(SConsumerObj *pConsumer) { - int32_t size = sizeof(SConsumerObj) + MND_CONSUMER_RESERVE_SIZE; - SSdbRaw *pRaw = sdbAllocRaw(SDB_CONSUMER, MND_CONSUMER_VER_NUMBER, size); - if (pRaw == NULL) return NULL; - - int32_t dataPos = 0; - SDB_SET_INT64(pRaw, dataPos, pConsumer->uid); - SDB_SET_INT64(pRaw, dataPos, pConsumer->createTime); - SDB_SET_INT64(pRaw, dataPos, pConsumer->updateTime); - /*SDB_SET_INT64(pRaw, dataPos, pConsumer->dbUid);*/ - SDB_SET_INT32(pRaw, dataPos, pConsumer->version); - SDB_SET_RESERVE(pRaw, dataPos, MND_CONSUMER_RESERVE_SIZE); SDB_SET_DATALEN(pRaw, dataPos); @@ -161,56 +118,67 @@ static SSdbRow *mndConsumerActionDecode(SSdbRaw *pRaw) { return NULL; } - int32_t size = sizeof(SConsumerObj) + TSDB_MAX_COLUMNS * sizeof(SSchema); - SSdbRow *pRow = sdbAllocRow(size); - SConsumerObj *pConsumer = sdbGetRowObj(pRow); + int32_t size = sizeof(SMqConsumerObj); + SSdbRow *pRow = sdbAllocRow(size); + SMqConsumerObj *pConsumer = sdbGetRowObj(pRow); if (pConsumer == NULL) return NULL; int32_t dataPos = 0; - SDB_GET_INT64(pRaw, pRow, dataPos, &pConsumer->uid); - SDB_GET_INT64(pRaw, pRow, dataPos, &pConsumer->createTime); - SDB_GET_INT64(pRaw, pRow, dataPos, &pConsumer->updateTime); - /*SDB_GET_INT64(pRaw, pRow, dataPos, &pConsumer->dbUid);*/ - SDB_GET_INT32(pRaw, pRow, dataPos, &pConsumer->version); + SDB_GET_INT64(pRaw, pRow, dataPos, &pConsumer->consumerId); + int32_t len, topicNum; + SDB_GET_INT32(pRaw, pRow, dataPos, &len); + SDB_GET_BINARY(pRaw, pRow, dataPos, pConsumer->cgroup, len); + SDB_GET_INT32(pRaw, pRow, dataPos, &topicNum); + for (int i = 0; i < topicNum; i++) { + int32_t topicLen; + SMqConsumerTopic *pConsumerTopic = malloc(sizeof(SMqConsumerTopic)); + if (pConsumerTopic == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + // TODO + return NULL; + } + /*pConsumerTopic->vgroups = taosArrayInit(topicNum, sizeof(SMqConsumerTopic));*/ + SDB_GET_INT32(pRaw, pRow, dataPos, &topicLen); + SDB_GET_BINARY(pRaw, pRow, dataPos, pConsumerTopic->name, topicLen); + int32_t vgSize; + SDB_GET_INT32(pRaw, pRow, dataPos, &vgSize); + } SDB_GET_RESERVE(pRaw, pRow, dataPos, MND_CONSUMER_RESERVE_SIZE); return pRow; } -static int32_t mndConsumerActionInsert(SSdb *pSdb, SConsumerObj *pConsumer) { - mTrace("consumer:%ld, perform insert action", pConsumer->uid); +static int32_t mndConsumerActionInsert(SSdb *pSdb, SMqConsumerObj *pConsumer) { + mTrace("consumer:%ld, perform insert action", pConsumer->consumerId); return 0; } -static int32_t mndConsumerActionDelete(SSdb *pSdb, SConsumerObj *pConsumer) { - mTrace("consumer:%ld, perform delete action", pConsumer->uid); +static int32_t mndConsumerActionDelete(SSdb *pSdb, SMqConsumerObj *pConsumer) { + mTrace("consumer:%ld, perform delete action", pConsumer->consumerId); return 0; } -static int32_t mndConsumerActionUpdate(SSdb *pSdb, SConsumerObj *pOldConsumer, SConsumerObj *pNewConsumer) { - mTrace("consumer:%ld, perform update action", pOldConsumer->uid); - atomic_exchange_32(&pOldConsumer->updateTime, pNewConsumer->updateTime); - atomic_exchange_32(&pOldConsumer->version, pNewConsumer->version); - - taosWLockLatch(&pOldConsumer->lock); +static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer, SMqConsumerObj *pNewConsumer) { + mTrace("consumer:%ld, perform update action", pOldConsumer->consumerId); // TODO handle update + /*taosWLockLatch(&pOldConsumer->lock);*/ + /*taosWUnLockLatch(&pOldConsumer->lock);*/ - taosWUnLockLatch(&pOldConsumer->lock); return 0; } -SConsumerObj *mndAcquireConsumer(SMnode *pMnode, int32_t consumerId) { - SSdb *pSdb = pMnode->pSdb; - SConsumerObj *pConsumer = sdbAcquire(pSdb, SDB_CONSUMER, &consumerId); +SMqConsumerObj *mndAcquireConsumer(SMnode *pMnode, int32_t consumerId) { + SSdb *pSdb = pMnode->pSdb; + SMqConsumerObj *pConsumer = sdbAcquire(pSdb, SDB_CONSUMER, &consumerId); if (pConsumer == NULL) { /*terrno = TSDB_CODE_MND_CONSUMER_NOT_EXIST;*/ } return pConsumer; } -void mndReleaseConsumer(SMnode *pMnode, SConsumerObj *pConsumer) { +void mndReleaseConsumer(SMnode *pMnode, SMqConsumerObj *pConsumer) { SSdb *pSdb = pMnode->pSdb; sdbRelease(pSdb, pConsumer); } @@ -220,48 +188,185 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) { char *msgStr = pMsg->rpcMsg.pCont; SCMSubscribeReq *pSubscribe; tDeserializeSCMSubscribeReq(msgStr, pSubscribe); - int topicNum = pSubscribe->topicNum; int64_t consumerId = pSubscribe->consumerId; char *consumerGroup = pSubscribe->consumerGroup; - // get consumer group and add client into it - SCGroupObj *pCGroup = sdbAcquire(pMnode->pSdb, SDB_CGROUP, consumerGroup); - if (pCGroup != NULL) { - // iterate the list until finding the consumer - // add consumer to cgroup list if not found - // put new record + + SArray *newSub = NULL; + int newTopicNum = pSubscribe->topicNum; + if (newTopicNum) { + newSub = taosArrayInit(newTopicNum, sizeof(SMqConsumerTopic)); + } + for (int i = 0; i < newTopicNum; i++) { + char *topic = pSubscribe->topicName[i]; + SMqConsumerTopic *pConsumerTopic = malloc(sizeof(SMqConsumerTopic)); + if (pConsumerTopic == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + // TODO: free + return -1; + } + pConsumerTopic->vgroups = tdListNew(sizeof(int64_t)); + taosArrayPush(newSub, pConsumerTopic); + free(pConsumerTopic); + } + taosArraySortString(newSub, taosArrayCompareString); + + SArray *oldSub = NULL; + int oldTopicNum = 0; + SMqConsumerObj *pConsumer = mndAcquireConsumer(pMnode, consumerId); + if (pConsumer == NULL) { + // create consumer + pConsumer = malloc(sizeof(SMqConsumerObj)); + if (pConsumer == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + strcpy(pConsumer->cgroup, pSubscribe->consumerGroup); + + } else { + oldSub = pConsumer->topics; + oldTopicNum = taosArrayGetSize(oldSub); + } + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, &pMsg->rpcMsg); + if (pTrans == NULL) { + return -1; } - SConsumerObj *pConsumer = mndAcquireConsumer(pMnode, consumerId); - if (pConsumer != NULL) { - //reset topic list - } - - for (int i = 0; i < topicNum; i++) { - char *topicName = pSubscribe->topicName[i]; - STopicObj *pTopic = mndAcquireTopic(pMnode, topicName); - //get - // consumer id - SList *list = pTopic->consumerIds; - // add the consumer if not in the list - // - SList* topicList = pConsumer->topics; - //add to topic + int i = 0, j = 0; + while (i < newTopicNum || j < oldTopicNum) { + SMqConsumerTopic *pOldTopic = NULL; + SMqConsumerTopic *pNewTopic = NULL; + if (i >= newTopicNum) { + // encode unset topic msg to all vnodes related to that topic + pOldTopic = taosArrayGet(oldSub, j); + j++; + } else if (j >= oldTopicNum) { + pNewTopic = taosArrayGet(newSub, i); + } else { + pNewTopic = taosArrayGet(newSub, i); + pOldTopic = taosArrayGet(oldSub, j); + + char *newName = pNewTopic->name; + char *oldName = pOldTopic->name; + int comp = compareLenPrefixedStr(newName, oldName); + if (comp == 0) { + // do nothing + pOldTopic = pNewTopic = NULL; + i++; + j++; + continue; + } else if (comp < 0) { + pOldTopic = NULL; + i++; + } else { + pNewTopic = NULL; + j++; + } + } + + if (pOldTopic != NULL) { + ASSERT(pNewTopic == NULL); + char *oldTopicName = pOldTopic->name; + SList *vgroups = pOldTopic->vgroups; + SListIter iter; + tdListInitIter(vgroups, &iter, TD_LIST_FORWARD); + SListNode *pn; + + SMqTopicObj *pTopic = mndAcquireTopic(pMnode, oldTopicName); + ASSERT(pTopic != NULL); + SMqCGroup *pGroup = taosHashGet(pTopic->cgroups, pSubscribe->consumerGroup, strlen(pSubscribe->consumerGroup)); + while ((pn = tdListNext(&iter)) != NULL) { + int32_t vgId = *(int64_t *)pn->data; + SVgObj *pVgObj = mndAcquireVgroup(pMnode, vgId); + // TODO release + if (pVgObj == NULL) { + // TODO handle error + continue; + } + // acquire and get epset + void *pMqVgSetReq = + mndBuildMqVGroupSetReq(pMnode, oldTopicName, vgId, pSubscribe->consumerId, pSubscribe->consumerGroup); + // TODO:serialize + if (pMsg == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + STransAction action = {0}; + action.epSet = mndGetVgroupEpset(pMnode, pVgObj); + action.pCont = pMqVgSetReq; + action.contLen = 0; // TODO + action.msgType = TDMT_VND_MQ_SET_CONN; + if (mndTransAppendRedoAction(pTrans, &action) != 0) { + free(pMqVgSetReq); + mndTransDrop(pTrans); + // TODO free + return -1; + } + } + taosHashRemove(pTopic->cgroups, pSubscribe->consumerGroup, strlen(pSubscribe->consumerGroup)); + + } else if (pNewTopic != NULL) { + ASSERT(pOldTopic == NULL); + + char *newTopicName = pNewTopic->name; + SMqTopicObj *pTopic = mndAcquireTopic(pMnode, newTopicName); + ASSERT(pTopic != NULL); + + SMqCGroup *pGroup = taosHashGet(pTopic->cgroups, pSubscribe->consumerGroup, strlen(pSubscribe->consumerGroup)); + if (pGroup == NULL) { + // add new group + pGroup = malloc(sizeof(SMqCGroup)); + if (pGroup == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + pGroup->consumerIds = tdListNew(sizeof(int64_t)); + if (pGroup->consumerIds == NULL) { + free(pGroup); + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + pGroup->status = 0; + // add into cgroups + taosHashPut(pTopic->cgroups, pSubscribe->consumerGroup, strlen(pSubscribe->consumerGroup), pGroup, + sizeof(SMqCGroup)); + } + + // put the consumer into list + // rebalance will be triggered by timer + tdListAppend(pGroup->consumerIds, &pSubscribe->consumerId); + + SSdbRaw *pTopicRaw = mndTopicActionEncode(pTopic); + sdbSetRawStatus(pTopicRaw, SDB_STATUS_READY); + // TODO: error handling + mndTransAppendRedolog(pTrans, pTopicRaw); + } else { + ASSERT(0); + } + } + // destroy old sub + taosArrayDestroy(oldSub); + // put new sub into consumerobj + pConsumer->topics = newSub; + + // persist consumerObj + SSdbRaw *pConsumerRaw = mndConsumerActionEncode(pConsumer); + sdbSetRawStatus(pConsumerRaw, SDB_STATUS_READY); + // TODO: error handling + mndTransAppendRedolog(pTrans, pConsumerRaw); + + if (mndTransPrepare(pMnode, pTrans) != 0) { + mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr()); + mndTransDrop(pTrans); + return -1; } + // TODO: free memory + mndTransDrop(pTrans); return 0; } -static int32_t mndProcessSubscribeRsp(SMnodeMsg *pMsg) { return 0; } - -static int32_t mndProcessSubscribeInternalReq(SMnodeMsg *pMsg) { return 0; } - static int32_t mndProcessSubscribeInternalRsp(SMnodeMsg *pMsg) { return 0; } -static int32_t mndProcessDropConsumerInRsp(SMnodeMsg *pMsg) { - mndTransProcessRsp(pMsg); - return 0; -} - static int32_t mndProcessConsumerMetaMsg(SMnodeMsg *pMsg) { SMnode *pMnode = pMsg->pMnode; STableInfoMsg *pInfo = pMsg->rpcMsg.pCont; @@ -339,7 +444,7 @@ static int32_t mndGetNumOfConsumers(SMnode *pMnode, char *dbName, int32_t *pNumO int32_t numOfConsumers = 0; void *pIter = NULL; while (1) { - SConsumerObj *pConsumer = NULL; + SMqConsumerObj *pConsumer = NULL; pIter = sdbFetch(pSdb, SDB_CONSUMER, pIter, (void **)&pConsumer); if (pIter == NULL) break; @@ -402,49 +507,6 @@ static int32_t mndGetConsumerMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMs return 0; } -static int32_t mndRetrieveCGroup(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int32_t rows) { - SMnode *pMnode = pMsg->pMnode; - SSdb *pSdb = pMnode->pSdb; - int32_t numOfRows = 0; - SCGroupObj *pCGroup = NULL; - int32_t cols = 0; - char *pWrite; - char prefix[64] = {0}; - - tstrncpy(prefix, pShow->db, 64); - strcat(prefix, TS_PATH_DELIMITER); - int32_t prefixLen = (int32_t)strlen(prefix); - - while (numOfRows < rows) { - pShow->pIter = sdbFetch(pSdb, SDB_CONSUMER, pShow->pIter, (void **)&pCGroup); - if (pShow->pIter == NULL) break; - - if (strncmp(pCGroup->name, prefix, prefixLen) != 0) { - sdbRelease(pSdb, pCGroup); - continue; - } - - cols = 0; - - char consumerName[TSDB_TABLE_NAME_LEN] = {0}; - tstrncpy(consumerName, pCGroup->name + prefixLen, TSDB_TABLE_NAME_LEN); - pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - STR_TO_VARSTR(pWrite, consumerName); - cols++; - - pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - *(int64_t *)pWrite = pCGroup->createTime; - cols++; - - numOfRows++; - sdbRelease(pSdb, pCGroup); - } - - pShow->numOfReads += numOfRows; - mndVacuumResult(data, pShow->numOfColumns, numOfRows, rows, pShow); - return numOfRows; -} - static void mndCancelGetNextConsumer(SMnode *pMnode, void *pIter) { SSdb *pSdb = pMnode->pSdb; sdbCancelFetch(pSdb, pIter); diff --git a/source/dnode/mnode/impl/src/mndTopic.c b/source/dnode/mnode/impl/src/mndTopic.c index 24e32e07b4..4f6567a50a 100644 --- a/source/dnode/mnode/impl/src/mndTopic.c +++ b/source/dnode/mnode/impl/src/mndTopic.c @@ -14,6 +14,7 @@ */ #define _DEFAULT_SOURCE +#include "mndTopic.h" #include "mndDb.h" #include "mndDnode.h" #include "mndMnode.h" @@ -27,18 +28,16 @@ #define MND_TOPIC_VER_NUMBER 1 #define MND_TOPIC_RESERVE_SIZE 64 -static SSdbRaw *mndTopicActionEncode(STopicObj *pTopic); -static SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw); -static int32_t mndTopicActionInsert(SSdb *pSdb, STopicObj *pTopic); -static int32_t mndTopicActionDelete(SSdb *pSdb, STopicObj *pTopic); -static int32_t mndTopicActionUpdate(SSdb *pSdb, STopicObj *pTopic, STopicObj *pNewTopic); -static int32_t mndProcessCreateTopicMsg(SMnodeMsg *pMsg); -static int32_t mndProcessDropTopicMsg(SMnodeMsg *pMsg); -static int32_t mndProcessDropTopicInRsp(SMnodeMsg *pMsg); -static int32_t mndProcessTopicMetaMsg(SMnodeMsg *pMsg); -static int32_t mndGetTopicMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pMeta); -static int32_t mndRetrieveTopic(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int32_t rows); -static void mndCancelGetNextTopic(SMnode *pMnode, void *pIter); +static int32_t mndTopicActionInsert(SSdb *pSdb, SMqTopicObj *pTopic); +static int32_t mndTopicActionDelete(SSdb *pSdb, SMqTopicObj *pTopic); +static int32_t mndTopicActionUpdate(SSdb *pSdb, SMqTopicObj *pTopic, SMqTopicObj *pNewTopic); +static int32_t mndProcessCreateTopicMsg(SMnodeMsg *pMsg); +static int32_t mndProcessDropTopicMsg(SMnodeMsg *pMsg); +static int32_t mndProcessDropTopicInRsp(SMnodeMsg *pMsg); +static int32_t mndProcessTopicMetaMsg(SMnodeMsg *pMsg); +static int32_t mndGetTopicMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pMeta); +static int32_t mndRetrieveTopic(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int32_t rows); +static void mndCancelGetNextTopic(SMnode *pMnode, void *pIter); int32_t mndInitTopic(SMnode *pMnode) { SSdbTable table = {.sdbType = SDB_TOPIC, @@ -58,8 +57,9 @@ int32_t mndInitTopic(SMnode *pMnode) { void mndCleanupTopic(SMnode *pMnode) {} -static SSdbRaw *mndTopicActionEncode(STopicObj *pTopic) { - int32_t size = sizeof(STopicObj) + MND_TOPIC_RESERVE_SIZE; +SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic) { + int32_t len; + int32_t size = sizeof(SMqTopicObj) + MND_TOPIC_RESERVE_SIZE; SSdbRaw *pRaw = sdbAllocRaw(SDB_TOPIC, MND_TOPIC_VER_NUMBER, size); if (pRaw == NULL) return NULL; @@ -71,10 +71,15 @@ static SSdbRaw *mndTopicActionEncode(STopicObj *pTopic) { SDB_SET_INT64(pRaw, dataPos, pTopic->uid); SDB_SET_INT64(pRaw, dataPos, pTopic->dbUid); SDB_SET_INT32(pRaw, dataPos, pTopic->version); - SDB_SET_INT32(pRaw, dataPos, pTopic->execLen); - SDB_SET_BINARY(pRaw, dataPos, pTopic->executor, pTopic->execLen); SDB_SET_INT32(pRaw, dataPos, pTopic->sqlLen); SDB_SET_BINARY(pRaw, dataPos, pTopic->sql, pTopic->sqlLen); + SDB_SET_INT32(pRaw, dataPos, pTopic->sqlLen); + len = strlen(pTopic->logicalPlan); + SDB_SET_INT32(pRaw, dataPos, len); + SDB_SET_BINARY(pRaw, dataPos, pTopic->logicalPlan, len); + len = strlen(pTopic->physicalPlan); + SDB_SET_INT32(pRaw, dataPos, len); + SDB_SET_BINARY(pRaw, dataPos, pTopic->physicalPlan, len); SDB_SET_RESERVE(pRaw, dataPos, MND_TOPIC_RESERVE_SIZE); SDB_SET_DATALEN(pRaw, dataPos); @@ -82,7 +87,7 @@ static SSdbRaw *mndTopicActionEncode(STopicObj *pTopic) { return pRaw; } -static SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) { +SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) { int8_t sver = 0; if (sdbGetRawSoftVer(pRaw, &sver) != 0) return NULL; @@ -92,11 +97,12 @@ static SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) { return NULL; } - int32_t size = sizeof(STopicObj) + TSDB_MAX_COLUMNS * sizeof(SSchema); - SSdbRow *pRow = sdbAllocRow(size); - STopicObj *pTopic = sdbGetRowObj(pRow); + int32_t size = sizeof(SMqTopicObj) + TSDB_MAX_COLUMNS * sizeof(SSchema); + SSdbRow *pRow = sdbAllocRow(size); + SMqTopicObj *pTopic = sdbGetRowObj(pRow); if (pTopic == NULL) return NULL; + int32_t len; int32_t dataPos = 0; SDB_GET_BINARY(pRaw, pRow, dataPos, pTopic->name, TSDB_TABLE_FNAME_LEN); SDB_GET_BINARY(pRaw, pRow, dataPos, pTopic->db, TSDB_DB_FNAME_LEN); @@ -105,49 +111,51 @@ static SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) { SDB_GET_INT64(pRaw, pRow, dataPos, &pTopic->uid); SDB_GET_INT64(pRaw, pRow, dataPos, &pTopic->dbUid); SDB_GET_INT32(pRaw, pRow, dataPos, &pTopic->version); - SDB_GET_INT32(pRaw, pRow, dataPos, &pTopic->execLen); - SDB_GET_BINARY(pRaw, pRow, dataPos, pTopic->executor, pTopic->execLen); SDB_GET_INT32(pRaw, pRow, dataPos, &pTopic->sqlLen); SDB_GET_BINARY(pRaw, pRow, dataPos, pTopic->sql, pTopic->sqlLen); + SDB_GET_INT32(pRaw, pRow, dataPos, &len); + SDB_GET_BINARY(pRaw, pRow, dataPos, pTopic->logicalPlan, len); + SDB_GET_INT32(pRaw, pRow, dataPos, &len); + SDB_GET_BINARY(pRaw, pRow, dataPos, pTopic->physicalPlan, len); SDB_GET_RESERVE(pRaw, pRow, dataPos, MND_TOPIC_RESERVE_SIZE); return pRow; } -static int32_t mndTopicActionInsert(SSdb *pSdb, STopicObj *pTopic) { +static int32_t mndTopicActionInsert(SSdb *pSdb, SMqTopicObj *pTopic) { mTrace("topic:%s, perform insert action", pTopic->name); return 0; } -static int32_t mndTopicActionDelete(SSdb *pSdb, STopicObj *pTopic) { +static int32_t mndTopicActionDelete(SSdb *pSdb, SMqTopicObj *pTopic) { mTrace("topic:%s, perform delete action", pTopic->name); return 0; } -static int32_t mndTopicActionUpdate(SSdb *pSdb, STopicObj *pOldTopic, STopicObj *pNewTopic) { +static int32_t mndTopicActionUpdate(SSdb *pSdb, SMqTopicObj *pOldTopic, SMqTopicObj *pNewTopic) { mTrace("topic:%s, perform update action", pOldTopic->name); atomic_exchange_32(&pOldTopic->updateTime, pNewTopic->updateTime); atomic_exchange_32(&pOldTopic->version, pNewTopic->version); taosWLockLatch(&pOldTopic->lock); - - //TODO handle update + + // TODO handle update taosWUnLockLatch(&pOldTopic->lock); return 0; } -STopicObj *mndAcquireTopic(SMnode *pMnode, char *topicName) { - SSdb *pSdb = pMnode->pSdb; - STopicObj *pTopic = sdbAcquire(pSdb, SDB_TOPIC, topicName); +SMqTopicObj *mndAcquireTopic(SMnode *pMnode, char *topicName) { + SSdb *pSdb = pMnode->pSdb; + SMqTopicObj *pTopic = sdbAcquire(pSdb, SDB_TOPIC, topicName); if (pTopic == NULL) { terrno = TSDB_CODE_MND_TOPIC_NOT_EXIST; } return pTopic; } -void mndReleaseTopic(SMnode *pMnode, STopicObj *pTopic) { +void mndReleaseTopic(SMnode *pMnode, SMqTopicObj *pTopic) { SSdb *pSdb = pMnode->pSdb; sdbRelease(pSdb, pTopic); } @@ -162,7 +170,7 @@ static SDbObj *mndAcquireDbByTopic(SMnode *pMnode, char *topicName) { return mndAcquireDb(pMnode, db); } -static SDDropTopicMsg *mndBuildDropTopicMsg(SMnode *pMnode, SVgObj *pVgroup, STopicObj *pTopic) { +static SDDropTopicMsg *mndBuildDropTopicMsg(SMnode *pMnode, SVgObj *pVgroup, SMqTopicObj *pTopic) { int32_t contLen = sizeof(SDDropTopicMsg); SDDropTopicMsg *pDrop = calloc(1, contLen); @@ -185,7 +193,7 @@ static int32_t mndCheckCreateTopicMsg(SCMCreateTopicReq *pCreate) { } static int32_t mndCreateTopic(SMnode *pMnode, SMnodeMsg *pMsg, SCMCreateTopicReq *pCreate, SDbObj *pDb) { - STopicObj topicObj = {0}; + SMqTopicObj topicObj = {0}; tstrncpy(topicObj.name, pCreate->name, TSDB_TABLE_FNAME_LEN); tstrncpy(topicObj.db, pDb->name, TSDB_DB_FNAME_LEN); topicObj.createTime = taosGetTimestampMs(); @@ -197,13 +205,14 @@ static int32_t mndCreateTopic(SMnode *pMnode, SMnodeMsg *pMsg, SCMCreateTopicReq SSdbRaw *pTopicRaw = mndTopicActionEncode(&topicObj); if (pTopicRaw == NULL) return -1; if (sdbSetRawStatus(pTopicRaw, SDB_STATUS_READY) != 0) return -1; + // TODO: replace with trans to support recovery return sdbWrite(pMnode->pSdb, pTopicRaw); } static int32_t mndProcessCreateTopicMsg(SMnodeMsg *pMsg) { - SMnode *pMnode = pMsg->pMnode; - char *msgStr = pMsg->rpcMsg.pCont; - SCMCreateTopicReq* pCreate; + SMnode *pMnode = pMsg->pMnode; + char *msgStr = pMsg->rpcMsg.pCont; + SCMCreateTopicReq *pCreate; tDeserializeSCMCreateTopicReq(msgStr, pCreate); mDebug("topic:%s, start to create", pCreate->name); @@ -213,7 +222,7 @@ static int32_t mndProcessCreateTopicMsg(SMnodeMsg *pMsg) { return -1; } - STopicObj *pTopic = mndAcquireTopic(pMnode, pCreate->name); + SMqTopicObj *pTopic = mndAcquireTopic(pMnode, pCreate->name); if (pTopic != NULL) { sdbRelease(pMnode->pSdb, pTopic); if (pCreate->igExists) { @@ -245,9 +254,7 @@ static int32_t mndProcessCreateTopicMsg(SMnodeMsg *pMsg) { return TSDB_CODE_MND_ACTION_IN_PROGRESS; } -static int32_t mndDropTopic(SMnode *pMnode, SMnodeMsg *pMsg, STopicObj *pTopic) { - return 0; -} +static int32_t mndDropTopic(SMnode *pMnode, SMnodeMsg *pMsg, SMqTopicObj *pTopic) { return 0; } static int32_t mndProcessDropTopicMsg(SMnodeMsg *pMsg) { SMnode *pMnode = pMsg->pMnode; @@ -255,7 +262,7 @@ static int32_t mndProcessDropTopicMsg(SMnodeMsg *pMsg) { mDebug("topic:%s, start to drop", pDrop->name); - STopicObj *pTopic = mndAcquireTopic(pMnode, pDrop->name); + SMqTopicObj *pTopic = mndAcquireTopic(pMnode, pDrop->name); if (pTopic == NULL) { if (pDrop->igNotExists) { mDebug("topic:%s, not exist, ignore not exist is set", pDrop->name); @@ -361,7 +368,7 @@ static int32_t mndGetNumOfTopics(SMnode *pMnode, char *dbName, int32_t *pNumOfTo int32_t numOfTopics = 0; void *pIter = NULL; while (1) { - STopicObj *pTopic = NULL; + SMqTopicObj *pTopic = NULL; pIter = sdbFetch(pSdb, SDB_TOPIC, pIter, (void **)&pTopic); if (pIter == NULL) break; @@ -440,13 +447,13 @@ static void mndExtractTableName(char *tableId, char *name) { } static int32_t mndRetrieveTopic(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int32_t rows) { - SMnode *pMnode = pMsg->pMnode; - SSdb *pSdb = pMnode->pSdb; - int32_t numOfRows = 0; - STopicObj *pTopic = NULL; - int32_t cols = 0; - char *pWrite; - char prefix[64] = {0}; + SMnode *pMnode = pMsg->pMnode; + SSdb *pSdb = pMnode->pSdb; + int32_t numOfRows = 0; + SMqTopicObj *pTopic = NULL; + int32_t cols = 0; + char *pWrite; + char prefix[64] = {0}; tstrncpy(prefix, pShow->db, 64); strcat(prefix, TS_PATH_DELIMITER); diff --git a/source/libs/wal/src/walMeta.c b/source/libs/wal/src/walMeta.c index 0f155f9553..6164ec2baf 100644 --- a/source/libs/wal/src/walMeta.c +++ b/source/libs/wal/src/walMeta.c @@ -261,15 +261,18 @@ int walLoadMeta(SWal* pWal) { memset(buf, 0, size + 5); int tfd = tfOpenRead(fnameStr); if (tfRead(tfd, buf, size) != size) { + tfClose(tfd); free(buf); return -1; } // load into fileInfoSet int code = walMetaDeserialize(pWal, buf); if (code != 0) { + tfClose(tfd); free(buf); return -1; } + tfClose(tfd); free(buf); return 0; } diff --git a/source/libs/wal/src/walRead.c b/source/libs/wal/src/walRead.c index c80fb4eed8..67c8694fd6 100644 --- a/source/libs/wal/src/walRead.c +++ b/source/libs/wal/src/walRead.c @@ -15,6 +15,7 @@ #include "tfile.h" #include "walInt.h" +#include "taoserror.h" SWalReadHandle *walOpenReadHandle(SWal *pWal) { SWalReadHandle *pRead = malloc(sizeof(SWalReadHandle)); @@ -30,6 +31,7 @@ SWalReadHandle *walOpenReadHandle(SWal *pWal) { pRead->status = 0; pRead->pHead = malloc(sizeof(SWalHead)); if (pRead->pHead == NULL) { + terrno = TSDB_CODE_WAL_OUT_OF_MEMORY; free(pRead); return NULL; } @@ -55,16 +57,19 @@ static int32_t walReadSeekFilePos(SWalReadHandle *pRead, int64_t fileFirstVer, i int64_t offset = (ver - fileFirstVer) * sizeof(SWalIdxEntry); code = tfLseek(idxTfd, offset, SEEK_SET); if (code < 0) { + terrno = TAOS_SYSTEM_ERROR(errno); return -1; } SWalIdxEntry entry; if (tfRead(idxTfd, &entry, sizeof(SWalIdxEntry)) != sizeof(SWalIdxEntry)) { + terrno = TSDB_CODE_WAL_FILE_CORRUPTED; return -1; } // TODO:deserialize ASSERT(entry.ver == ver); code = tfLseek(logTfd, entry.offset, SEEK_SET); if (code < 0) { + terrno = TAOS_SYSTEM_ERROR(errno); return -1; } return code; @@ -79,6 +84,7 @@ static int32_t walReadChangeFile(SWalReadHandle *pRead, int64_t fileFirstVer) { walBuildLogName(pRead->pWal, fileFirstVer, fnameStr); int64_t logTfd = tfOpenRead(fnameStr); if (logTfd < 0) { + terrno = TAOS_SYSTEM_ERROR(errno); return -1; } @@ -100,6 +106,7 @@ static int32_t walReadSeekVer(SWalReadHandle *pRead, int64_t ver) { return 0; } if (ver > pWal->vers.lastVer || ver < pWal->vers.firstVer) { + terrno = TSDB_CODE_WAL_INVALID_VER; return -1; } if (ver < pWal->vers.snapshotVer) { @@ -113,7 +120,6 @@ static int32_t walReadSeekVer(SWalReadHandle *pRead, int64_t ver) { if (pRead->curFileFirstVer != pRet->firstVer) { code = walReadChangeFile(pRead, pRet->firstVer); if (code < 0) { - // TODO: set error flag return -1; } } @@ -132,7 +138,7 @@ int32_t walReadWithHandle(SWalReadHandle *pRead, int64_t ver) { // TODO: check wal life if (pRead->curVersion != ver) { code = walReadSeekVer(pRead, ver); - if (code != 0) { + if (code < 0) { return -1; } } @@ -145,11 +151,13 @@ int32_t walReadWithHandle(SWalReadHandle *pRead, int64_t ver) { } code = walValidHeadCksum(pRead->pHead); if (code != 0) { + terrno = TSDB_CODE_WAL_FILE_CORRUPTED; return -1; } if (pRead->capacity < pRead->pHead->head.len) { void *ptr = realloc(pRead->pHead, sizeof(SWalHead) + pRead->pHead->head.len); if (ptr == NULL) { + terrno = TSDB_CODE_WAL_OUT_OF_MEMORY; return -1; } pRead->pHead = ptr; @@ -163,6 +171,7 @@ int32_t walReadWithHandle(SWalReadHandle *pRead, int64_t ver) { code = walValidBodyCksum(pRead->pHead); if (code != 0) { + terrno = TSDB_CODE_WAL_FILE_CORRUPTED; return -1; } pRead->curVersion++; diff --git a/source/libs/wal/src/walSeek.c b/source/libs/wal/src/walSeek.c index 1f9b7b6e58..1d9f7bdf4d 100644 --- a/source/libs/wal/src/walSeek.c +++ b/source/libs/wal/src/walSeek.c @@ -30,17 +30,20 @@ static int walSeekFilePos(SWal* pWal, int64_t ver) { int64_t idxOff = walGetVerIdxOffset(pWal, ver); code = tfLseek(idxTfd, idxOff, SEEK_SET); if (code != 0) { + terrno = TAOS_SYSTEM_ERROR(errno); return -1; } SWalIdxEntry entry; // TODO:deserialize code = tfRead(idxTfd, &entry, sizeof(SWalIdxEntry)); if (code != 0) { + terrno = TAOS_SYSTEM_ERROR(errno); return -1; } ASSERT(entry.ver == ver); code = tfLseek(logTfd, entry.offset, SEEK_CUR); if (code < 0) { + terrno = TAOS_SYSTEM_ERROR(errno); return -1; } return code; @@ -56,11 +59,13 @@ int walChangeFileToLast(SWal* pWal) { walBuildIdxName(pWal, fileFirstVer, fnameStr); idxTfd = tfOpenReadWrite(fnameStr); if (idxTfd < 0) { + terrno = TAOS_SYSTEM_ERROR(errno); return -1; } walBuildLogName(pWal, fileFirstVer, fnameStr); logTfd = tfOpenReadWrite(fnameStr); if (logTfd < 0) { + terrno = TAOS_SYSTEM_ERROR(errno); return -1; } // switch file @@ -76,11 +81,12 @@ int walChangeFile(SWal* pWal, int64_t ver) { code = tfClose(pWal->writeLogTfd); if (code != 0) { // TODO + terrno = TAOS_SYSTEM_ERROR(errno); return -1; } code = tfClose(pWal->writeIdxTfd); if (code != 0) { - // TODO + terrno = TAOS_SYSTEM_ERROR(errno); return -1; } SWalFileInfo tmpInfo; @@ -113,6 +119,7 @@ int walSeekVer(SWal* pWal, int64_t ver) { return 0; } if (ver > pWal->vers.lastVer || ver < pWal->vers.firstVer) { + terrno = TSDB_CODE_WAL_INVALID_VER; return -1; } if (ver < pWal->vers.snapshotVer) { diff --git a/source/libs/wal/src/walWrite.c b/source/libs/wal/src/walWrite.c index c8ffd9d07d..5e26dd8278 100644 --- a/source/libs/wal/src/walWrite.c +++ b/source/libs/wal/src/walWrite.c @@ -25,6 +25,7 @@ int32_t walCommit(SWal *pWal, int64_t ver) { ASSERT(pWal->vers.commitVer >= pWal->vers.snapshotVer); ASSERT(pWal->vers.commitVer <= pWal->vers.lastVer); if (ver < pWal->vers.commitVer || ver > pWal->vers.lastVer) { + terrno = TSDB_CODE_WAL_INVALID_VER; return -1; } pWal->vers.commitVer = ver; @@ -38,6 +39,7 @@ int32_t walRollback(SWal *pWal, int64_t ver) { return 0; } if (ver > pWal->vers.lastVer || ver < pWal->vers.commitVer) { + terrno = TSDB_CODE_WAL_INVALID_VER; return -1; } pthread_mutex_lock(&pWal->mutex); From b00bc84157c7ea004cd837d4ac5c9f6556fd33c6 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Thu, 6 Jan 2022 10:55:20 +0800 Subject: [PATCH 13/18] [td-11818] free still reachable buffer. --- source/client/src/clientImpl.c | 11 ++- source/client/test/clientTests.cpp | 22 +++--- source/libs/scheduler/inc/schedulerInt.h | 29 ++++---- source/libs/scheduler/src/scheduler.c | 89 +++++++++++++++--------- 4 files changed, 93 insertions(+), 58 deletions(-) diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index a416033946..9f91fa8a23 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -203,12 +203,21 @@ int32_t getPlan(SRequestObj* pRequest, SQueryNode* pQueryNode, SQueryDag** pDag) int32_t scheduleQuery(SRequestObj* pRequest, SQueryDag* pDag, void** pJob) { if (TSDB_SQL_INSERT == pRequest->type || TSDB_SQL_CREATE_TABLE == pRequest->type) { SQueryResult res = {.code = 0, .numOfRows = 0, .msgSize = ERROR_MSG_BUF_DEFAULT_SIZE, .msg = pRequest->msgBuf}; + int32_t code = scheduleExecJob(pRequest->pTscObj->pTransporter, NULL, pDag, pJob, &res); + if (code != TSDB_CODE_SUCCESS) { + // handle error and retry + } else { + if (*pJob != NULL) { + scheduleFreeJob(*pJob); + } + } + pRequest->affectedRows = res.numOfRows; return res.code; } - return scheduleAsyncExecJob(pRequest->pTscObj->pTransporter, NULL/*todo appInfo.xxx*/, pDag, pJob); + return scheduleAsyncExecJob(pRequest->pTscObj->pTransporter, NULL /*todo appInfo.xxx*/, pDag, pJob); } TAOS_RES *tmq_create_topic(TAOS* taos, const char* name, const char* sql, int sqlLen) { diff --git a/source/client/test/clientTests.cpp b/source/client/test/clientTests.cpp index ef2dcc21df..cbd5689cc8 100644 --- a/source/client/test/clientTests.cpp +++ b/source/client/test/clientTests.cpp @@ -505,15 +505,15 @@ TEST(testCase, create_multiple_tables) { taos_free_result(pRes); -// for(int32_t i = 0; i < 10000; ++i) { -// char sql[512] = {0}; -// snprintf(sql, tListLen(sql), "create table t_x_%d using st1 tags(2)", i); -// TAOS_RES* pres = taos_query(pConn, sql); -// if (taos_errno(pres) != 0) { -// printf("failed to create table %d\n, reason:%s", i, taos_errstr(pres)); -// } -// taos_free_result(pres); -// } + for(int32_t i = 0; i < 1000; ++i) { + char sql[512] = {0}; + snprintf(sql, tListLen(sql), "create table t_x_%d using st1 tags(2)", i); + TAOS_RES* pres = taos_query(pConn, sql); + if (taos_errno(pres) != 0) { + printf("failed to create table %d\n, reason:%s", i, taos_errstr(pres)); + } + taos_free_result(pres); + } taos_close(pConn); } @@ -521,11 +521,11 @@ TEST(testCase, create_multiple_tables) { TEST(testCase, generated_request_id_test) { SHashObj *phash = taosHashInit(10000, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK); - for(int32_t i = 0; i < 50000000; ++i) { + for(int32_t i = 0; i < 50000; ++i) { uint64_t v = generateRequestId(); void* result = taosHashGet(phash, &v, sizeof(v)); if (result != nullptr) { - printf("0x%"PRIx64", index:%d\n", v, i); + printf("0x%lx, index:%d\n", v, i); } assert(result == nullptr); taosHashPut(phash, &v, sizeof(v), NULL, 0); diff --git a/source/libs/scheduler/inc/schedulerInt.h b/source/libs/scheduler/inc/schedulerInt.h index fa4ae0d152..be488ea87b 100644 --- a/source/libs/scheduler/inc/schedulerInt.h +++ b/source/libs/scheduler/inc/schedulerInt.h @@ -82,12 +82,11 @@ typedef struct SSchJobAttr { } SSchJobAttr; typedef struct SSchJob { - uint64_t queryId; - int32_t levelNum; - int32_t levelIdx; - int8_t status; - SSchJobAttr attr; - SQueryProfileSummary summary; + uint64_t queryId; + int32_t levelNum; + int32_t levelIdx; + int8_t status; + SSchJobAttr attr; SEpSet dataSrcEps; SEpAddr resEp; void *transport; @@ -95,18 +94,20 @@ typedef struct SSchJob { tsem_t rspSem; int32_t userFetch; int32_t remoteFetch; - SSchTask *fetchTask; + int32_t errCode; void *res; int32_t resNumOfRows; - - SHashObj *execTasks; // executing tasks, key:taskid, value:SQueryTask* - SHashObj *succTasks; // succeed tasks, key:taskid, value:SQueryTask* - SHashObj *failTasks; // failed tasks, key:taskid, value:SQueryTask* - - SArray *levels; // Element is SQueryLevel, starting from 0. - SArray *subPlans; // Element is SArray*, and nested element is SSubplan. The execution level of subplan, starting from 0. + + SHashObj *execTasks; // executing tasks, key:taskid, value:SQueryTask* + SHashObj *succTasks; // succeed tasks, key:taskid, value:SQueryTask* + SHashObj *failTasks; // failed tasks, key:taskid, value:SQueryTask* + + SArray *levels; // Element is SQueryLevel, starting from 0. + SArray *subPlans; // Element is SArray*, and nested element is SSubplan. The execution level of subplan, starting from 0. + + SQueryProfileSummary summary; } SSchJob; #define SCH_HAS_QNODE_IN_CLUSTER(type) (false) //TODO CLUSTER TYPE diff --git a/source/libs/scheduler/src/scheduler.c b/source/libs/scheduler/src/scheduler.c index 9079912c40..8271d865a1 100644 --- a/source/libs/scheduler/src/scheduler.c +++ b/source/libs/scheduler/src/scheduler.c @@ -18,8 +18,7 @@ #include "query.h" #include "catalog.h" -SSchedulerMgmt schMgmt = {0}; - +static SSchedulerMgmt schMgmt = {0}; int32_t schBuildTaskRalation(SSchJob *job, SHashObj *planToTask) { for (int32_t i = 0; i < job->levelNum; ++i) { @@ -93,11 +92,30 @@ int32_t schBuildTaskRalation(SSchJob *job, SHashObj *planToTask) { return TSDB_CODE_SUCCESS; } +static SSchTask initTask(SSchJob* pJob, SSubplan* plan, SSchLevel *pLevel) { + SSchTask task = {0}; + if (plan->type == QUERY_TYPE_MODIFY) { + pJob->attr.needFetch = false; + } else { + pJob->attr.queryJob = true; + } -int32_t schValidateAndBuildJob(SQueryDag *dag, SSchJob *job) { + task.plan = plan; + task.level = pLevel; + task.status = JOB_TASK_STATUS_NOT_START; + task.taskId = atomic_add_fetch_64(&schMgmt.taskId, 1); + + return task; +} + +static void cleanupTask(SSchTask* pTask) { + taosArrayDestroy(pTask->condidateAddrs); +} + +int32_t schValidateAndBuildJob(SQueryDag *dag, SSchJob *pJob) { int32_t code = 0; - job->queryId = dag->queryId; + pJob->queryId = dag->queryId; if (dag->numOfSubplans <= 0) { qError("invalid subplan num:%d", dag->numOfSubplans); @@ -115,20 +133,20 @@ int32_t schValidateAndBuildJob(SQueryDag *dag, SSchJob *job) { qError("taosHashInit %d failed", SCHEDULE_DEFAULT_TASK_NUMBER); SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); } - - job->levels = taosArrayInit(levelNum, sizeof(SSchLevel)); - if (NULL == job->levels) { + + pJob->levels = taosArrayInit(levelNum, sizeof(SSchLevel)); + if (NULL == pJob->levels) { qError("taosArrayInit %d failed", levelNum); SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); } //?? - job->attr.needFetch = true; - - job->levelNum = levelNum; - job->levelIdx = levelNum - 1; + pJob->attr.needFetch = true; - job->subPlans = dag->pSubplans; + pJob->levelNum = levelNum; + pJob->levelIdx = levelNum - 1; + + pJob->subPlans = dag->pSubplans; SSchLevel level = {0}; SArray *levelPlans = NULL; @@ -138,12 +156,12 @@ int32_t schValidateAndBuildJob(SQueryDag *dag, SSchJob *job) { level.status = JOB_TASK_STATUS_NOT_START; for (int32_t i = 0; i < levelNum; ++i) { - if (NULL == taosArrayPush(job->levels, &level)) { + if (NULL == taosArrayPush(pJob->levels, &level)) { qError("taosArrayPush failed"); SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); } - pLevel = taosArrayGet(job->levels, i); + pLevel = taosArrayGet(pJob->levels, i); pLevel->level = i; levelPlans = taosArrayGetP(dag->pSubplans, i); @@ -168,20 +186,13 @@ int32_t schValidateAndBuildJob(SQueryDag *dag, SSchJob *job) { for (int32_t n = 0; n < levelPlanNum; ++n) { SSubplan *plan = taosArrayGetP(levelPlans, n); - SSchTask task = {0}; - if (plan->type == QUERY_TYPE_MODIFY) { - job->attr.needFetch = false; + pJob->attr.needFetch = false; } else { - job->attr.queryJob = true; + pJob->attr.queryJob = true; } - - task.taskId = atomic_add_fetch_64(&schMgmt.taskId, 1); - task.plan = plan; - task.level = pLevel; - task.status = JOB_TASK_STATUS_NOT_START; - + SSchTask task = initTask(pJob, plan, pLevel); void *p = taosArrayPush(pLevel->subTasks, &task); if (NULL == p) { qError("taosArrayPush failed"); @@ -193,10 +204,9 @@ int32_t schValidateAndBuildJob(SQueryDag *dag, SSchJob *job) { SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); } } - } - SCH_ERR_JRET(schBuildTaskRalation(job, planToTask)); + SCH_ERR_JRET(schBuildTaskRalation(pJob, planToTask)); if (planToTask) { taosHashCleanup(planToTask); @@ -839,7 +849,6 @@ void schDropJobAllTasks(SSchJob *job) { void *pIter = taosHashIterate(job->succTasks, NULL); while (pIter) { SSchTask *task = *(SSchTask **)pIter; - schBuildAndSendMsg(job, task, TDMT_VND_DROP_TASK); pIter = taosHashIterate(job->succTasks, pIter); @@ -933,16 +942,15 @@ int32_t scheduleExecJobImpl(void *transport, SArray *nodeList, SQueryDag* pDag, code = taosHashPut(schMgmt.jobs, &job->queryId, sizeof(job->queryId), &job, POINTER_BYTES); if (0 != code) { if (HASH_NODE_EXIST(code)) { - qError("taosHashPut queryId:%"PRIx64" already exist", job->queryId); + qError("taosHashPut queryId:0x%"PRIx64" already exist", job->queryId); SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT); } else { - qError("taosHashPut queryId:%"PRIx64" failed", job->queryId); + qError("taosHashPut queryId:0x%"PRIx64" failed", job->queryId); SCH_ERR_JRET(TSDB_CODE_SCH_INTERNAL_ERROR); } } job->status = JOB_TASK_STATUS_NOT_START; - SCH_ERR_JRET(schLaunchJob(job)); *(SSchJob **)pJob = job; @@ -954,7 +962,6 @@ int32_t scheduleExecJobImpl(void *transport, SArray *nodeList, SQueryDag* pDag, return TSDB_CODE_SUCCESS; _return: - *(SSchJob **)pJob = NULL; scheduleFreeJob(job); @@ -1064,7 +1071,25 @@ void scheduleFreeJob(void *pJob) { schDropJobAllTasks(job); } - //TODO free job + taosArrayDestroy(job->subPlans); + int32_t numOfLevels = taosArrayGetSize(job->levels); + for(int32_t i = 0; i < numOfLevels; ++i) { + SSchLevel *pLevel = taosArrayGet(job->levels, i); + + int32_t numOfTasks = taosArrayGetSize(pLevel->subTasks); + for(int32_t j = 0; j < numOfTasks; ++j) { + SSchTask* pTask = taosArrayGet(pLevel->subTasks, j); + cleanupTask(pTask); + } + + taosArrayDestroy(pLevel->subTasks); + } + + taosHashCleanup(job->execTasks); + taosHashCleanup(job->failTasks); + taosHashCleanup(job->succTasks); + taosArrayDestroy(job->levels); + tfree(job); } void schedulerDestroy(void) { From b0d935ba7da7f15175c7206629444e90085d5f8c Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Thu, 6 Jan 2022 10:56:25 +0800 Subject: [PATCH 14/18] merge from 3.0 --- include/common/tmsg.h | 2 +- source/dnode/mnode/impl/src/mndConsumer.c | 41 ++++++++++++----------- source/dnode/mnode/impl/src/mndTopic.c | 41 +++++++++++------------ 3 files changed, 41 insertions(+), 43 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 177a3b4b1e..4a0e3593da 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1192,7 +1192,7 @@ typedef struct { char* physicalPlan; } SMVSubscribeReq; -static FORCE_INLINE int tSerializeSMVSubscribeReq(void* buf, SMVSubscribeReq* pReq) { +static FORCE_INLINE int tSerializeSMVSubscribeReq(void** buf, SMVSubscribeReq* pReq) { int tlen = 0; tlen += taosEncodeFixedI64(buf, pReq->topicId); tlen += taosEncodeFixedI64(buf, pReq->consumerId); diff --git a/source/dnode/mnode/impl/src/mndConsumer.c b/source/dnode/mnode/impl/src/mndConsumer.c index 0f600bdcf8..7aa818c7bb 100644 --- a/source/dnode/mnode/impl/src/mndConsumer.c +++ b/source/dnode/mnode/impl/src/mndConsumer.c @@ -78,41 +78,41 @@ static SSdbRaw *mndConsumerActionEncode(SMqConsumerObj *pConsumer) { int32_t dataPos = 0; int32_t topicNum = taosArrayGetSize(pConsumer->topics); - SDB_SET_INT64(pRaw, dataPos, pConsumer->consumerId); + SDB_SET_INT64(pRaw, dataPos, pConsumer->consumerId, CM_ENCODE_OVER); int32_t len = strlen(pConsumer->cgroup); SDB_SET_INT32(pRaw, dataPos, len, CM_ENCODE_OVER); SDB_SET_BINARY(pRaw, dataPos, pConsumer->cgroup, len, CM_ENCODE_OVER); - SDB_SET_INT32(pRaw, dataPos, topicNum); + SDB_SET_INT32(pRaw, dataPos, topicNum, CM_ENCODE_OVER); for (int i = 0; i < topicNum; i++) { int32_t len; SMqConsumerTopic *pConsumerTopic = taosArrayGet(pConsumer->topics, i); len = strlen(pConsumerTopic->name); - SDB_SET_INT32(pRaw, dataPos, len); - SDB_SET_BINARY(pRaw, dataPos, pConsumerTopic->name, len); + SDB_SET_INT32(pRaw, dataPos, len, CM_ENCODE_OVER); + SDB_SET_BINARY(pRaw, dataPos, pConsumerTopic->name, len, CM_ENCODE_OVER); int vgSize; if (pConsumerTopic->vgroups == NULL) { vgSize = 0; } else { vgSize = listNEles(pConsumerTopic->vgroups); } - SDB_SET_INT32(pRaw, dataPos, vgSize); + SDB_SET_INT32(pRaw, dataPos, vgSize, CM_ENCODE_OVER); for (int j = 0; j < vgSize; j++) { // SList* head; /*SDB_SET_INT64(pRaw, dataPos, 0[> change to list item <]);*/ } } - SDB_SET_RESERVE(pRaw, dataPos, MND_CONSUMER_RESERVE_SIZE); - SDB_SET_DATALEN(pRaw, dataPos); + SDB_SET_RESERVE(pRaw, dataPos, MND_CONSUMER_RESERVE_SIZE, CM_ENCODE_OVER); + SDB_SET_DATALEN(pRaw, dataPos, CM_ENCODE_OVER); CM_ENCODE_OVER: if (terrno != 0) { - mError("consumer:%s, failed to encode to raw:%p since %s", pConsumer->name, pRaw, terrstr()); + mError("consumer:%ld, failed to encode to raw:%p since %s", pConsumer->consumerId, pRaw, terrstr()); sdbFreeRaw(pRaw); return NULL; } - mTrace("consumer:%s, encode to raw:%p, row:%p", pConsumer->name, pRaw, pConsumer); + mTrace("consumer:%ld, encode to raw:%p, row:%p", pConsumer->consumerId, pRaw, pConsumer); return pRaw; } @@ -129,17 +129,17 @@ static SSdbRow *mndConsumerActionDecode(SSdbRaw *pRaw) { int32_t size = sizeof(SMqConsumerObj); SSdbRow *pRow = sdbAllocRow(size); - if (pRow == NULL) goto CONSUMER_DECODE_OVER; + if (pRow == NULL) goto CONSUME_DECODE_OVER; SMqConsumerObj *pConsumer = sdbGetRowObj(pRow); - if (pConsumer == NULL) goto CONSUMER_DECODE_OVER; + if (pConsumer == NULL) goto CONSUME_DECODE_OVER; int32_t dataPos = 0; - SDB_GET_INT64(pRaw, pRow, dataPos, &pConsumer->consumerId, CONSUME_DECODE_OVER); + SDB_GET_INT64(pRaw, dataPos, &pConsumer->consumerId, CONSUME_DECODE_OVER); int32_t len, topicNum; - SDB_GET_INT32(pRaw, pRow, dataPos, &len, CONSUME_DECODE_OVER); - SDB_GET_BINARY(pRaw, pRow, dataPos, pConsumer->cgroup, len, CONSUME_DECODE_OVER); - SDB_GET_INT32(pRaw, pRow, dataPos, &topicNum, CONSUME_DECODE_OVER); + SDB_GET_INT32(pRaw, dataPos, &len, CONSUME_DECODE_OVER); + SDB_GET_BINARY(pRaw, dataPos, pConsumer->cgroup, len, CONSUME_DECODE_OVER); + SDB_GET_INT32(pRaw, dataPos, &topicNum, CONSUME_DECODE_OVER); for (int i = 0; i < topicNum; i++) { int32_t topicLen; SMqConsumerTopic *pConsumerTopic = malloc(sizeof(SMqConsumerTopic)); @@ -149,20 +149,21 @@ static SSdbRow *mndConsumerActionDecode(SSdbRaw *pRaw) { return NULL; } /*pConsumerTopic->vgroups = taosArrayInit(topicNum, sizeof(SMqConsumerTopic));*/ - SDB_GET_INT32(pRaw, pRow, dataPos, &topicLen, CONSUME_DECODE_OVER); - SDB_GET_BINARY(pRaw, pRow, dataPos, pConsumerTopic->name, topicLen, CONSUME_DECODE_OVER); + SDB_GET_INT32(pRaw, dataPos, &topicLen, CONSUME_DECODE_OVER); + SDB_GET_BINARY(pRaw, dataPos, pConsumerTopic->name, topicLen, CONSUME_DECODE_OVER); int32_t vgSize; - SDB_GET_INT32(pRaw, pRow, dataPos, &vgSize, CONSUME_DECODE_OVER); + SDB_GET_INT32(pRaw, dataPos, &vgSize, CONSUME_DECODE_OVER); } CONSUME_DECODE_OVER: if (terrno != 0) { - mError("consumer:%s, failed to decode from raw:%p since %s", pConsumer->name, pRaw, terrstr()); + mError("consumer:%ld, failed to decode from raw:%p since %s", pConsumer->consumerId, pRaw, terrstr()); tfree(pRow); return NULL; + } - SDB_GET_RESERVE(pRaw, pRow, dataPos, MND_CONSUMER_RESERVE_SIZE); + /*SDB_GET_RESERVE(pRaw, dataPos, MND_CONSUMER_RESERVE_SIZE);*/ return pRow; } diff --git a/source/dnode/mnode/impl/src/mndTopic.c b/source/dnode/mnode/impl/src/mndTopic.c index 83870aebb7..c31b91c3fc 100644 --- a/source/dnode/mnode/impl/src/mndTopic.c +++ b/source/dnode/mnode/impl/src/mndTopic.c @@ -57,27 +57,26 @@ int32_t mndInitTopic(SMnode *pMnode) { void mndCleanupTopic(SMnode *pMnode) {} -static SSdbRaw *mndTopicActionEncode(STopicObj *pTopic) { - int32_t size = sizeof(STopicObj) + MND_TOPIC_RESERVE_SIZE; +SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic) { + int32_t size = sizeof(SMqTopicObj) + MND_TOPIC_RESERVE_SIZE; SSdbRaw *pRaw = sdbAllocRaw(SDB_TOPIC, MND_TOPIC_VER_NUMBER, size); - if (pRaw == NULL) goto TOPIC_ENCODE_OVER; + if (pRaw == NULL) goto WTF; int32_t dataPos = 0; - SDB_SET_BINARY(pRaw, dataPos, pTopic->name, TSDB_TABLE_FNAME_LEN); - SDB_SET_BINARY(pRaw, dataPos, pTopic->db, TSDB_DB_FNAME_LEN); - SDB_SET_INT64(pRaw, dataPos, pTopic->createTime); - SDB_SET_INT64(pRaw, dataPos, pTopic->updateTime); - SDB_SET_INT64(pRaw, dataPos, pTopic->uid); - SDB_SET_INT64(pRaw, dataPos, pTopic->dbUid); - SDB_SET_INT32(pRaw, dataPos, pTopic->version); - SDB_SET_INT32(pRaw, dataPos, pTopic->execLen); - SDB_SET_BINARY(pRaw, dataPos, pTopic->executor, pTopic->execLen); - SDB_SET_INT32(pRaw, dataPos, pTopic->sqlLen); - SDB_SET_BINARY(pRaw, dataPos, pTopic->sql, pTopic->sqlLen); + SDB_SET_BINARY(pRaw, dataPos, pTopic->name, TSDB_TABLE_FNAME_LEN, WTF); + SDB_SET_BINARY(pRaw, dataPos, pTopic->db, TSDB_DB_FNAME_LEN, WTF); + SDB_SET_INT64(pRaw, dataPos, pTopic->createTime, WTF); + SDB_SET_INT64(pRaw, dataPos, pTopic->updateTime, WTF); + SDB_SET_INT64(pRaw, dataPos, pTopic->uid, WTF); + SDB_SET_INT64(pRaw, dataPos, pTopic->dbUid, WTF); + SDB_SET_INT32(pRaw, dataPos, pTopic->version, WTF); + SDB_SET_INT32(pRaw, dataPos, pTopic->sqlLen, WTF); + SDB_SET_BINARY(pRaw, dataPos, pTopic->sql, pTopic->sqlLen, WTF); - SDB_SET_RESERVE(pRaw, dataPos, MND_TOPIC_RESERVE_SIZE); - SDB_SET_DATALEN(pRaw, dataPos); + SDB_SET_RESERVE(pRaw, dataPos, MND_TOPIC_RESERVE_SIZE, WTF); + SDB_SET_DATALEN(pRaw, dataPos, WTF); +WTF: return pRaw; } @@ -109,9 +108,9 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) { SDB_GET_INT32(pRaw, dataPos, &pTopic->version, TOPIC_DECODE_OVER); SDB_GET_INT32(pRaw, dataPos, &pTopic->sqlLen, TOPIC_DECODE_OVER); SDB_GET_BINARY(pRaw, dataPos, pTopic->sql, pTopic->sqlLen, TOPIC_DECODE_OVER); - SDB_GET_INT32(pRaw, dataPos, &len); + SDB_GET_INT32(pRaw, dataPos, &len, TOPIC_DECODE_OVER); SDB_GET_BINARY(pRaw, dataPos, pTopic->logicalPlan, len, TOPIC_DECODE_OVER); - SDB_GET_INT32(pRaw, dataPos, &len); + SDB_GET_INT32(pRaw, dataPos, &len, TOPIC_DECODE_OVER); SDB_GET_BINARY(pRaw, dataPos, pTopic->physicalPlan, len, TOPIC_DECODE_OVER); SDB_GET_RESERVE(pRaw, dataPos, MND_TOPIC_RESERVE_SIZE, TOPIC_DECODE_OVER) @@ -374,13 +373,11 @@ static int32_t mndGetNumOfTopics(SMnode *pMnode, char *dbName, int32_t *pNumOfTo int32_t numOfTopics = 0; void *pIter = NULL; while (1) { - STopicObj *pTopic = NULL; + SMqTopicObj *pTopic = NULL; pIter = sdbFetch(pSdb, SDB_TOPIC, pIter, (void **)&pTopic); if (pIter == NULL) break; - if (strcmp(pTopic->db, dbName) == 0) { - numOfTopics++; - } + numOfTopics++; sdbRelease(pSdb, pTopic); } From 4725b4e02042b521c155292239f204d17ea64aed Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Thu, 6 Jan 2022 11:16:26 +0800 Subject: [PATCH 15/18] [td-11818] fix crash in create database. --- source/libs/scheduler/inc/schedulerInt.h | 4 ++-- source/libs/scheduler/src/scheduler.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/source/libs/scheduler/inc/schedulerInt.h b/source/libs/scheduler/inc/schedulerInt.h index be488ea87b..779a264699 100644 --- a/source/libs/scheduler/inc/schedulerInt.h +++ b/source/libs/scheduler/inc/schedulerInt.h @@ -104,8 +104,8 @@ typedef struct SSchJob { SHashObj *succTasks; // succeed tasks, key:taskid, value:SQueryTask* SHashObj *failTasks; // failed tasks, key:taskid, value:SQueryTask* - SArray *levels; // Element is SQueryLevel, starting from 0. - SArray *subPlans; // Element is SArray*, and nested element is SSubplan. The execution level of subplan, starting from 0. + SArray *levels; // Element is SQueryLevel, starting from 0. SArray + SArray *subPlans; // Element is SArray*, and nested element is SSubplan. The execution level of subplan, starting from 0. SArray SQueryProfileSummary summary; } SSchJob; diff --git a/source/libs/scheduler/src/scheduler.c b/source/libs/scheduler/src/scheduler.c index 8271d865a1..90233f86cb 100644 --- a/source/libs/scheduler/src/scheduler.c +++ b/source/libs/scheduler/src/scheduler.c @@ -1070,8 +1070,8 @@ void scheduleFreeJob(void *pJob) { schDropJobAllTasks(job); } - - taosArrayDestroy(job->subPlans); + + job->subPlans = NULL; // it is a reference to pDag->pSubplans int32_t numOfLevels = taosArrayGetSize(job->levels); for(int32_t i = 0; i < numOfLevels; ++i) { SSchLevel *pLevel = taosArrayGet(job->levels, i); From 20c264ba027ba73cfefcfdc493d9b0a63b1104fa Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Thu, 6 Jan 2022 11:37:45 +0800 Subject: [PATCH 16/18] [td-11818] fix invalid write. --- source/client/src/clientImpl.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 9f91fa8a23..26c27a5cae 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -535,9 +535,7 @@ void* doFetchRow(SRequestObj* pRequest) { int64_t transporterId = 0; STscObj *pTscObj = pRequest->pTscObj; asyncSendMsgToServer(pTscObj->pTransporter, &pTscObj->pAppInfo->mgmtEp.epSet, &transporterId, body); - tsem_wait(&pRequest->body.rspSem); - destroySendMsgInfo(body); pRequest->type = TDMT_VND_SHOW_TABLES_FETCH; } From db2dbe5f519ef016245e38e31f87e18c3c0f3ac5 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 5 Jan 2022 20:22:33 -0800 Subject: [PATCH 17/18] pullup trans when mnode restart --- source/dnode/mnode/impl/inc/mndDef.h | 4 +- source/dnode/mnode/impl/src/mndSync.c | 3 +- source/dnode/mnode/impl/src/mndTrans.c | 6 +- source/dnode/mnode/impl/test/bnode/bnode.cpp | 8 +- source/dnode/mnode/impl/test/qnode/qnode.cpp | 8 +- source/dnode/mnode/impl/test/snode/snode.cpp | 8 +- source/dnode/mnode/impl/test/trans/trans.cpp | 79 ++++++++++++++++++-- 7 files changed, 87 insertions(+), 29 deletions(-) diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index 93a5722842..d19718d4e0 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -64,8 +64,8 @@ typedef enum { TRN_STAGE_PREPARE = 0, TRN_STAGE_REDO_LOG = 1, TRN_STAGE_REDO_ACTION = 2, - TRN_STAGE_COMMIT_LOG = 3, - TRN_STAGE_COMMIT = 4, + TRN_STAGE_COMMIT = 3, + TRN_STAGE_COMMIT_LOG = 4, TRN_STAGE_UNDO_ACTION = 5, TRN_STAGE_UNDO_LOG = 6, TRN_STAGE_ROLLBACK = 7, diff --git a/source/dnode/mnode/impl/src/mndSync.c b/source/dnode/mnode/impl/src/mndSync.c index bf1697fb19..47d0ce4105 100644 --- a/source/dnode/mnode/impl/src/mndSync.c +++ b/source/dnode/mnode/impl/src/mndSync.c @@ -54,7 +54,7 @@ static int32_t mndRestoreWal(SMnode *pMnode) { int64_t first = walGetFirstVer(pWal); int64_t last = walGetLastVer(pWal); - mDebug("restore sdb wal start, sdb ver:%" PRId64 ", wal first:%" PRId64 " last:%" PRId64, lastSdbVer, first, last); + mDebug("start to restore sdb wal, sdb ver:%" PRId64 ", wal first:%" PRId64 " last:%" PRId64, lastSdbVer, first, last); first = MAX(lastSdbVer + 1, first); for (int64_t ver = first; ver >= 0 && ver <= last; ++ver) { @@ -71,6 +71,7 @@ static int32_t mndRestoreWal(SMnode *pMnode) { goto WAL_RESTORE_OVER; } + mTrace("wal:%" PRId64 ", will be restored, content:%p", ver, pHead->head.body); if (sdbWriteNotFree(pSdb, (void *)pHead->head.body) < 0) { mError("failed to read wal from sdb since %s, ver:%" PRId64, terrstr(), ver); goto WAL_RESTORE_OVER; diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index 11bd15d270..4a42133ce3 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -112,6 +112,7 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) { int32_t dataPos = 0; SDB_SET_INT32(pRaw, dataPos, pTrans->id, TRANS_ENCODE_OVER) SDB_SET_INT8(pRaw, dataPos, pTrans->policy, TRANS_ENCODE_OVER) + SDB_SET_INT8(pRaw, dataPos, pTrans->stage, TRANS_ENCODE_OVER) SDB_SET_INT32(pRaw, dataPos, redoLogNum, TRANS_ENCODE_OVER) SDB_SET_INT32(pRaw, dataPos, undoLogNum, TRANS_ENCODE_OVER) SDB_SET_INT32(pRaw, dataPos, commitLogNum, TRANS_ENCODE_OVER) @@ -216,6 +217,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) { SDB_GET_INT32(pRaw, dataPos, &pTrans->id, TRANS_DECODE_OVER) SDB_GET_INT8(pRaw, dataPos, (int8_t *)&pTrans->policy, TRANS_DECODE_OVER) + SDB_GET_INT8(pRaw, dataPos, (int8_t *)&pTrans->stage, TRANS_DECODE_OVER) SDB_GET_INT32(pRaw, dataPos, &redoLogNum, TRANS_DECODE_OVER) SDB_GET_INT32(pRaw, dataPos, &undoLogNum, TRANS_DECODE_OVER) SDB_GET_INT32(pRaw, dataPos, &commitLogNum, TRANS_DECODE_OVER) @@ -315,6 +317,8 @@ static int32_t mndTransActionDelete(SSdb *pSdb, STrans *pTrans) { } static int32_t mndTransActionUpdate(SSdb *pSdb, STrans *pOld, STrans *pNew) { + if (pNew->stage == TRN_STAGE_COMMIT) pNew->stage = TRN_STAGE_COMMIT_LOG; + mTrace("trans:%d, perform update action, old row:%p stage:%d, new row:%p stage:%d", pOld->id, pOld, pOld->stage, pNew, pNew->stage); pOld->stage = pNew->stage; @@ -646,7 +650,7 @@ static int32_t mndTransSendActionMsg(SMnode *pMnode, STrans *pTrans, SArray *pAr pAction->msgReceived = 0; pAction->errCode = 0; } else { - mDebug("trans:%d, action:%d not sent since %s", pTrans->id, action, terrstr()); + mDebug("trans:%d, action:%d not send since %s", pTrans->id, action, terrstr()); return -1; } } diff --git a/source/dnode/mnode/impl/test/bnode/bnode.cpp b/source/dnode/mnode/impl/test/bnode/bnode.cpp index e32c0e7f91..c33776fd1b 100644 --- a/source/dnode/mnode/impl/test/bnode/bnode.cpp +++ b/source/dnode/mnode/impl/test/bnode/bnode.cpp @@ -186,7 +186,6 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) { SMCreateBnodeReq* pReq = (SMCreateBnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - server2.Stop(); SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_CREATING); @@ -199,7 +198,6 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) { SMDropBnodeReq* pReq = (SMDropBnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - server2.Stop(); SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_BNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_CREATING); @@ -211,7 +209,7 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) { taosMsleep(1000); int32_t retry = 0; - int32_t retryMax = 10; + int32_t retryMax = 20; for (retry = 0; retry < retryMax; retry++) { int32_t contLen = sizeof(SMCreateBnodeReq); @@ -250,7 +248,6 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) { SMCreateBnodeReq* pReq = (SMCreateBnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - server2.Stop(); SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_BNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_DROPPING); @@ -263,7 +260,6 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) { SMDropBnodeReq* pReq = (SMDropBnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - server2.Stop(); SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_BNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_DROPPING); @@ -275,7 +271,7 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) { taosMsleep(1000); int32_t retry = 0; - int32_t retryMax = 10; + int32_t retryMax = 20; for (retry = 0; retry < retryMax; retry++) { int32_t contLen = sizeof(SMCreateBnodeReq); diff --git a/source/dnode/mnode/impl/test/qnode/qnode.cpp b/source/dnode/mnode/impl/test/qnode/qnode.cpp index 55806dca4d..9aa41ca177 100644 --- a/source/dnode/mnode/impl/test/qnode/qnode.cpp +++ b/source/dnode/mnode/impl/test/qnode/qnode.cpp @@ -186,7 +186,6 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) { SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - server2.Stop(); SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_CREATING); @@ -199,7 +198,6 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) { SMDropQnodeReq* pReq = (SMDropQnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - server2.Stop(); SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_QNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_CREATING); @@ -211,7 +209,7 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) { taosMsleep(1000); int32_t retry = 0; - int32_t retryMax = 10; + int32_t retryMax = 20; for (retry = 0; retry < retryMax; retry++) { int32_t contLen = sizeof(SMCreateQnodeReq); @@ -250,7 +248,6 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) { SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - server2.Stop(); SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_DROPPING); @@ -263,7 +260,6 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) { SMDropQnodeReq* pReq = (SMDropQnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - server2.Stop(); SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_QNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_DROPPING); @@ -275,7 +271,7 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) { taosMsleep(1000); int32_t retry = 0; - int32_t retryMax = 10; + int32_t retryMax = 20; for (retry = 0; retry < retryMax; retry++) { int32_t contLen = sizeof(SMCreateQnodeReq); diff --git a/source/dnode/mnode/impl/test/snode/snode.cpp b/source/dnode/mnode/impl/test/snode/snode.cpp index 9e07be842f..2dcfc658a4 100644 --- a/source/dnode/mnode/impl/test/snode/snode.cpp +++ b/source/dnode/mnode/impl/test/snode/snode.cpp @@ -186,7 +186,6 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) { SMCreateSnodeReq* pReq = (SMCreateSnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - server2.Stop(); SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_CREATING); @@ -199,7 +198,6 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) { SMDropSnodeReq* pReq = (SMDropSnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - server2.Stop(); SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_SNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_CREATING); @@ -211,7 +209,7 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) { taosMsleep(1000); int32_t retry = 0; - int32_t retryMax = 10; + int32_t retryMax = 20; for (retry = 0; retry < retryMax; retry++) { int32_t contLen = sizeof(SMCreateSnodeReq); @@ -250,7 +248,6 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) { SMCreateSnodeReq* pReq = (SMCreateSnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - server2.Stop(); SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_SNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_DROPPING); @@ -263,7 +260,6 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) { SMDropSnodeReq* pReq = (SMDropSnodeReq*)rpcMallocCont(contLen); pReq->dnodeId = htonl(2); - server2.Stop(); SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_SNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, TSDB_CODE_SDB_OBJ_DROPPING); @@ -275,7 +271,7 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) { taosMsleep(1000); int32_t retry = 0; - int32_t retryMax = 10; + int32_t retryMax = 20; for (retry = 0; retry < retryMax; retry++) { int32_t contLen = sizeof(SMCreateSnodeReq); diff --git a/source/dnode/mnode/impl/test/trans/trans.cpp b/source/dnode/mnode/impl/test/trans/trans.cpp index eef94436b7..e2ed707a99 100644 --- a/source/dnode/mnode/impl/test/trans/trans.cpp +++ b/source/dnode/mnode/impl/test/trans/trans.cpp @@ -13,8 +13,18 @@ class MndTestTrans : public ::testing::Test { protected: - static void SetUpTestSuite() { test.Init("/tmp/mnode_test_trans", 9013); } - static void TearDownTestSuite() { test.Cleanup(); } + static void SetUpTestSuite() { + test.Init("/tmp/mnode_test_trans", 9013); + const char* fqdn = "localhost"; + const char* firstEp = "localhost:9013"; + server2.Start("/tmp/mnode_test_trans2", fqdn, 9020, firstEp); + } + + static void TearDownTestSuite() { + server2.Stop(); + test.Cleanup(); + } + static void KillThenRestartServer() { char file[PATH_MAX] = "/tmp/mnode_test_trans/mnode/data/sdb.data"; FileFd fd = taosOpenFileRead(file); @@ -40,14 +50,16 @@ class MndTestTrans : public ::testing::Test { test.ServerStart(); } - static Testbase test; + static Testbase test; + static TestServer server2; public: void SetUp() override {} void TearDown() override {} }; -Testbase MndTestTrans::test; +Testbase MndTestTrans::test; +TestServer MndTestTrans::server2; TEST_F(MndTestTrans, 01_Create_User_Crash) { { @@ -84,7 +96,7 @@ TEST_F(MndTestTrans, 01_Create_User_Crash) { CheckBinary("root", TSDB_USER_LEN); } -TEST_F(MndTestTrans, 02_Create_Qnode_Crash) { +TEST_F(MndTestTrans, 02_Create_Qnode1_Crash) { { int32_t contLen = sizeof(SMCreateQnodeReq); @@ -102,9 +114,60 @@ TEST_F(MndTestTrans, 02_Create_Qnode_Crash) { } KillThenRestartServer(); + { + int32_t contLen = sizeof(SMCreateQnodeReq); + + SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen); + pReq->dnodeId = htonl(1); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_QNODE_ALREADY_EXIST); + + test.SendShowMetaReq(TSDB_MGMT_TABLE_QNODE, ""); + CHECK_META("show qnodes", 3); + test.SendShowRetrieveReq(); + EXPECT_EQ(test.GetShowRows(), 1); + } +} + +TEST_F(MndTestTrans, 03_Create_Qnode2_Crash) { + { + int32_t contLen = sizeof(SCreateDnodeMsg); + + SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen); + strcpy(pReq->fqdn, "localhost"); + pReq->port = htonl(9020); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); + + taosMsleep(1300); + test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, ""); + test.SendShowRetrieveReq(); + EXPECT_EQ(test.GetShowRows(), 2); + } + + { + int32_t contLen = sizeof(SMCreateQnodeReq); + + SMCreateQnodeReq* pReq = (SMCreateQnodeReq*)rpcMallocCont(contLen); + pReq->dnodeId = htonl(2); + + server2.Stop(); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_QNODE, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_RPC_NETWORK_UNAVAIL); + } + + KillThenRestartServer(); + + server2.DoStart(); + { int32_t retry = 0; - int32_t retryMax = 10; + int32_t retryMax = 20; for (retry = 0; retry < retryMax; retry++) { int32_t contLen = sizeof(SMCreateQnodeReq); @@ -118,9 +181,11 @@ TEST_F(MndTestTrans, 02_Create_Qnode_Crash) { taosMsleep(1000); } + ASSERT_NE(retry, retryMax); + test.SendShowMetaReq(TSDB_MGMT_TABLE_QNODE, ""); CHECK_META("show qnodes", 3); test.SendShowRetrieveReq(); - EXPECT_EQ(test.GetShowRows(), 1); + EXPECT_EQ(test.GetShowRows(), 2); } } \ No newline at end of file From ca7ab427f5a159ce804aeb52f84a87d0f761407c Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Thu, 6 Jan 2022 14:08:09 +0800 Subject: [PATCH 18/18] [td-11818]fix invalid read. --- source/libs/scheduler/src/scheduler.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/source/libs/scheduler/src/scheduler.c b/source/libs/scheduler/src/scheduler.c index 90233f86cb..b35823bc76 100644 --- a/source/libs/scheduler/src/scheduler.c +++ b/source/libs/scheduler/src/scheduler.c @@ -346,11 +346,12 @@ _return: int32_t schProcessOnJobPartialSuccess(SSchJob *job) { job->status = JOB_TASK_STATUS_PARTIAL_SUCCEED; + bool needFetch = job->userFetch; if ((!job->attr.needFetch) && job->attr.syncSchedule) { tsem_post(&job->rspSem); } - if (job->userFetch) { + if (needFetch) { SCH_ERR_RET(schFetchFromRemote(job)); } @@ -420,7 +421,6 @@ int32_t schProcessOnTaskSuccess(SSchJob *job, SSchTask *task) { } job->fetchTask = task; - SCH_ERR_RET(schProcessOnJobPartialSuccess(job)); return TSDB_CODE_SUCCESS; @@ -495,7 +495,6 @@ int32_t schProcessRspMsg(SSchJob *job, SSchTask *task, int32_t msgType, char *ms if (rspCode != TSDB_CODE_SUCCESS) { SCH_ERR_JRET(schProcessOnTaskFailure(job, task, rspCode)); } else { -// job->resNumOfRows += rsp->affectedRows; code = schProcessOnTaskSuccess(job, task); if (code) { goto _task_error;