From a1a498a19adb8d8a1ff19224892f5900cec26cba Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Wed, 20 Apr 2022 16:56:00 +0800 Subject: [PATCH] sync integration add error code --- include/util/taoserror.h | 4 ++++ source/dnode/mgmt/mgmt_vnode/src/vmWorker.c | 4 ++-- source/libs/sync/test/syncApplyMsgTest.cpp | 16 ++++++++-------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/include/util/taoserror.h b/include/util/taoserror.h index c5b477343d..93ab133dc1 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -407,6 +407,10 @@ int32_t* taosGetErrno(); #define TSDB_CODE_SYN_INVALID_MSGLEN TAOS_DEF_ERROR_CODE(0, 0x0909) #define TSDB_CODE_SYN_INVALID_MSGTYPE TAOS_DEF_ERROR_CODE(0, 0x090A) +// sync integration +#define TSDB_CODE_SYN_NOT_LEADER TAOS_DEF_ERROR_CODE(0, 0x0910) +#define TSDB_CODE_SYN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x09FF) + // tq #define TSDB_CODE_TQ_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0A00) #define TSDB_CODE_TQ_INIT_FAILED TAOS_DEF_ERROR_CODE(0, 0x0A01) diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c index b3afba51c0..206f53d36b 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c @@ -153,10 +153,10 @@ static void vmProcessWriteQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO int32_t ret = syncPropose(vnodeGetSyncHandle(pVnode->pImpl), pRpc, false); if (ret == TAOS_SYNC_PROPOSE_NOT_LEADER) { - rsp.code = -1; + rsp.code = TSDB_CODE_SYN_NOT_LEADER; tmsgSendRsp(&rsp); } else if (ret == TAOS_SYNC_PROPOSE_OTHER_ERROR) { - rsp.code = -2; + rsp.code = TSDB_CODE_SYN_INTERNAL_ERROR; tmsgSendRsp(&rsp); } else if (ret == TAOS_SYNC_PROPOSE_SUCCESS) { // ok diff --git a/source/libs/sync/test/syncApplyMsgTest.cpp b/source/libs/sync/test/syncApplyMsgTest.cpp index 7544613c5d..30019f71e5 100644 --- a/source/libs/sync/test/syncApplyMsgTest.cpp +++ b/source/libs/sync/test/syncApplyMsgTest.cpp @@ -42,8 +42,8 @@ void test1() { void test2() { SyncApplyMsg *pMsg = createMsg(); - uint32_t len = pMsg->bytes; - char * serialized = (char *)taosMemoryMalloc(len); + uint32_t len = pMsg->bytes; + char * serialized = (char *)taosMemoryMalloc(len); syncApplyMsgSerialize(pMsg, serialized, len); SyncApplyMsg *pMsg2 = syncApplyMsgBuild(pMsg->dataLen); syncApplyMsgDeserialize(serialized, len, pMsg2); @@ -56,8 +56,8 @@ void test2() { void test3() { SyncApplyMsg *pMsg = createMsg(); - uint32_t len; - char * serialized = syncApplyMsgSerialize2(pMsg, &len); + uint32_t len; + char * serialized = syncApplyMsgSerialize2(pMsg, &len); SyncApplyMsg *pMsg2 = syncApplyMsgDeserialize2(serialized, len); syncApplyMsgLog2((char *)"test3: syncApplyMsgSerialize2 -> syncApplyMsgDeserialize2 ", pMsg2); @@ -68,7 +68,7 @@ void test3() { void test4() { SyncApplyMsg *pMsg = createMsg(); - SRpcMsg rpcMsg; + SRpcMsg rpcMsg; syncApplyMsg2RpcMsg(pMsg, &rpcMsg); SyncApplyMsg *pMsg2 = (SyncApplyMsg *)taosMemoryMalloc(rpcMsg.contLen); syncApplyMsgFromRpcMsg(&rpcMsg, pMsg2); @@ -81,7 +81,7 @@ void test4() { void test5() { SyncApplyMsg *pMsg = createMsg(); - SRpcMsg rpcMsg; + SRpcMsg rpcMsg; syncApplyMsg2RpcMsg(pMsg, &rpcMsg); SyncApplyMsg *pMsg2 = syncApplyMsgFromRpcMsg2(&rpcMsg); syncApplyMsgLog2((char *)"test5: syncClientRequest2RpcMsg -> syncApplyMsgFromRpcMsg2 ", pMsg2); @@ -93,13 +93,13 @@ void test5() { void test6() { SyncApplyMsg *pMsg = createMsg(); - SRpcMsg rpcMsg; + SRpcMsg rpcMsg; syncApplyMsg2RpcMsg(pMsg, &rpcMsg); SyncApplyMsg *pMsg2 = syncApplyMsgFromRpcMsg2(&rpcMsg); SRpcMsg originalRpcMsg; syncApplyMsg2OriginalRpcMsg(pMsg2, &originalRpcMsg); - syncRpcMsgLog2((char*)"test6", &originalRpcMsg); + syncRpcMsgLog2((char *)"test6", &originalRpcMsg); rpcFreeCont(originalRpcMsg.pCont); rpcFreeCont(rpcMsg.pCont);