enh: refactor return code
This commit is contained in:
parent
a2579d5970
commit
1cf7744c74
|
@ -238,7 +238,7 @@ const char* columnLevelStr(uint8_t type) {
|
||||||
|
|
||||||
bool checkColumnEncode(char encode[TSDB_CL_COMPRESS_OPTION_LEN]) {
|
bool checkColumnEncode(char encode[TSDB_CL_COMPRESS_OPTION_LEN]) {
|
||||||
if (0 == strlen(encode)) return true;
|
if (0 == strlen(encode)) return true;
|
||||||
strtolower(encode, encode);
|
(void)strtolower(encode, encode);
|
||||||
for (int i = 0; i < supportedEncodeNum; ++i) {
|
for (int i = 0; i < supportedEncodeNum; ++i) {
|
||||||
if (0 == strcmp((const char*)encode, supportedEncode[i])) {
|
if (0 == strcmp((const char*)encode, supportedEncode[i])) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -255,7 +255,7 @@ bool checkColumnEncodeOrSetDefault(uint8_t type, char encode[TSDB_CL_COMPRESS_OP
|
||||||
}
|
}
|
||||||
bool checkColumnCompress(char compress[TSDB_CL_COMPRESS_OPTION_LEN]) {
|
bool checkColumnCompress(char compress[TSDB_CL_COMPRESS_OPTION_LEN]) {
|
||||||
if (0 == strlen(compress)) return true;
|
if (0 == strlen(compress)) return true;
|
||||||
strtolower(compress, compress);
|
(void)strtolower(compress, compress);
|
||||||
for (int i = 0; i < supportedCompressNum; ++i) {
|
for (int i = 0; i < supportedCompressNum; ++i) {
|
||||||
if (0 == strcmp((const char*)compress, supportedCompress[i])) {
|
if (0 == strcmp((const char*)compress, supportedCompress[i])) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -273,7 +273,7 @@ bool checkColumnCompressOrSetDefault(uint8_t type, char compress[TSDB_CL_COMPRES
|
||||||
}
|
}
|
||||||
bool checkColumnLevel(char level[TSDB_CL_COMPRESS_OPTION_LEN]) {
|
bool checkColumnLevel(char level[TSDB_CL_COMPRESS_OPTION_LEN]) {
|
||||||
if (0 == strlen(level)) return true;
|
if (0 == strlen(level)) return true;
|
||||||
strtolower(level, level);
|
(void)strtolower(level, level);
|
||||||
if (1 == strlen(level)) {
|
if (1 == strlen(level)) {
|
||||||
if ('h' == level[0] || 'm' == level[0] || 'l' == level[0]) return true;
|
if ('h' == level[0] || 'm' == level[0] || 'l' == level[0]) return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -68,7 +68,7 @@ bool tdSTSRowIterFetch(STSRowIter *pIter, col_id_t colId, col_type_t colType, SC
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tdSTSRowIterGetTpVal(pIter, pCol->type, pCol->offset, pVal);
|
(void)tdSTSRowIterGetTpVal(pIter, pCol->type, pCol->offset, pVal);
|
||||||
++pIter->colIdx;
|
++pIter->colIdx;
|
||||||
} else if (TD_IS_KV_ROW(pIter->pRow)) {
|
} else if (TD_IS_KV_ROW(pIter->pRow)) {
|
||||||
return tdSTSRowIterGetKvVal(pIter, colId, &pIter->kvIdx, pVal);
|
return tdSTSRowIterGetKvVal(pIter, colId, &pIter->kvIdx, pVal);
|
||||||
|
|
|
@ -134,7 +134,7 @@ int32_t syncLogReplGetPrevLogTerm(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncI
|
||||||
}
|
}
|
||||||
|
|
||||||
SSnapshot snapshot = {0};
|
SSnapshot snapshot = {0};
|
||||||
(void)pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot); // TODO: check the return code
|
(void)pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot);
|
||||||
if (prevIndex == snapshot.lastApplyIndex) {
|
if (prevIndex == snapshot.lastApplyIndex) {
|
||||||
*pSyncTerm = snapshot.lastApplyTerm;
|
*pSyncTerm = snapshot.lastApplyTerm;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -184,7 +184,7 @@ int32_t syncLogBufferInitWithoutLock(SSyncLogBuffer* pBuf, SSyncNode* pNode) {
|
||||||
|
|
||||||
int32_t code = 0, lino = 0;
|
int32_t code = 0, lino = 0;
|
||||||
SSnapshot snapshot = {0};
|
SSnapshot snapshot = {0};
|
||||||
pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot);
|
TAOS_CHECK_EXIT(pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot));
|
||||||
|
|
||||||
SyncIndex commitIndex = snapshot.lastApplyIndex;
|
SyncIndex commitIndex = snapshot.lastApplyIndex;
|
||||||
SyncTerm commitTerm = TMAX(snapshot.lastApplyTerm, 0);
|
SyncTerm commitTerm = TMAX(snapshot.lastApplyTerm, 0);
|
||||||
|
|
|
@ -86,14 +86,17 @@ int32_t snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaIndex, SSyncSn
|
||||||
pSender->replicaIndex = replicaIndex;
|
pSender->replicaIndex = replicaIndex;
|
||||||
pSender->term = raftStoreGetTerm(pSyncNode);
|
pSender->term = raftStoreGetTerm(pSyncNode);
|
||||||
pSender->startTime = -1;
|
pSender->startTime = -1;
|
||||||
pSender->pSyncNode->pFsm->FpGetSnapshotInfo(pSender->pSyncNode->pFsm, &pSender->snapshot);
|
|
||||||
pSender->finish = false;
|
pSender->finish = false;
|
||||||
|
|
||||||
|
code = pSender->pSyncNode->pFsm->FpGetSnapshotInfo(pSender->pSyncNode->pFsm, &pSender->snapshot);
|
||||||
|
if (code != 0) {
|
||||||
|
taosMemoryFreeClear(pSender);
|
||||||
|
TAOS_RETURN(code);
|
||||||
|
}
|
||||||
SSyncSnapBuffer *pSndBuf = NULL;
|
SSyncSnapBuffer *pSndBuf = NULL;
|
||||||
code = syncSnapBufferCreate(&pSndBuf);
|
code = syncSnapBufferCreate(&pSndBuf);
|
||||||
if (pSndBuf == NULL) {
|
if (pSndBuf == NULL) {
|
||||||
taosMemoryFree(pSender);
|
taosMemoryFreeClear(pSender);
|
||||||
pSender = NULL;
|
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
pSndBuf->entryDeleteCb = syncSnapBlockDestroy;
|
pSndBuf->entryDeleteCb = syncSnapBlockDestroy;
|
||||||
|
@ -472,7 +475,7 @@ void snapshotReceiverDestroy(SSyncSnapshotReceiver *pReceiver) {
|
||||||
syncSnapBufferDestroy(&pReceiver->pRcvBuf);
|
syncSnapBufferDestroy(&pReceiver->pRcvBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
snapshotReceiverClearInfoData(pReceiver);
|
(void)snapshotReceiverClearInfoData(pReceiver);
|
||||||
|
|
||||||
// free receiver
|
// free receiver
|
||||||
taosMemoryFree(pReceiver);
|
taosMemoryFree(pReceiver);
|
||||||
|
@ -592,7 +595,7 @@ static int32_t snapshotReceiverFinish(SSyncSnapshotReceiver *pReceiver, SyncSnap
|
||||||
code = pReceiver->pSyncNode->pFsm->FpSnapshotStopWrite(pReceiver->pSyncNode->pFsm, pReceiver->pWriter, true,
|
code = pReceiver->pSyncNode->pFsm->FpSnapshotStopWrite(pReceiver->pSyncNode->pFsm, pReceiver->pWriter, true,
|
||||||
&pReceiver->snapshot);
|
&pReceiver->snapshot);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
sRError(pReceiver, "snapshot receiver apply failed since %s", tstrerror(code));
|
sRError(pReceiver, "snapshot receiver apply failed since %s", tstrerror(code));
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
pReceiver->pWriter = NULL;
|
pReceiver->pWriter = NULL;
|
||||||
|
@ -603,7 +606,11 @@ static int32_t snapshotReceiverFinish(SSyncSnapshotReceiver *pReceiver, SyncSnap
|
||||||
|
|
||||||
// get fsmState
|
// get fsmState
|
||||||
SSnapshot snapshot = {0};
|
SSnapshot snapshot = {0};
|
||||||
pReceiver->pSyncNode->pFsm->FpGetSnapshotInfo(pReceiver->pSyncNode->pFsm, &snapshot);
|
code = pReceiver->pSyncNode->pFsm->FpGetSnapshotInfo(pReceiver->pSyncNode->pFsm, &snapshot);
|
||||||
|
if (code != 0) {
|
||||||
|
sRError(pReceiver, "snapshot receiver get snapshot info failed since %s", tstrerror(code));
|
||||||
|
TAOS_RETURN(code);
|
||||||
|
}
|
||||||
pReceiver->pSyncNode->fsmState = snapshot.state;
|
pReceiver->pSyncNode->fsmState = snapshot.state;
|
||||||
|
|
||||||
// reset wal
|
// reset wal
|
||||||
|
@ -1276,13 +1283,13 @@ int32_t syncNodeOnSnapshotRsp(SSyncNode *pSyncNode, SRpcMsg *pRpcMsg) {
|
||||||
if (pMsg->ack == SYNC_SNAPSHOT_SEQ_END) {
|
if (pMsg->ack == SYNC_SNAPSHOT_SEQ_END) {
|
||||||
sSInfo(pSender, "process end rsp");
|
sSInfo(pSender, "process end rsp");
|
||||||
snapshotSenderStop(pSender, true);
|
snapshotSenderStop(pSender, true);
|
||||||
syncNodeReplicateReset(pSyncNode, &pMsg->srcId);
|
(void)syncNodeReplicateReset(pSyncNode, &pMsg->srcId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
_ERROR:
|
_ERROR:
|
||||||
snapshotSenderStop(pSender, false);
|
snapshotSenderStop(pSender, false);
|
||||||
syncNodeReplicateReset(pSyncNode, &pMsg->srcId);
|
(void)syncNodeReplicateReset(pSyncNode, &pMsg->srcId);
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,7 +183,7 @@ void syncPrintNodeLog(const char* flags, ELogLevel level, int32_t dflag, SSyncNo
|
||||||
|
|
||||||
SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0};
|
SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0};
|
||||||
if (pNode->pFsm != NULL && pNode->pFsm->FpGetSnapshotInfo != NULL) {
|
if (pNode->pFsm != NULL && pNode->pFsm->FpGetSnapshotInfo != NULL) {
|
||||||
pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot);
|
(void)pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot);
|
||||||
}
|
}
|
||||||
|
|
||||||
SyncIndex logLastIndex = SYNC_INDEX_INVALID;
|
SyncIndex logLastIndex = SYNC_INDEX_INVALID;
|
||||||
|
@ -253,7 +253,7 @@ void syncPrintSnapshotSenderLog(const char* flags, ELogLevel level, int32_t dfla
|
||||||
|
|
||||||
SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0};
|
SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0};
|
||||||
if (pNode->pFsm != NULL && pNode->pFsm->FpGetSnapshotInfo != NULL) {
|
if (pNode->pFsm != NULL && pNode->pFsm->FpGetSnapshotInfo != NULL) {
|
||||||
pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot);
|
(void)pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot);
|
||||||
}
|
}
|
||||||
|
|
||||||
SyncIndex logLastIndex = SYNC_INDEX_INVALID;
|
SyncIndex logLastIndex = SYNC_INDEX_INVALID;
|
||||||
|
@ -302,7 +302,7 @@ void syncPrintSnapshotReceiverLog(const char* flags, ELogLevel level, int32_t df
|
||||||
|
|
||||||
SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0};
|
SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0};
|
||||||
if (pNode->pFsm != NULL && pNode->pFsm->FpGetSnapshotInfo != NULL) {
|
if (pNode->pFsm != NULL && pNode->pFsm->FpGetSnapshotInfo != NULL) {
|
||||||
pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot);
|
(void)pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot);
|
||||||
}
|
}
|
||||||
|
|
||||||
SyncIndex logLastIndex = SYNC_INDEX_INVALID;
|
SyncIndex logLastIndex = SYNC_INDEX_INVALID;
|
||||||
|
|
|
@ -483,7 +483,7 @@ const STfsFile *tfsReaddir(STfsDir *pTfsDir) {
|
||||||
void tfsClosedir(STfsDir *pTfsDir) {
|
void tfsClosedir(STfsDir *pTfsDir) {
|
||||||
if (pTfsDir) {
|
if (pTfsDir) {
|
||||||
if (pTfsDir->pDir != NULL) {
|
if (pTfsDir->pDir != NULL) {
|
||||||
taosCloseDir(&pTfsDir->pDir);
|
(void)taosCloseDir(&pTfsDir->pDir);
|
||||||
pTfsDir->pDir = NULL;
|
pTfsDir->pDir = NULL;
|
||||||
}
|
}
|
||||||
taosMemoryFree(pTfsDir);
|
taosMemoryFree(pTfsDir);
|
||||||
|
|
Loading…
Reference in New Issue