minor changes
This commit is contained in:
parent
455006cc2a
commit
856104c4f3
|
@ -26,7 +26,7 @@ int32_t mndInitTopic(SMnode *pMnode);
|
|||
void mndCleanupTopic(SMnode *pMnode);
|
||||
|
||||
STopicObj *mndAcquireTopic(SMnode *pMnode, char *topicName);
|
||||
void mndReleaseTopic(SMnode *pMnode, STopicObj *pTopic);
|
||||
void mndReleaseTopic(SMnode *pMnode, STopicObj *pTopic);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -441,7 +441,7 @@ static void *mnodeGenTypeStr(char *buf, int32_t buflen, uint8_t type, int16_t le
|
|||
}
|
||||
|
||||
if (type == TSDB_DATA_TYPE_NCHAR || type == TSDB_DATA_TYPE_BINARY) {
|
||||
int32_t bytes = len > 0 ? (int)(len - VARSTR_HEADER_SIZE) : len;
|
||||
int32_t bytes = len > 0 ? (int32_t)(len - VARSTR_HEADER_SIZE) : len;
|
||||
|
||||
snprintf(buf, buflen - 1, "%s(%d)", tDataTypes[type].name, type == TSDB_DATA_TYPE_NCHAR ? bytes / 4 : bytes);
|
||||
buf[buflen - 1] = 0;
|
||||
|
|
|
@ -834,8 +834,8 @@ static int32_t mndGetStbMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pM
|
|||
}
|
||||
|
||||
static void mndExtractTableName(char *tableId, char *name) {
|
||||
int pos = -1;
|
||||
int num = 0;
|
||||
int32_t pos = -1;
|
||||
int32_t num = 0;
|
||||
for (pos = 0; tableId[pos] != 0; ++pos) {
|
||||
if (tableId[pos] == '.') num++;
|
||||
if (num == 2) break;
|
||||
|
|
|
@ -14,18 +14,18 @@
|
|||
*/
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "mndStb.h"
|
||||
#include "mndDb.h"
|
||||
#include "mndDnode.h"
|
||||
#include "mndMnode.h"
|
||||
#include "mndShow.h"
|
||||
#include "mndStb.h"
|
||||
#include "mndTrans.h"
|
||||
#include "mndUser.h"
|
||||
#include "mndVgroup.h"
|
||||
#include "tname.h"
|
||||
|
||||
#define TSDB_TOPIC_VER_NUMBER 1
|
||||
#define TSDB_TOPIC_RESERVE_SIZE 64
|
||||
#define MND_TOPIC_VER_NUMBER 1
|
||||
#define MND_TOPIC_RESERVE_SIZE 64
|
||||
|
||||
static SSdbRaw *mndTopicActionEncode(STopicObj *pTopic);
|
||||
static SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw);
|
||||
|
@ -73,8 +73,8 @@ int32_t mndInitTopic(SMnode *pMnode) {
|
|||
void mndCleanupTopic(SMnode *pMnode) {}
|
||||
|
||||
static SSdbRaw *mndTopicActionEncode(STopicObj *pTopic) {
|
||||
int32_t size = sizeof(STopicObj) + TSDB_TOPIC_RESERVE_SIZE;
|
||||
SSdbRaw *pRaw = sdbAllocRaw(SDB_TOPIC, TSDB_TOPIC_VER_NUMBER, size);
|
||||
int32_t size = sizeof(STopicObj) + MND_TOPIC_RESERVE_SIZE;
|
||||
SSdbRaw *pRaw = sdbAllocRaw(SDB_TOPIC, MND_TOPIC_VER_NUMBER, size);
|
||||
if (pRaw == NULL) return NULL;
|
||||
|
||||
int32_t dataPos = 0;
|
||||
|
@ -90,7 +90,7 @@ static SSdbRaw *mndTopicActionEncode(STopicObj *pTopic) {
|
|||
SDB_SET_INT32(pRaw, dataPos, pTopic->sqlLen);
|
||||
SDB_SET_BINARY(pRaw, dataPos, pTopic->sql, pTopic->sqlLen);
|
||||
|
||||
SDB_SET_RESERVE(pRaw, dataPos, TSDB_TOPIC_RESERVE_SIZE);
|
||||
SDB_SET_RESERVE(pRaw, dataPos, MND_TOPIC_RESERVE_SIZE);
|
||||
SDB_SET_DATALEN(pRaw, dataPos);
|
||||
|
||||
return pRaw;
|
||||
|
@ -100,14 +100,14 @@ static SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
|
|||
int8_t sver = 0;
|
||||
if (sdbGetRawSoftVer(pRaw, &sver) != 0) return NULL;
|
||||
|
||||
if (sver != TSDB_TOPIC_VER_NUMBER) {
|
||||
mError("failed to decode stable since %s", terrstr());
|
||||
if (sver != MND_TOPIC_VER_NUMBER) {
|
||||
terrno = TSDB_CODE_SDB_INVALID_DATA_VER;
|
||||
mError("failed to decode topic since %s", terrstr());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int32_t size = sizeof(STopicObj) + TSDB_MAX_COLUMNS * sizeof(SSchema);
|
||||
SSdbRow *pRow = sdbAllocRow(size);
|
||||
int32_t size = sizeof(STopicObj) + TSDB_MAX_COLUMNS * sizeof(SSchema);
|
||||
SSdbRow *pRow = sdbAllocRow(size);
|
||||
STopicObj *pTopic = sdbGetRowObj(pRow);
|
||||
if (pTopic == NULL) return NULL;
|
||||
|
||||
|
@ -124,7 +124,7 @@ static SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
|
|||
SDB_GET_INT32(pRaw, pRow, dataPos, &pTopic->sqlLen);
|
||||
SDB_GET_BINARY(pRaw, pRow, dataPos, pTopic->sql, pTopic->sqlLen);
|
||||
|
||||
SDB_GET_RESERVE(pRaw, pRow, dataPos, TSDB_TOPIC_RESERVE_SIZE);
|
||||
SDB_GET_RESERVE(pRaw, pRow, dataPos, MND_TOPIC_RESERVE_SIZE);
|
||||
|
||||
return pRow;
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ static int32_t mndTopicActionUpdate(SSdb *pSdb, STopicObj *pOldTopic, STopicObj
|
|||
}
|
||||
|
||||
STopicObj *mndAcquireTopic(SMnode *pMnode, char *topicName) {
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
STopicObj *pTopic = sdbAcquire(pSdb, SDB_TOPIC, topicName);
|
||||
if (pTopic == NULL) {
|
||||
terrno = TSDB_CODE_MND_TOPIC_NOT_EXIST;
|
||||
|
@ -208,7 +208,7 @@ static SCreateTopicInternalMsg *mndBuildCreateTopicMsg(SMnode *pMnode, SVgObj *p
|
|||
pCreate->sverson = htonl(pTopic->version);
|
||||
|
||||
pCreate->sql = malloc(pTopic->sqlLen);
|
||||
if(pCreate->sql == NULL) {
|
||||
if (pCreate->sql == NULL) {
|
||||
free(pCreate);
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
|
@ -216,7 +216,7 @@ static SCreateTopicInternalMsg *mndBuildCreateTopicMsg(SMnode *pMnode, SVgObj *p
|
|||
memcpy(pCreate->sql, pTopic->sql, pTopic->sqlLen);
|
||||
|
||||
pCreate->executor = malloc(pTopic->execLen);
|
||||
if(pCreate->executor == NULL) {
|
||||
if (pCreate->executor == NULL) {
|
||||
free(pCreate);
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
|
@ -244,7 +244,7 @@ static SDropTopicInternalMsg *mndBuildDropTopicMsg(SMnode *pMnode, SVgObj *pVgro
|
|||
}
|
||||
|
||||
static int32_t mndCheckCreateTopicMsg(SCreateTopicMsg *pCreate) {
|
||||
//deserialize and other stuff
|
||||
// deserialize and other stuff
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -413,7 +413,7 @@ CREATE_TOPIC_OVER:
|
|||
}
|
||||
|
||||
static int32_t mndProcessCreateTopicMsg(SMnodeMsg *pMsg) {
|
||||
SMnode *pMnode = pMsg->pMnode;
|
||||
SMnode *pMnode = pMsg->pMnode;
|
||||
SCreateTopicMsg *pCreate = pMsg->rpcMsg.pCont;
|
||||
|
||||
mDebug("topic:%s, start to create", pCreate->name);
|
||||
|
@ -436,7 +436,7 @@ static int32_t mndProcessCreateTopicMsg(SMnodeMsg *pMsg) {
|
|||
}
|
||||
}
|
||||
|
||||
//topic should have different name with stb
|
||||
// topic should have different name with stb
|
||||
SStbObj *pStb = mndAcquireStb(pMnode, pCreate->name);
|
||||
if (pStb != NULL) {
|
||||
sdbRelease(pMnode->pSdb, pStb);
|
||||
|
@ -492,7 +492,7 @@ static int32_t mndCheckAlterTopicMsg(SAlterTopicMsg *pAlter) {
|
|||
static int32_t mndUpdateTopic(SMnode *pMnode, SMnodeMsg *pMsg, STopicObj *pOldTopic, STopicObj *pNewTopic) { return 0; }
|
||||
|
||||
static int32_t mndProcessAlterTopicMsg(SMnodeMsg *pMsg) {
|
||||
SMnode *pMnode = pMsg->pMnode;
|
||||
SMnode *pMnode = pMsg->pMnode;
|
||||
SAlterTopicMsg *pAlter = pMsg->rpcMsg.pCont;
|
||||
|
||||
mDebug("topic:%s, start to alter", pAlter->name);
|
||||
|
@ -606,7 +606,7 @@ DROP_TOPIC_OVER:
|
|||
}
|
||||
|
||||
static int32_t mndProcessDropTopicMsg(SMnodeMsg *pMsg) {
|
||||
SMnode *pMnode = pMsg->pMnode;
|
||||
SMnode *pMnode = pMsg->pMnode;
|
||||
SDropTopicMsg *pDrop = pMsg->rpcMsg.pCont;
|
||||
|
||||
mDebug("topic:%s, start to drop", pDrop->name);
|
||||
|
@ -705,7 +705,7 @@ static int32_t mndProcessTopicMetaMsg(SMnodeMsg *pMsg) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndProcessCreateTopicInRsp(SMnodeMsg* pMsg) {
|
||||
static int32_t mndProcessCreateTopicInRsp(SMnodeMsg *pMsg) {
|
||||
mndTransHandleActionRsp(pMsg);
|
||||
return 0;
|
||||
}
|
||||
|
@ -788,8 +788,8 @@ static int32_t mndGetTopicMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
|
|||
}
|
||||
|
||||
static void mndExtractTableName(char *tableId, char *name) {
|
||||
int pos = -1;
|
||||
int num = 0;
|
||||
int32_t pos = -1;
|
||||
int32_t num = 0;
|
||||
for (pos = 0; tableId[pos] != 0; ++pos) {
|
||||
if (tableId[pos] == '.') num++;
|
||||
if (num == 2) break;
|
||||
|
@ -801,13 +801,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;
|
||||
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};
|
||||
int32_t cols = 0;
|
||||
char *pWrite;
|
||||
char prefix[64] = {0};
|
||||
|
||||
tstrncpy(prefix, pShow->db, 64);
|
||||
strcat(prefix, TS_PATH_DELIMITER);
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
#include "mndTrans.h"
|
||||
#include "mndSync.h"
|
||||
|
||||
#define TSDB_TRANS_VER_NUMBER 1
|
||||
#define TSDB_TRN_ARRAY_SIZE 8
|
||||
#define TSDB_TRN_RESERVE_SIZE 64
|
||||
#define MND_TRANS_VER_NUMBER 1
|
||||
#define MND_TRANS_ARRAY_SIZE 8
|
||||
#define MND_TRANS_RESERVE_SIZE 64
|
||||
|
||||
static SSdbRaw *mndTransActionEncode(STrans *pTrans);
|
||||
static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw);
|
||||
|
@ -61,7 +61,7 @@ int32_t mndInitTrans(SMnode *pMnode) {
|
|||
void mndCleanupTrans(SMnode *pMnode) {}
|
||||
|
||||
static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
|
||||
int32_t rawDataLen = sizeof(STrans) + TSDB_TRN_RESERVE_SIZE;
|
||||
int32_t rawDataLen = sizeof(STrans) + MND_TRANS_RESERVE_SIZE;
|
||||
int32_t redoLogNum = taosArrayGetSize(pTrans->redoLogs);
|
||||
int32_t undoLogNum = taosArrayGetSize(pTrans->undoLogs);
|
||||
int32_t commitLogNum = taosArrayGetSize(pTrans->commitLogs);
|
||||
|
@ -93,7 +93,7 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
|
|||
rawDataLen += (sizeof(STransAction) + pAction->contLen);
|
||||
}
|
||||
|
||||
SSdbRaw *pRaw = sdbAllocRaw(SDB_TRANS, TSDB_TRANS_VER_NUMBER, rawDataLen);
|
||||
SSdbRaw *pRaw = sdbAllocRaw(SDB_TRANS, MND_TRANS_VER_NUMBER, rawDataLen);
|
||||
if (pRaw == NULL) {
|
||||
mError("trans:%d, failed to alloc raw since %s", pTrans->id, terrstr());
|
||||
return NULL;
|
||||
|
@ -145,7 +145,7 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
|
|||
SDB_SET_BINARY(pRaw, dataPos, (void *)pAction->pCont, pAction->contLen);
|
||||
}
|
||||
|
||||
SDB_SET_RESERVE(pRaw, dataPos, TSDB_TRN_RESERVE_SIZE)
|
||||
SDB_SET_RESERVE(pRaw, dataPos, MND_TRANS_RESERVE_SIZE)
|
||||
SDB_SET_DATALEN(pRaw, dataPos);
|
||||
mTrace("trans:%d, encode to raw:%p, len:%d", pTrans->id, pRaw, dataPos);
|
||||
return pRaw;
|
||||
|
@ -155,12 +155,9 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
|
|||
int32_t code = 0;
|
||||
|
||||
int8_t sver = 0;
|
||||
if (sdbGetRawSoftVer(pRaw, &sver) != 0) {
|
||||
mError("failed to get soft ver from raw:%p since %s", pRaw, terrstr());
|
||||
return NULL;
|
||||
}
|
||||
if (sdbGetRawSoftVer(pRaw, &sver) != 0) return NULL;
|
||||
|
||||
if (sver != TSDB_TRANS_VER_NUMBER) {
|
||||
if (sver != MND_TRANS_VER_NUMBER) {
|
||||
terrno = TSDB_CODE_SDB_INVALID_DATA_VER;
|
||||
mError("failed to get check soft ver from raw:%p since %s", pRaw, terrstr());
|
||||
return NULL;
|
||||
|
@ -173,11 +170,11 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
pTrans->redoLogs = taosArrayInit(TSDB_TRN_ARRAY_SIZE, sizeof(void *));
|
||||
pTrans->undoLogs = taosArrayInit(TSDB_TRN_ARRAY_SIZE, sizeof(void *));
|
||||
pTrans->commitLogs = taosArrayInit(TSDB_TRN_ARRAY_SIZE, sizeof(void *));
|
||||
pTrans->redoActions = taosArrayInit(TSDB_TRN_ARRAY_SIZE, sizeof(STransAction));
|
||||
pTrans->undoActions = taosArrayInit(TSDB_TRN_ARRAY_SIZE, sizeof(STransAction));
|
||||
pTrans->redoLogs = taosArrayInit(MND_TRANS_ARRAY_SIZE, sizeof(void *));
|
||||
pTrans->undoLogs = taosArrayInit(MND_TRANS_ARRAY_SIZE, sizeof(void *));
|
||||
pTrans->commitLogs = taosArrayInit(MND_TRANS_ARRAY_SIZE, sizeof(void *));
|
||||
pTrans->redoActions = taosArrayInit(MND_TRANS_ARRAY_SIZE, sizeof(STransAction));
|
||||
pTrans->undoActions = taosArrayInit(MND_TRANS_ARRAY_SIZE, sizeof(STransAction));
|
||||
|
||||
if (pTrans->redoLogs == NULL || pTrans->undoLogs == NULL || pTrans->commitLogs == NULL ||
|
||||
pTrans->redoActions == NULL || pTrans->undoActions == NULL) {
|
||||
|
@ -278,7 +275,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
|
|||
}
|
||||
}
|
||||
|
||||
SDB_GET_RESERVE(pRaw, pRow, dataPos, TSDB_TRN_RESERVE_SIZE)
|
||||
SDB_GET_RESERVE(pRaw, pRow, dataPos, MND_TRANS_RESERVE_SIZE)
|
||||
|
||||
TRANS_DECODE_OVER:
|
||||
if (code != 0) {
|
||||
|
@ -370,11 +367,11 @@ STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, void *rpcHandle) {
|
|||
pTrans->stage = TRN_STAGE_PREPARE;
|
||||
pTrans->policy = policy;
|
||||
pTrans->rpcHandle = rpcHandle;
|
||||
pTrans->redoLogs = taosArrayInit(TSDB_TRN_ARRAY_SIZE, sizeof(void *));
|
||||
pTrans->undoLogs = taosArrayInit(TSDB_TRN_ARRAY_SIZE, sizeof(void *));
|
||||
pTrans->commitLogs = taosArrayInit(TSDB_TRN_ARRAY_SIZE, sizeof(void *));
|
||||
pTrans->redoActions = taosArrayInit(TSDB_TRN_ARRAY_SIZE, sizeof(STransAction));
|
||||
pTrans->undoActions = taosArrayInit(TSDB_TRN_ARRAY_SIZE, sizeof(STransAction));
|
||||
pTrans->redoLogs = taosArrayInit(MND_TRANS_ARRAY_SIZE, sizeof(void *));
|
||||
pTrans->undoLogs = taosArrayInit(MND_TRANS_ARRAY_SIZE, sizeof(void *));
|
||||
pTrans->commitLogs = taosArrayInit(MND_TRANS_ARRAY_SIZE, sizeof(void *));
|
||||
pTrans->redoActions = taosArrayInit(MND_TRANS_ARRAY_SIZE, sizeof(STransAction));
|
||||
pTrans->undoActions = taosArrayInit(MND_TRANS_ARRAY_SIZE, sizeof(STransAction));
|
||||
|
||||
if (pTrans->redoLogs == NULL || pTrans->undoLogs == NULL || pTrans->commitLogs == NULL ||
|
||||
pTrans->redoActions == NULL || pTrans->undoActions == NULL) {
|
||||
|
@ -504,7 +501,7 @@ int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans) {
|
|||
|
||||
STrans *pNewTrans = mndAcquireTrans(pMnode, pTrans->id);
|
||||
if (pNewTrans == NULL) {
|
||||
mError("trans:%d, failed to ready from sdb since %s", pTrans->id, terrstr());
|
||||
mError("trans:%d, failed to read from sdb since %s", pTrans->id, terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -526,19 +523,17 @@ int32_t mndTransCommit(SMnode *pMnode, STrans *pTrans) {
|
|||
|
||||
if (taosArrayGetSize(pTrans->commitLogs) != 0) {
|
||||
mTrace("trans:%d, sync to other nodes", pTrans->id);
|
||||
int32_t code = mndSyncPropose(pMnode, pRaw);
|
||||
if (code != 0) {
|
||||
if (mndSyncPropose(pMnode, pRaw) != 0) {
|
||||
mError("trans:%d, failed to sync since %s", pTrans->id, terrstr());
|
||||
sdbFreeRaw(pRaw);
|
||||
return -1;
|
||||
}
|
||||
|
||||
mTrace("trans:%d, sync finished", pTrans->id);
|
||||
code = sdbWrite(pMnode->pSdb, pRaw);
|
||||
if (code != 0) {
|
||||
mError("trans:%d, failed to write sdb since %s", pTrans->id, terrstr());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (sdbWrite(pMnode->pSdb, pRaw) != 0) {
|
||||
mError("trans:%d, failed to write sdb since %s", pTrans->id, terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
mDebug("trans:%d, commit finished", pTrans->id);
|
||||
|
@ -614,7 +609,7 @@ void mndTransHandleActionRsp(SMnodeMsg *pMsg) {
|
|||
}
|
||||
|
||||
int32_t actionNum = taosArrayGetSize(pTrans->redoActions);
|
||||
if (action < 0 || action > actionNum) {
|
||||
if (action < 0 || action >= actionNum) {
|
||||
mError("trans:%d, invalid action:%d", transId, action);
|
||||
goto HANDLE_ACTION_RSP_OVER;
|
||||
}
|
||||
|
@ -636,6 +631,8 @@ static int32_t mndTransExecuteLogs(SMnode *pMnode, SArray *pArray) {
|
|||
SSdb *pSdb = pMnode->pSdb;
|
||||
int32_t arraySize = taosArrayGetSize(pArray);
|
||||
|
||||
if (arraySize == 0) return 0;
|
||||
|
||||
for (int32_t i = 0; i < arraySize; ++i) {
|
||||
SSdbRaw *pRaw = taosArrayGetP(pArray, i);
|
||||
int32_t code = sdbWriteNotFree(pSdb, pRaw);
|
||||
|
@ -648,45 +645,15 @@ static int32_t mndTransExecuteLogs(SMnode *pMnode, SArray *pArray) {
|
|||
}
|
||||
|
||||
static int32_t mndTransExecuteRedoLogs(SMnode *pMnode, STrans *pTrans) {
|
||||
int32_t code = 0;
|
||||
if (taosArrayGetSize(pTrans->redoLogs) != 0) {
|
||||
code = mndTransExecuteLogs(pMnode, pTrans->redoLogs);
|
||||
if (code != 0) {
|
||||
mError("trans:%d, failed to execute redo logs since %s", pTrans->id, terrstr())
|
||||
} else {
|
||||
mDebug("trans:%d, execute redo logs finished", pTrans->id)
|
||||
}
|
||||
}
|
||||
|
||||
return code;
|
||||
return mndTransExecuteLogs(pMnode, pTrans->redoLogs);
|
||||
}
|
||||
|
||||
static int32_t mndTransExecuteUndoLogs(SMnode *pMnode, STrans *pTrans) {
|
||||
int32_t code = 0;
|
||||
if (taosArrayGetSize(pTrans->undoLogs) != 0) {
|
||||
code = mndTransExecuteLogs(pMnode, pTrans->undoLogs);
|
||||
if (code != 0) {
|
||||
mError("trans:%d, failed to execute undo logs since %s", pTrans->id, terrstr())
|
||||
} else {
|
||||
mDebug("trans:%d, execute undo logs finished", pTrans->id)
|
||||
}
|
||||
}
|
||||
|
||||
return code;
|
||||
return mndTransExecuteLogs(pMnode, pTrans->undoLogs);
|
||||
}
|
||||
|
||||
static int32_t mndTransExecuteCommitLogs(SMnode *pMnode, STrans *pTrans) {
|
||||
int32_t code = 0;
|
||||
if (taosArrayGetSize(pTrans->commitLogs) != 0) {
|
||||
code = mndTransExecuteLogs(pMnode, pTrans->commitLogs);
|
||||
if (code != 0) {
|
||||
mError("trans:%d, failed to execute commit logs since %s", pTrans->id, terrstr())
|
||||
} else {
|
||||
mDebug("trans:%d, execute commit logs finished", pTrans->id)
|
||||
}
|
||||
}
|
||||
|
||||
return code;
|
||||
return mndTransExecuteLogs(pMnode, pTrans->commitLogs);
|
||||
}
|
||||
|
||||
static int32_t mndTransExecuteActions(SMnode *pMnode, STrans *pTrans, SArray *pArray) {
|
||||
|
@ -719,25 +686,25 @@ static int32_t mndTransExecuteActions(SMnode *pMnode, STrans *pTrans, SArray *pA
|
|||
mndSendMsgToDnode(pMnode, &pAction->epSet, &rpcMsg);
|
||||
}
|
||||
|
||||
int32_t numOfReceivedMsgs = 0;
|
||||
int32_t errorCode = 0;
|
||||
int32_t numOfReceived = 0;
|
||||
int32_t errCode = 0;
|
||||
for (int32_t action = 0; action < numOfActions; ++action) {
|
||||
STransAction *pAction = taosArrayGet(pArray, action);
|
||||
if (pAction == NULL) continue;
|
||||
if (pAction->msgSent && pAction->msgReceived) {
|
||||
numOfReceivedMsgs++;
|
||||
numOfReceived++;
|
||||
if (pAction->errCode != 0) {
|
||||
errorCode = pAction->errCode;
|
||||
errCode = pAction->errCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (numOfReceivedMsgs == numOfActions) {
|
||||
mDebug("trans:%d, all %d actions executed, code:0x%x", pTrans->id, numOfActions, errorCode);
|
||||
terrno = errorCode;
|
||||
return errorCode;
|
||||
if (numOfReceived == numOfActions) {
|
||||
mDebug("trans:%d, all %d actions executed, code:0x%x", pTrans->id, numOfActions, errCode);
|
||||
terrno = errCode;
|
||||
return errCode;
|
||||
} else {
|
||||
mDebug("trans:%d, %d of %d actions executed, code:0x%x", pTrans->id, numOfReceivedMsgs, numOfActions, errorCode);
|
||||
mDebug("trans:%d, %d of %d actions executed, code:0x%x", pTrans->id, numOfReceived, numOfActions, errCode);
|
||||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue