Merge branch '3.0' of https://github.com/taosdata/TDengine into enh/TD-30987-22
This commit is contained in:
commit
16153022a5
|
@ -1075,10 +1075,10 @@ typedef struct {
|
|||
SUpdateUserIpWhite* pUserIpWhite;
|
||||
} SUpdateIpWhite;
|
||||
|
||||
int32_t tSerializeSUpdateIpWhite(void* buf, int32_t bufLen, SUpdateIpWhite* pReq);
|
||||
int32_t tDeserializeSUpdateIpWhite(void* buf, int32_t bufLen, SUpdateIpWhite* pReq);
|
||||
void tFreeSUpdateIpWhiteReq(SUpdateIpWhite* pReq);
|
||||
SUpdateIpWhite* cloneSUpdateIpWhiteReq(SUpdateIpWhite* pReq);
|
||||
int32_t tSerializeSUpdateIpWhite(void* buf, int32_t bufLen, SUpdateIpWhite* pReq);
|
||||
int32_t tDeserializeSUpdateIpWhite(void* buf, int32_t bufLen, SUpdateIpWhite* pReq);
|
||||
void tFreeSUpdateIpWhiteReq(SUpdateIpWhite* pReq);
|
||||
int32_t cloneSUpdateIpWhiteReq(SUpdateIpWhite* pReq, SUpdateIpWhite** pUpdate);
|
||||
|
||||
typedef struct {
|
||||
int64_t ipWhiteVer;
|
||||
|
@ -3639,9 +3639,9 @@ static FORCE_INLINE void tqOffsetResetToLog(STqOffsetVal* pOffsetVal, int64_t ve
|
|||
|
||||
int32_t tEncodeSTqOffsetVal(SEncoder* pEncoder, const STqOffsetVal* pOffsetVal);
|
||||
int32_t tDecodeSTqOffsetVal(SDecoder* pDecoder, STqOffsetVal* pOffsetVal);
|
||||
int32_t tFormatOffset(char* buf, int32_t maxLen, const STqOffsetVal* pVal);
|
||||
void tFormatOffset(char* buf, int32_t maxLen, const STqOffsetVal* pVal);
|
||||
bool tOffsetEqual(const STqOffsetVal* pLeft, const STqOffsetVal* pRight);
|
||||
int32_t tOffsetCopy(STqOffsetVal* pLeft, const STqOffsetVal* pRight);
|
||||
void tOffsetCopy(STqOffsetVal* pLeft, const STqOffsetVal* pRight);
|
||||
void tOffsetDestroy(void* pVal);
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -164,13 +164,13 @@ int rpcRegisterBrokenLinkArg(SRpcMsg *msg);
|
|||
int rpcReleaseHandle(void *handle, int8_t type); // just release conn to rpc instance, no close sock
|
||||
|
||||
// These functions will not be called in the child process
|
||||
int rpcSendRequestWithCtx(void *thandle, const SEpSet *pEpSet, SRpcMsg *pMsg, int64_t *rid, SRpcCtx *ctx);
|
||||
int rpcSendRecv(void *shandle, SEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp);
|
||||
int rpcSendRecvWithTimeout(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp, int8_t *epUpdated,
|
||||
int32_t timeoutMs);
|
||||
int rpcSetDefaultAddr(void *thandle, const char *ip, const char *fqdn);
|
||||
void *rpcAllocHandle();
|
||||
void rpcSetIpWhite(void *thandl, void *arg);
|
||||
int rpcSendRequestWithCtx(void *thandle, const SEpSet *pEpSet, SRpcMsg *pMsg, int64_t *rid, SRpcCtx *ctx);
|
||||
int rpcSendRecv(void *shandle, SEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp);
|
||||
int rpcSendRecvWithTimeout(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp, int8_t *epUpdated,
|
||||
int32_t timeoutMs);
|
||||
int rpcSetDefaultAddr(void *thandle, const char *ip, const char *fqdn);
|
||||
void *rpcAllocHandle();
|
||||
int32_t rpcSetIpWhite(void *thandl, void *arg);
|
||||
|
||||
int32_t rpcUtilSIpRangeToStr(SIpV4Range *pRange, char *buf);
|
||||
|
||||
|
|
|
@ -90,6 +90,8 @@ int32_t taosGetErrSize();
|
|||
#define TSDB_CODE_RPC_NETWORK_ERROR TAOS_DEF_ERROR_CODE(0, 0x0023)
|
||||
#define TSDB_CODE_RPC_NETWORK_BUSY TAOS_DEF_ERROR_CODE(0, 0x0024)
|
||||
#define TSDB_CODE_HTTP_MODULE_QUIT TAOS_DEF_ERROR_CODE(0, 0x0025)
|
||||
#define TSDB_CODE_RPC_MODULE_QUIT TAOS_DEF_ERROR_CODE(0, 0x0026)
|
||||
#define TSDB_CODE_RPC_ASYNC_MODULE_QUIT TAOS_DEF_ERROR_CODE(0, 0x0027)
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ static FORCE_INLINE int32_t tarray2SortInsert(void *arr, const void *elePtr, int
|
|||
if ((cb) && (a)->size > 0) { \
|
||||
TArray2Cb cb_ = (TArray2Cb)(cb); \
|
||||
for (int32_t i = 0; i < (a)->size; ++i) { \
|
||||
cb_((a)->data + i); \
|
||||
(void)cb_((a)->data + i); \
|
||||
} \
|
||||
} \
|
||||
(a)->size = 0; \
|
||||
|
|
|
@ -1764,23 +1764,33 @@ int32_t tDeserializeSUpdateIpWhite(void *buf, int32_t bufLen, SUpdateIpWhite *pR
|
|||
return 0;
|
||||
}
|
||||
void tFreeSUpdateIpWhiteReq(SUpdateIpWhite *pReq) {
|
||||
for (int i = 0; i < pReq->numOfUser; i++) {
|
||||
SUpdateUserIpWhite *pUserWhite = &pReq->pUserIpWhite[i];
|
||||
taosMemoryFree(pUserWhite->pIpRanges);
|
||||
if (pReq == NULL) return;
|
||||
|
||||
if (pReq->pUserIpWhite) {
|
||||
for (int i = 0; i < pReq->numOfUser; i++) {
|
||||
SUpdateUserIpWhite *pUserWhite = &pReq->pUserIpWhite[i];
|
||||
taosMemoryFree(pUserWhite->pIpRanges);
|
||||
}
|
||||
}
|
||||
taosMemoryFree(pReq->pUserIpWhite);
|
||||
// impl later
|
||||
return;
|
||||
}
|
||||
SUpdateIpWhite *cloneSUpdateIpWhiteReq(SUpdateIpWhite *pReq) {
|
||||
int32_t cloneSUpdateIpWhiteReq(SUpdateIpWhite *pReq, SUpdateIpWhite **pUpdateMsg) {
|
||||
int32_t code = 0;
|
||||
if (pReq == NULL) {
|
||||
return 0;
|
||||
}
|
||||
SUpdateIpWhite *pClone = taosMemoryCalloc(1, sizeof(SUpdateIpWhite));
|
||||
if (pClone == NULL) return NULL;
|
||||
if (pClone == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
pClone->numOfUser = pReq->numOfUser;
|
||||
pClone->ver = pReq->ver;
|
||||
if ((pClone->pUserIpWhite = taosMemoryCalloc(1, sizeof(SUpdateUserIpWhite) * pReq->numOfUser)) == NULL) {
|
||||
pClone->pUserIpWhite = taosMemoryCalloc(1, sizeof(SUpdateUserIpWhite) * pReq->numOfUser);
|
||||
if (pClone->pUserIpWhite == NULL) {
|
||||
taosMemoryFree(pClone);
|
||||
return NULL;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
for (int i = 0; i < pReq->numOfUser; i++) {
|
||||
|
@ -1792,17 +1802,21 @@ SUpdateIpWhite *cloneSUpdateIpWhiteReq(SUpdateIpWhite *pReq) {
|
|||
pNew->numOfRange = pOld->numOfRange;
|
||||
|
||||
int32_t sz = pOld->numOfRange * sizeof(SIpV4Range);
|
||||
if ((pNew->pIpRanges = taosMemoryCalloc(1, sz)) == NULL) {
|
||||
for (int j = 0; j < i; j++) {
|
||||
taosMemoryFree(pClone->pUserIpWhite[j].pIpRanges);
|
||||
}
|
||||
taosMemoryFree(pClone->pUserIpWhite);
|
||||
taosMemoryFree(pClone);
|
||||
return NULL;
|
||||
pNew->pIpRanges = taosMemoryCalloc(1, sz);
|
||||
if (pNew->pIpRanges == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
break;
|
||||
}
|
||||
memcpy(pNew->pIpRanges, pOld->pIpRanges, sz);
|
||||
}
|
||||
return pClone;
|
||||
_return:
|
||||
if (code < 0) {
|
||||
tFreeSUpdateIpWhiteReq(pClone);
|
||||
taosMemoryFree(pClone);
|
||||
} else {
|
||||
*pUpdateMsg = pClone;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
int32_t tSerializeRetrieveIpWhite(void *buf, int32_t bufLen, SRetrieveIpWhiteReq *pReq) {
|
||||
SEncoder encoder = {0};
|
||||
|
@ -7342,6 +7356,7 @@ int32_t tSerializeSMqPollReq(void *buf, int32_t bufLen, SMqPollReq *pReq) {
|
|||
if (tEncodeSTqOffsetVal(&encoder, &pReq->reqOffset) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->enableReplay) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->sourceExcluded) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->enableBatchMeta) < 0) return -1;
|
||||
|
||||
tEndEncode(&encoder);
|
||||
|
||||
|
@ -7353,7 +7368,6 @@ int32_t tSerializeSMqPollReq(void *buf, int32_t bufLen, SMqPollReq *pReq) {
|
|||
pHead->vgId = htonl(pReq->head.vgId);
|
||||
pHead->contLen = htonl(tlen + headLen);
|
||||
}
|
||||
if (tEncodeI8(&encoder, pReq->enableBatchMeta) < 0) return -1;
|
||||
|
||||
return tlen + headLen;
|
||||
}
|
||||
|
@ -9180,7 +9194,7 @@ int32_t tDecodeSTqOffsetVal(SDecoder *pDecoder, STqOffsetVal *pOffsetVal) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t tFormatOffset(char *buf, int32_t maxLen, const STqOffsetVal *pVal) {
|
||||
void tFormatOffset(char *buf, int32_t maxLen, const STqOffsetVal *pVal) {
|
||||
if (pVal->type == TMQ_OFFSET__RESET_NONE) {
|
||||
(void)snprintf(buf, maxLen, "none");
|
||||
} else if (pVal->type == TMQ_OFFSET__RESET_EARLIEST) {
|
||||
|
@ -9192,7 +9206,7 @@ int32_t tFormatOffset(char *buf, int32_t maxLen, const STqOffsetVal *pVal) {
|
|||
} else if (pVal->type == TMQ_OFFSET__SNAPSHOT_DATA || pVal->type == TMQ_OFFSET__SNAPSHOT_META) {
|
||||
if (IS_VAR_DATA_TYPE(pVal->primaryKey.type)) {
|
||||
char *tmp = taosMemoryCalloc(1, pVal->primaryKey.nData + 1);
|
||||
if (tmp == NULL) return terrno;
|
||||
if (tmp == NULL) return;
|
||||
(void)memcpy(tmp, pVal->primaryKey.pData, pVal->primaryKey.nData);
|
||||
(void)snprintf(buf, maxLen, "tsdb:%" PRId64 "|%" PRId64 ",pk type:%d,val:%s", pVal->uid, pVal->ts,
|
||||
pVal->primaryKey.type, tmp);
|
||||
|
@ -9202,8 +9216,6 @@ int32_t tFormatOffset(char *buf, int32_t maxLen, const STqOffsetVal *pVal) {
|
|||
pVal->primaryKey.type, pVal->primaryKey.val);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool tOffsetEqual(const STqOffsetVal *pLeft, const STqOffsetVal *pRight) {
|
||||
|
@ -9226,16 +9238,17 @@ bool tOffsetEqual(const STqOffsetVal *pLeft, const STqOffsetVal *pRight) {
|
|||
return false;
|
||||
}
|
||||
|
||||
int32_t tOffsetCopy(STqOffsetVal *pLeft, const STqOffsetVal *pRight) {
|
||||
void tOffsetCopy(STqOffsetVal *pLeft, const STqOffsetVal *pRight) {
|
||||
tOffsetDestroy(pLeft);
|
||||
*pLeft = *pRight;
|
||||
if (IS_VAR_DATA_TYPE(pRight->primaryKey.type)) {
|
||||
if ((pLeft->primaryKey.pData = taosMemoryMalloc(pRight->primaryKey.nData)) == NULL) {
|
||||
return terrno;
|
||||
pLeft->primaryKey.pData = taosMemoryMalloc(pRight->primaryKey.nData);
|
||||
if (pLeft->primaryKey.pData == NULL) {
|
||||
uError("failed to allocate memory for offset");
|
||||
return;
|
||||
}
|
||||
(void)memcpy(pLeft->primaryKey.pData, pRight->primaryKey.pData, pRight->primaryKey.nData);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void tOffsetDestroy(void *param) {
|
||||
|
|
|
@ -65,10 +65,11 @@ static int32_t dmConvertErrCode(tmsg_t msgType, int32_t code) {
|
|||
return code;
|
||||
}
|
||||
static void dmUpdateRpcIpWhite(SDnodeData *pData, void *pTrans, SRpcMsg *pRpc) {
|
||||
int32_t code = 0;
|
||||
SUpdateIpWhite ipWhite = {0}; // aosMemoryCalloc(1, sizeof(SUpdateIpWhite));
|
||||
tDeserializeSUpdateIpWhite(pRpc->pCont, pRpc->contLen, &ipWhite);
|
||||
|
||||
rpcSetIpWhite(pTrans, &ipWhite);
|
||||
code = rpcSetIpWhite(pTrans, &ipWhite);
|
||||
pData->ipWhiteVer = ipWhite.ver;
|
||||
|
||||
tFreeSUpdateIpWhiteReq(&ipWhite);
|
||||
|
|
|
@ -70,16 +70,16 @@ static void mndBuildRuntimeInfo(SMnode* pMnode, SJson* pJson) {
|
|||
SMnodeStat mstat = {0};
|
||||
mndGetStat(pMnode, &mstat);
|
||||
|
||||
tjsonAddDoubleToObject(pJson, "numOfDnode", mstat.numOfDnode);
|
||||
tjsonAddDoubleToObject(pJson, "numOfMnode", mstat.numOfMnode);
|
||||
tjsonAddDoubleToObject(pJson, "numOfVgroup", mstat.numOfVgroup);
|
||||
tjsonAddDoubleToObject(pJson, "numOfDatabase", mstat.numOfDatabase);
|
||||
tjsonAddDoubleToObject(pJson, "numOfSuperTable", mstat.numOfSuperTable);
|
||||
tjsonAddDoubleToObject(pJson, "numOfChildTable", mstat.numOfChildTable);
|
||||
tjsonAddDoubleToObject(pJson, "numOfColumn", mstat.numOfColumn);
|
||||
tjsonAddDoubleToObject(pJson, "numOfPoint", mstat.totalPoints);
|
||||
tjsonAddDoubleToObject(pJson, "totalStorage", mstat.totalStorage);
|
||||
tjsonAddDoubleToObject(pJson, "compStorage", mstat.compStorage);
|
||||
(void)tjsonAddDoubleToObject(pJson, "numOfDnode", mstat.numOfDnode);
|
||||
(void)tjsonAddDoubleToObject(pJson, "numOfMnode", mstat.numOfMnode);
|
||||
(void)tjsonAddDoubleToObject(pJson, "numOfVgroup", mstat.numOfVgroup);
|
||||
(void)tjsonAddDoubleToObject(pJson, "numOfDatabase", mstat.numOfDatabase);
|
||||
(void)tjsonAddDoubleToObject(pJson, "numOfSuperTable", mstat.numOfSuperTable);
|
||||
(void)tjsonAddDoubleToObject(pJson, "numOfChildTable", mstat.numOfChildTable);
|
||||
(void)tjsonAddDoubleToObject(pJson, "numOfColumn", mstat.numOfColumn);
|
||||
(void)tjsonAddDoubleToObject(pJson, "numOfPoint", mstat.totalPoints);
|
||||
(void)tjsonAddDoubleToObject(pJson, "totalStorage", mstat.totalStorage);
|
||||
(void)tjsonAddDoubleToObject(pJson, "compStorage", mstat.compStorage);
|
||||
}
|
||||
|
||||
static char* mndBuildTelemetryReport(SMnode* pMnode) {
|
||||
|
@ -90,29 +90,29 @@ static char* mndBuildTelemetryReport(SMnode* pMnode) {
|
|||
if (pJson == NULL) return NULL;
|
||||
|
||||
char clusterName[64] = {0};
|
||||
mndGetClusterName(pMnode, clusterName, sizeof(clusterName));
|
||||
tjsonAddStringToObject(pJson, "instanceId", clusterName);
|
||||
tjsonAddDoubleToObject(pJson, "reportVersion", 1);
|
||||
if ((terrno = mndGetClusterName(pMnode, clusterName, sizeof(clusterName))) != 0) return NULL;
|
||||
(void)tjsonAddStringToObject(pJson, "instanceId", clusterName);
|
||||
(void)tjsonAddDoubleToObject(pJson, "reportVersion", 1);
|
||||
|
||||
if (taosGetOsReleaseName(tmp, NULL, NULL, sizeof(tmp)) == 0) {
|
||||
tjsonAddStringToObject(pJson, "os", tmp);
|
||||
(void)tjsonAddStringToObject(pJson, "os", tmp);
|
||||
}
|
||||
|
||||
float numOfCores = 0;
|
||||
if (taosGetCpuInfo(tmp, sizeof(tmp), &numOfCores) == 0) {
|
||||
tjsonAddStringToObject(pJson, "cpuModel", tmp);
|
||||
tjsonAddDoubleToObject(pJson, "numOfCpu", numOfCores);
|
||||
(void)tjsonAddStringToObject(pJson, "cpuModel", tmp);
|
||||
(void)tjsonAddDoubleToObject(pJson, "numOfCpu", numOfCores);
|
||||
} else {
|
||||
tjsonAddDoubleToObject(pJson, "numOfCpu", tsNumOfCores);
|
||||
(void)tjsonAddDoubleToObject(pJson, "numOfCpu", tsNumOfCores);
|
||||
}
|
||||
|
||||
snprintf(tmp, sizeof(tmp), "%" PRId64 " kB", tsTotalMemoryKB);
|
||||
tjsonAddStringToObject(pJson, "memory", tmp);
|
||||
(void)tjsonAddStringToObject(pJson, "memory", tmp);
|
||||
|
||||
tjsonAddStringToObject(pJson, "version", version);
|
||||
tjsonAddStringToObject(pJson, "buildInfo", buildinfo);
|
||||
tjsonAddStringToObject(pJson, "gitInfo", gitinfo);
|
||||
tjsonAddStringToObject(pJson, "email", pMgmt->email);
|
||||
(void)tjsonAddStringToObject(pJson, "version", version);
|
||||
(void)tjsonAddStringToObject(pJson, "buildInfo", buildinfo);
|
||||
(void)tjsonAddStringToObject(pJson, "gitInfo", gitinfo);
|
||||
(void)tjsonAddStringToObject(pJson, "email", pMgmt->email);
|
||||
|
||||
mndBuildRuntimeInfo(pMnode, pJson);
|
||||
|
||||
|
@ -126,9 +126,9 @@ static int32_t mndProcessTelemTimer(SRpcMsg* pReq) {
|
|||
STelemMgmt* pMgmt = &pMnode->telemMgmt;
|
||||
if (!tsEnableTelem) return 0;
|
||||
|
||||
taosThreadMutexLock(&pMgmt->lock);
|
||||
(void)taosThreadMutexLock(&pMgmt->lock);
|
||||
char* pCont = mndBuildTelemetryReport(pMnode);
|
||||
taosThreadMutexUnlock(&pMgmt->lock);
|
||||
(void)taosThreadMutexUnlock(&pMgmt->lock);
|
||||
|
||||
if (pCont != NULL) {
|
||||
if (taosSendHttpReport(tsTelemServer, tsTelemUri, tsTelemPort, pCont, strlen(pCont), HTTP_FLAT) != 0) {
|
||||
|
@ -142,10 +142,12 @@ static int32_t mndProcessTelemTimer(SRpcMsg* pReq) {
|
|||
}
|
||||
|
||||
int32_t mndInitTelem(SMnode* pMnode) {
|
||||
int32_t code = 0;
|
||||
STelemMgmt* pMgmt = &pMnode->telemMgmt;
|
||||
|
||||
taosThreadMutexInit(&pMgmt->lock, NULL);
|
||||
taosGetEmail(pMgmt->email, sizeof(pMgmt->email));
|
||||
(void)taosThreadMutexInit(&pMgmt->lock, NULL);
|
||||
if ((code = taosGetEmail(pMgmt->email, sizeof(pMgmt->email))) != 0)
|
||||
mWarn("failed to get email since %s", tstrerror(code));
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_TELEM_TIMER, mndProcessTelemTimer);
|
||||
|
||||
return 0;
|
||||
|
@ -153,5 +155,5 @@ int32_t mndInitTelem(SMnode* pMnode) {
|
|||
|
||||
void mndCleanupTelem(SMnode* pMnode) {
|
||||
STelemMgmt* pMgmt = &pMnode->telemMgmt;
|
||||
taosThreadMutexDestroy(&pMgmt->lock);
|
||||
(void)taosThreadMutexDestroy(&pMgmt->lock);
|
||||
}
|
||||
|
|
|
@ -376,7 +376,7 @@ SSdbRow *mndTransDecode(SSdbRaw *pRaw) {
|
|||
for (int32_t i = 0; i < arbgroupIdNum; ++i) {
|
||||
int32_t arbGroupId = 0;
|
||||
SDB_GET_INT32(pRaw, dataPos, &arbGroupId, _OVER)
|
||||
taosHashPut(pTrans->arbGroupIds, &arbGroupId, sizeof(int32_t), NULL, 0);
|
||||
if ((terrno = taosHashPut(pTrans->arbGroupIds, &arbGroupId, sizeof(int32_t), NULL, 0)) != 0) goto _OVER;
|
||||
}
|
||||
|
||||
SDB_GET_RESERVE(pRaw, dataPos, TRANS_RESERVE_SIZE, _OVER)
|
||||
|
@ -461,7 +461,7 @@ static int32_t mndTransActionInsert(SSdb *pSdb, STrans *pTrans) {
|
|||
mInfo("trans:%d, perform insert action, row:%p stage:%s, callfunc:1, startFunc:%d", pTrans->id, pTrans,
|
||||
mndTransStr(pTrans->stage), pTrans->startFunc);
|
||||
|
||||
taosThreadMutexInit(&pTrans->mutex, NULL);
|
||||
(void)taosThreadMutexInit(&pTrans->mutex, NULL);
|
||||
|
||||
if (pTrans->startFunc > 0) {
|
||||
TransCbFp fp = mndTransGetCbFp(pTrans->startFunc);
|
||||
|
@ -616,7 +616,7 @@ STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, ETrnConflct conflict,
|
|||
pTrans->pRpcArray = taosArrayInit(1, sizeof(SRpcHandleInfo));
|
||||
pTrans->mTraceId = pReq ? TRACE_GET_ROOTID(&pReq->info.traceId) : tGenIdPI64();
|
||||
taosInitRWLatch(&pTrans->lockRpcArray);
|
||||
taosThreadMutexInit(&pTrans->mutex, NULL);
|
||||
(void)taosThreadMutexInit(&pTrans->mutex, NULL);
|
||||
|
||||
if (pTrans->redoActions == NULL || pTrans->undoActions == NULL || pTrans->commitActions == NULL ||
|
||||
pTrans->pRpcArray == NULL) {
|
||||
|
@ -627,7 +627,10 @@ STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, ETrnConflct conflict,
|
|||
}
|
||||
|
||||
if (pReq != NULL) {
|
||||
taosArrayPush(pTrans->pRpcArray, &pReq->info);
|
||||
if (taosArrayPush(pTrans->pRpcArray, &pReq->info) == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
pTrans->originRpcType = pReq->msgType;
|
||||
}
|
||||
|
||||
|
@ -765,7 +768,7 @@ void mndTransSetDbName(STrans *pTrans, const char *dbname, const char *stbname)
|
|||
}
|
||||
|
||||
void mndTransAddArbGroupId(STrans *pTrans, int32_t groupId) {
|
||||
taosHashPut(pTrans->arbGroupIds, &groupId, sizeof(int32_t), NULL, 0);
|
||||
(void)taosHashPut(pTrans->arbGroupIds, &groupId, sizeof(int32_t), NULL, 0);
|
||||
}
|
||||
|
||||
void mndTransSetSerial(STrans *pTrans) { pTrans->exec = TRN_EXEC_SERIAL; }
|
||||
|
@ -1505,9 +1508,9 @@ static int32_t mndTransExecuteActionsSerial(SMnode *pMnode, STrans *pTrans, SArr
|
|||
pTrans->actionPos++;
|
||||
mInfo("trans:%d, %s:%d is executed and need sync to other mnodes", pTrans->id, mndTransStr(pAction->stage),
|
||||
pAction->id);
|
||||
taosThreadMutexUnlock(&pTrans->mutex);
|
||||
(void)taosThreadMutexUnlock(&pTrans->mutex);
|
||||
code = mndTransSync(pMnode, pTrans);
|
||||
taosThreadMutexLock(&pTrans->mutex);
|
||||
(void)taosThreadMutexLock(&pTrans->mutex);
|
||||
if (code != 0) {
|
||||
pTrans->actionPos--;
|
||||
pTrans->code = terrno;
|
||||
|
@ -1540,21 +1543,21 @@ static int32_t mndTransExecuteActionsSerial(SMnode *pMnode, STrans *pTrans, SArr
|
|||
|
||||
static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans, bool topHalf) {
|
||||
int32_t code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||
taosThreadMutexLock(&pTrans->mutex);
|
||||
(void)taosThreadMutexLock(&pTrans->mutex);
|
||||
if (pTrans->stage == TRN_STAGE_REDO_ACTION) {
|
||||
code = mndTransExecuteActionsSerial(pMnode, pTrans, pTrans->redoActions, topHalf);
|
||||
}
|
||||
taosThreadMutexUnlock(&pTrans->mutex);
|
||||
(void)taosThreadMutexUnlock(&pTrans->mutex);
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t mndTransExecuteUndoActionsSerial(SMnode *pMnode, STrans *pTrans, bool topHalf) {
|
||||
int32_t code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||
taosThreadMutexLock(&pTrans->mutex);
|
||||
(void)taosThreadMutexLock(&pTrans->mutex);
|
||||
if (pTrans->stage == TRN_STAGE_UNDO_ACTION) {
|
||||
code = mndTransExecuteActionsSerial(pMnode, pTrans, pTrans->undoActions, topHalf);
|
||||
}
|
||||
taosThreadMutexUnlock(&pTrans->mutex);
|
||||
(void)taosThreadMutexUnlock(&pTrans->mutex);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -1894,7 +1897,7 @@ void mndTransPullup(SMnode *pMnode) {
|
|||
STrans *pTrans = NULL;
|
||||
pIter = sdbFetch(pMnode->pSdb, SDB_TRANS, pIter, (void **)&pTrans);
|
||||
if (pIter == NULL) break;
|
||||
taosArrayPush(pArray, &pTrans->id);
|
||||
(void)taosArrayPush(pArray, &pTrans->id);
|
||||
sdbRelease(pSdb, pTrans);
|
||||
}
|
||||
|
||||
|
@ -1925,36 +1928,36 @@ static int32_t mndRetrieveTrans(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
|
|||
cols = 0;
|
||||
|
||||
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->id, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->id, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->createdTime, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->createdTime, false);
|
||||
|
||||
char stage[TSDB_TRANS_STAGE_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(stage, mndTransStr(pTrans->stage), pShow->pMeta->pSchemas[cols].bytes);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)stage, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)stage, false);
|
||||
|
||||
char opername[TSDB_TRANS_OPER_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(opername, pTrans->opername, pShow->pMeta->pSchemas[cols].bytes);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)opername, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)opername, false);
|
||||
|
||||
char dbname[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(dbname, mndGetDbStr(pTrans->dbname), pShow->pMeta->pSchemas[cols].bytes);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)dbname, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)dbname, false);
|
||||
|
||||
char stbname[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(stbname, mndGetDbStr(pTrans->stbname), pShow->pMeta->pSchemas[cols].bytes);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)stbname, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)stbname, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->failedTimes, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->failedTimes, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->lastExecTime, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->lastExecTime, false);
|
||||
|
||||
char lastInfo[TSDB_TRANS_ERROR_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
char detail[TSDB_TRANS_ERROR_LEN + 1] = {0};
|
||||
|
@ -1970,7 +1973,7 @@ static int32_t mndRetrieveTrans(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
|
|||
}
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(lastInfo, detail, pShow->pMeta->pSchemas[cols].bytes);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)lastInfo, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)lastInfo, false);
|
||||
|
||||
numOfRows++;
|
||||
sdbRelease(pSdb, pTrans);
|
||||
|
|
|
@ -36,7 +36,7 @@ int32_t sndBuildStreamTask(SSnode *pSnode, SStreamTask *pTask, int64_t nextProce
|
|||
streamTaskOpenAllUpstreamInput(pTask);
|
||||
|
||||
streamTaskResetUpstreamStageInfo(pTask);
|
||||
streamSetupScheduleTrigger(pTask);
|
||||
(void)streamSetupScheduleTrigger(pTask);
|
||||
|
||||
SCheckpointInfo *pChkInfo = &pTask->chkInfo;
|
||||
tqSetRestoreVersionInfo(pTask);
|
||||
|
@ -91,14 +91,14 @@ FAIL:
|
|||
}
|
||||
|
||||
int32_t sndInit(SSnode *pSnode) {
|
||||
streamTaskSchedTask(&pSnode->msgCb, pSnode->pMeta->vgId, 0, 0, STREAM_EXEC_T_START_ALL_TASKS);
|
||||
(void)streamTaskSchedTask(&pSnode->msgCb, pSnode->pMeta->vgId, 0, 0, STREAM_EXEC_T_START_ALL_TASKS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sndClose(SSnode *pSnode) {
|
||||
stopRsync();
|
||||
streamMetaNotifyClose(pSnode->pMeta);
|
||||
streamMetaCommit(pSnode->pMeta);
|
||||
(void)streamMetaCommit(pSnode->pMeta);
|
||||
streamMetaClose(pSnode->pMeta);
|
||||
taosMemoryFree(pSnode);
|
||||
}
|
||||
|
|
|
@ -102,8 +102,8 @@ static int32_t tsdbSaveFSToFile(STsdbFS *pFS, const char *fname) {
|
|||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
tsdbFSToBinary(pData, pFS);
|
||||
taosCalcChecksumAppend(0, pData, size);
|
||||
(void)tsdbFSToBinary(pData, pFS);
|
||||
(void)taosCalcChecksumAppend(0, pData, size);
|
||||
|
||||
// save to file
|
||||
pFD = taosOpenFile(fname, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC | TD_FILE_WRITE_THROUGH);
|
||||
|
@ -125,7 +125,7 @@ _exit:
|
|||
tsdbError("%s failed at line %d since %s, fname:%s", __func__, lino, tstrerror(code), fname);
|
||||
}
|
||||
taosMemoryFree(pData);
|
||||
taosCloseFile(&pFD);
|
||||
(void)taosCloseFile(&pFD);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -267,14 +267,14 @@ void tsdbGetCurrentFName(STsdb *pTsdb, char *current, char *current_t) {
|
|||
|
||||
// CURRENT
|
||||
if (current) {
|
||||
vnodeGetPrimaryDir(pTsdb->path, pVnode->diskPrimary, pVnode->pTfs, current, TSDB_FILENAME_LEN);
|
||||
(void)vnodeGetPrimaryDir(pTsdb->path, pVnode->diskPrimary, pVnode->pTfs, current, TSDB_FILENAME_LEN);
|
||||
offset = strlen(current);
|
||||
snprintf(current + offset, TSDB_FILENAME_LEN - offset - 1, "%sCURRENT", TD_DIRSEP);
|
||||
}
|
||||
|
||||
// CURRENT.t
|
||||
if (current_t) {
|
||||
vnodeGetPrimaryDir(pTsdb->path, pVnode->diskPrimary, pVnode->pTfs, current_t, TSDB_FILENAME_LEN);
|
||||
(void)vnodeGetPrimaryDir(pTsdb->path, pVnode->diskPrimary, pVnode->pTfs, current_t, TSDB_FILENAME_LEN);
|
||||
offset = strlen(current_t);
|
||||
snprintf(current_t + offset, TSDB_FILENAME_LEN - offset - 1, "%sCURRENT.t", TD_DIRSEP);
|
||||
}
|
||||
|
@ -295,26 +295,26 @@ static int32_t load_fs(const char *fname, STsdbFS *pFS) {
|
|||
int64_t size;
|
||||
if (taosFStatFile(pFD, &size, NULL) < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
taosCloseFile(&pFD);
|
||||
(void)taosCloseFile(&pFD);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
||||
pData = taosMemoryMalloc(size);
|
||||
if (pData == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
taosCloseFile(&pFD);
|
||||
(void)taosCloseFile(&pFD);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
||||
if (taosReadFile(pFD, pData, size) < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
taosCloseFile(&pFD);
|
||||
(void)taosCloseFile(&pFD);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
||||
if (!taosCheckChecksumWhole(pData, size)) {
|
||||
code = TSDB_CODE_FILE_CORRUPTED;
|
||||
taosCloseFile(&pFD);
|
||||
(void)taosCloseFile(&pFD);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
||||
|
@ -326,7 +326,7 @@ _exit:
|
|||
tsdbError("%s failed at line %d since %s, fname:%s", __func__, lino, tstrerror(code), fname);
|
||||
}
|
||||
taosMemoryFree(pData);
|
||||
taosCloseFile(&pFD);
|
||||
(void)taosCloseFile(&pFD);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ static int32_t tsdbSttLvlInitRef(STsdb *pTsdb, const SSttLvl *lvl1, SSttLvl **lv
|
|||
|
||||
STFileObj *fobj1;
|
||||
TARRAY2_FOREACH(lvl1->fobjArr, fobj1) {
|
||||
tsdbTFileObjRef(fobj1);
|
||||
(void)tsdbTFileObjRef(fobj1);
|
||||
code = TARRAY2_APPEND(lvl[0]->fobjArr, fobj1);
|
||||
if (code) return code;
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ static int32_t tsdbSttLvlFilteredInitEx(STsdb *pTsdb, const SSttLvl *lvl1, int64
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void tsdbSttLvlRemoveFObj(void *data) { tsdbTFileObjRemove(*(STFileObj **)data); }
|
||||
static void tsdbSttLvlRemoveFObj(void *data) { (void)tsdbTFileObjRemove(*(STFileObj **)data); }
|
||||
static void tsdbSttLvlRemove(SSttLvl **lvl) {
|
||||
TARRAY2_DESTROY(lvl[0]->fobjArr, tsdbSttLvlRemoveFObj);
|
||||
taosMemoryFree(lvl[0]);
|
||||
|
@ -173,7 +173,7 @@ static int32_t tsdbSttLvlToJson(const SSttLvl *lvl, cJSON *json) {
|
|||
TARRAY2_FOREACH(lvl->fobjArr, fobj) {
|
||||
cJSON *item = cJSON_CreateObject();
|
||||
if (item == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
||||
cJSON_AddItemToArray(ajson, item);
|
||||
(void)cJSON_AddItemToArray(ajson, item);
|
||||
|
||||
int32_t code = tsdbTFileToJson(fobj->f, item);
|
||||
if (code) return code;
|
||||
|
@ -198,7 +198,7 @@ static int32_t tsdbJsonToSttLvl(STsdb *pTsdb, const cJSON *json, SSttLvl **lvl)
|
|||
|
||||
item1 = cJSON_GetObjectItem(json, "files");
|
||||
if (!cJSON_IsArray(item1)) {
|
||||
tsdbSttLvlClear(lvl);
|
||||
(void)tsdbSttLvlClear(lvl);
|
||||
return TSDB_CODE_FILE_CORRUPTED;
|
||||
}
|
||||
|
||||
|
@ -206,14 +206,14 @@ static int32_t tsdbJsonToSttLvl(STsdb *pTsdb, const cJSON *json, SSttLvl **lvl)
|
|||
STFile tf;
|
||||
code = tsdbJsonToTFile(item2, TSDB_FTYPE_STT, &tf);
|
||||
if (code) {
|
||||
tsdbSttLvlClear(lvl);
|
||||
(void)tsdbSttLvlClear(lvl);
|
||||
return code;
|
||||
}
|
||||
|
||||
STFileObj *fobj;
|
||||
code = tsdbTFileObjInit(pTsdb, &tf, &fobj);
|
||||
if (code) {
|
||||
tsdbSttLvlClear(lvl);
|
||||
(void)tsdbSttLvlClear(lvl);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -247,7 +247,7 @@ int32_t tsdbTFileSetToJson(const STFileSet *fset, cJSON *json) {
|
|||
TARRAY2_FOREACH(fset->lvlArr, lvl) {
|
||||
item2 = cJSON_CreateObject();
|
||||
if (!item2) return TSDB_CODE_OUT_OF_MEMORY;
|
||||
cJSON_AddItemToArray(item1, item2);
|
||||
(void)cJSON_AddItemToArray(item1, item2);
|
||||
|
||||
code = tsdbSttLvlToJson(lvl, item2);
|
||||
if (code) return code;
|
||||
|
@ -347,7 +347,7 @@ int32_t tsdbTFileSetEdit(STsdb *pTsdb, STFileSet *fset, const STFileOp *op) {
|
|||
TARRAY2_REMOVE(lvl->fobjArr, idx, tsdbSttLvlClearFObj);
|
||||
} else {
|
||||
ASSERT(tsdbIsSameTFile(&op->of, fset->farr[op->of.type]->f));
|
||||
tsdbTFileObjUnref(fset->farr[op->of.type]);
|
||||
(void)tsdbTFileObjUnref(fset->farr[op->of.type]);
|
||||
fset->farr[op->of.type] = NULL;
|
||||
}
|
||||
} else {
|
||||
|
@ -389,9 +389,9 @@ int32_t tsdbTFileSetApplyEdit(STsdb *pTsdb, const STFileSet *fset1, STFileSet *f
|
|||
}
|
||||
} else {
|
||||
if (fobj1->f->cid != fobj2->f->cid) {
|
||||
tsdbTFileObjRemove(fobj2);
|
||||
(void)tsdbTFileObjRemove(fobj2);
|
||||
} else {
|
||||
tsdbTFileObjRemoveUpdateLC(fobj2);
|
||||
(void)tsdbTFileObjRemoveUpdateLC(fobj2);
|
||||
}
|
||||
code = tsdbTFileObjInit(pTsdb, fobj1->f, &fset2->farr[ftype]);
|
||||
if (code) return code;
|
||||
|
@ -402,7 +402,7 @@ int32_t tsdbTFileSetApplyEdit(STsdb *pTsdb, const STFileSet *fset1, STFileSet *f
|
|||
if (code) return code;
|
||||
} else {
|
||||
// remove the file
|
||||
tsdbTFileObjRemove(fobj2);
|
||||
(void)tsdbTFileObjRemove(fobj2);
|
||||
fset2->farr[ftype] = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -460,12 +460,12 @@ int32_t tsdbTFileSetInit(int32_t fid, STFileSet **fset) {
|
|||
TARRAY2_INIT(fset[0]->lvlArr);
|
||||
|
||||
// background task queue
|
||||
taosThreadCondInit(&(*fset)->beginTask, NULL);
|
||||
(void)taosThreadCondInit(&(*fset)->beginTask, NULL);
|
||||
(*fset)->taskRunning = false;
|
||||
(*fset)->numWaitTask = 0;
|
||||
|
||||
// block commit variables
|
||||
taosThreadCondInit(&fset[0]->canCommit, NULL);
|
||||
(void)taosThreadCondInit(&fset[0]->canCommit, NULL);
|
||||
(*fset)->numWaitCommit = 0;
|
||||
(*fset)->blockCommit = false;
|
||||
|
||||
|
@ -567,7 +567,7 @@ int32_t tsdbTFileSetInitRef(STsdb *pTsdb, const STFileSet *fset1, STFileSet **fs
|
|||
for (int32_t ftype = TSDB_FTYPE_MIN; ftype < TSDB_FTYPE_MAX; ++ftype) {
|
||||
if (fset1->farr[ftype] == NULL) continue;
|
||||
|
||||
tsdbTFileObjRef(fset1->farr[ftype]);
|
||||
(void)tsdbTFileObjRef(fset1->farr[ftype]);
|
||||
fset[0]->farr[ftype] = fset1->farr[ftype];
|
||||
}
|
||||
|
||||
|
@ -609,13 +609,13 @@ void tsdbTFileSetClear(STFileSet **fset) {
|
|||
if (fset && *fset) {
|
||||
for (tsdb_ftype_t ftype = TSDB_FTYPE_MIN; ftype < TSDB_FTYPE_MAX; ++ftype) {
|
||||
if ((*fset)->farr[ftype] == NULL) continue;
|
||||
tsdbTFileObjUnref((*fset)->farr[ftype]);
|
||||
(void)tsdbTFileObjUnref((*fset)->farr[ftype]);
|
||||
}
|
||||
|
||||
TARRAY2_DESTROY((*fset)->lvlArr, tsdbSttLvlClear);
|
||||
|
||||
taosThreadCondDestroy(&(*fset)->beginTask);
|
||||
taosThreadCondDestroy(&(*fset)->canCommit);
|
||||
(void)taosThreadCondDestroy(&(*fset)->beginTask);
|
||||
(void)taosThreadCondDestroy(&(*fset)->canCommit);
|
||||
taosMemoryFreeClear(*fset);
|
||||
}
|
||||
}
|
||||
|
@ -625,7 +625,7 @@ int32_t tsdbTFileSetRemove(STFileSet *fset) {
|
|||
|
||||
for (tsdb_ftype_t ftype = TSDB_FTYPE_MIN; ftype < TSDB_FTYPE_MAX; ++ftype) {
|
||||
if (fset->farr[ftype] != NULL) {
|
||||
tsdbTFileObjRemove(fset->farr[ftype]);
|
||||
(void)tsdbTFileObjRemove(fset->farr[ftype]);
|
||||
fset->farr[ftype] = NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -410,7 +410,7 @@ static int32_t tsdbGetOrCreateTbData(SMemTable *pMemTable, tb_uid_t suid, tb_uid
|
|||
pMemTable->aBucket[idx] = pTbData;
|
||||
pMemTable->nTbData++;
|
||||
|
||||
tRBTreePut(pMemTable->tbDataTree, pTbData->rbtn);
|
||||
(void)tRBTreePut(pMemTable->tbDataTree, pTbData->rbtn);
|
||||
|
||||
taosWUnLockLatch(&pMemTable->latch);
|
||||
|
||||
|
@ -742,7 +742,7 @@ int32_t tsdbRefMemTable(SMemTable *pMemTable, SQueryNode *pQNode) {
|
|||
int32_t nRef = atomic_fetch_add_32(&pMemTable->nRef, 1);
|
||||
ASSERT(nRef > 0);
|
||||
|
||||
vnodeBufPoolRegisterQuery(pMemTable->pPool, pQNode);
|
||||
(void)vnodeBufPoolRegisterQuery(pMemTable->pPool, pQNode);
|
||||
|
||||
_exit:
|
||||
return code;
|
||||
|
|
|
@ -65,7 +65,7 @@ _exit:
|
|||
if (code) {
|
||||
tsdbError("vgId:%d %s failed at line %d since %s, sver:0, ever:%" PRId64 " type:%d", TD_VID(tsdb->pVnode), __func__,
|
||||
lino, tstrerror(code), ever, type);
|
||||
tsdbFSDestroyRefSnapshot(&reader[0]->fsetArr);
|
||||
(void)tsdbFSDestroyRefSnapshot(&reader[0]->fsetArr);
|
||||
taosMemoryFree(reader[0]);
|
||||
reader[0] = NULL;
|
||||
} else {
|
||||
|
@ -84,7 +84,7 @@ int32_t tsdbSnapRAWReaderClose(STsdbSnapRAWReader** reader) {
|
|||
STsdb* tsdb = reader[0]->tsdb;
|
||||
|
||||
TARRAY2_DESTROY(reader[0]->dataReaderArr, tsdbDataFileRAWReaderClose);
|
||||
tsdbFSDestroyRefSnapshot(&reader[0]->fsetArr);
|
||||
(void)tsdbFSDestroyRefSnapshot(&reader[0]->fsetArr);
|
||||
taosMemoryFree(reader[0]);
|
||||
reader[0] = NULL;
|
||||
|
||||
|
@ -141,7 +141,7 @@ static int32_t tsdbSnapRAWReadFileSetOpenReader(STsdbSnapRAWReader* reader) {
|
|||
|
||||
_exit:
|
||||
if (code) {
|
||||
tsdbSnapRAWReadFileSetCloseReader(reader);
|
||||
(void)tsdbSnapRAWReadFileSetCloseReader(reader);
|
||||
TSDB_ERROR_LOG(TD_VID(reader->tsdb->pVnode), code, lino);
|
||||
}
|
||||
return code;
|
||||
|
@ -268,8 +268,8 @@ _exit:
|
|||
}
|
||||
|
||||
static int32_t tsdbSnapRAWReadEnd(STsdbSnapRAWReader* reader) {
|
||||
tsdbSnapRAWReadFileSetCloseIter(reader);
|
||||
tsdbSnapRAWReadFileSetCloseReader(reader);
|
||||
(void)tsdbSnapRAWReadFileSetCloseIter(reader);
|
||||
(void)tsdbSnapRAWReadFileSetCloseReader(reader);
|
||||
reader->ctx->fset = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
@ -420,7 +420,7 @@ static int32_t tsdbSnapRAWWriteFileSetBegin(STsdbSnapRAWWriter* writer, int32_t
|
|||
int32_t level = tsdbFidLevel(fid, &writer->tsdb->keepCfg, taosGetTimestampSec());
|
||||
code = tfsAllocDisk(writer->tsdb->pVnode->pTfs, level, &writer->ctx->did);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
tfsMkdirRecurAt(writer->tsdb->pVnode->pTfs, writer->tsdb->path, writer->ctx->did);
|
||||
(void)tfsMkdirRecurAt(writer->tsdb->pVnode->pTfs, writer->tsdb->path, writer->ctx->did);
|
||||
|
||||
code = tsdbSnapRAWWriteFileSetOpenWriter(writer);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
@ -499,7 +499,7 @@ int32_t tsdbSnapRAWWriterClose(STsdbSnapRAWWriter** writer, int8_t rollback) {
|
|||
}
|
||||
|
||||
TARRAY2_DESTROY(writer[0]->fopArr, NULL);
|
||||
tsdbFSDestroyCopySnapshot(&writer[0]->fsetArr);
|
||||
(void)tsdbFSDestroyCopySnapshot(&writer[0]->fsetArr);
|
||||
|
||||
taosMemoryFree(writer[0]);
|
||||
writer[0] = NULL;
|
||||
|
|
|
@ -55,7 +55,7 @@ int32_t tsdbSttFileReaderOpen(const char *fname, const SSttFileReaderConfig *con
|
|||
TAOS_CHECK_GOTO(tsdbOpenFile(fname, config->tsdb, TD_FILE_READ, &reader[0]->fd, 0), &lino, _exit);
|
||||
} else {
|
||||
char fname1[TSDB_FILENAME_LEN];
|
||||
tsdbTFileName(config->tsdb, config->file, fname1);
|
||||
(void)tsdbTFileName(config->tsdb, config->file, fname1);
|
||||
TAOS_CHECK_GOTO(tsdbOpenFile(fname1, config->tsdb, TD_FILE_READ, &reader[0]->fd, 0), &lino, _exit);
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ _exit:
|
|||
if (code) {
|
||||
tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(config->tsdb->pVnode), __func__, __FILE__, lino,
|
||||
tstrerror(code));
|
||||
tsdbSttFileReaderClose(reader);
|
||||
(void)tsdbSttFileReaderClose(reader);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -790,7 +790,7 @@ static int32_t tsdbSttFWriterDoOpen(SSttFileWriter *writer) {
|
|||
int32_t flag = TD_FILE_READ | TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC;
|
||||
char fname[TSDB_FILENAME_LEN];
|
||||
|
||||
tsdbTFileName(writer->config->tsdb, writer->file, fname);
|
||||
(void)tsdbTFileName(writer->config->tsdb, writer->file, fname);
|
||||
TAOS_CHECK_GOTO(tsdbOpenFile(fname, writer->config->tsdb, flag, &writer->fd, 0), &lino, _exit);
|
||||
|
||||
uint8_t hdr[TSDB_FHDR_SIZE] = {0};
|
||||
|
@ -860,7 +860,7 @@ static int32_t tsdbSttFWriterCloseCommit(SSttFileWriter *writer, TFileOpArray *o
|
|||
.fid = writer->config->fid,
|
||||
.nf = writer->file[0],
|
||||
};
|
||||
tsdbTFileUpdVerRange(&op.nf, writer->ctx->range);
|
||||
(void)tsdbTFileUpdVerRange(&op.nf, writer->ctx->range);
|
||||
|
||||
TAOS_CHECK_GOTO(TARRAY2_APPEND(opArray, op), &lino, _exit);
|
||||
|
||||
|
@ -874,7 +874,7 @@ _exit:
|
|||
|
||||
static int32_t tsdbSttFWriterCloseAbort(SSttFileWriter *writer) {
|
||||
char fname[TSDB_FILENAME_LEN];
|
||||
tsdbTFileName(writer->config->tsdb, writer->file, fname);
|
||||
(void)tsdbTFileName(writer->config->tsdb, writer->file, fname);
|
||||
tsdbCloseFile(&writer->fd);
|
||||
(void)taosRemoveFile(fname);
|
||||
return 0;
|
||||
|
|
|
@ -171,12 +171,12 @@ static int32_t vnodeAsyncTaskDone(SVAsync *async, SVATask *task) {
|
|||
async->numTasks--;
|
||||
|
||||
if (task->numWait == 0) {
|
||||
taosThreadCondDestroy(&task->waitCond);
|
||||
(void)taosThreadCondDestroy(&task->waitCond);
|
||||
taosMemoryFree(task);
|
||||
} else if (task->numWait == 1) {
|
||||
taosThreadCondSignal(&task->waitCond);
|
||||
(void)taosThreadCondSignal(&task->waitCond);
|
||||
} else {
|
||||
taosThreadCondBroadcast(&task->waitCond);
|
||||
(void)taosThreadCondBroadcast(&task->waitCond);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ static int32_t vnodeAsyncCancelAllTasks(SVAsync *async, SArray *cancelArray) {
|
|||
.arg = task->arg,
|
||||
}));
|
||||
}
|
||||
vnodeAsyncTaskDone(async, task);
|
||||
(void)vnodeAsyncTaskDone(async, task);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -217,14 +217,14 @@ static void *vnodeAsyncLoop(void *arg) {
|
|||
|
||||
// finish last running task
|
||||
if (worker->runningTask != NULL) {
|
||||
vnodeAsyncTaskDone(async, worker->runningTask);
|
||||
(void)vnodeAsyncTaskDone(async, worker->runningTask);
|
||||
worker->runningTask = NULL;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
if (async->stop || worker->workerId >= async->numWorkers) {
|
||||
if (async->stop) { // cancel all tasks
|
||||
vnodeAsyncCancelAllTasks(async, cancelArray);
|
||||
(void)vnodeAsyncCancelAllTasks(async, cancelArray);
|
||||
}
|
||||
worker->state = EVA_WORKER_STATE_STOP;
|
||||
async->numLaunchWorkers--;
|
||||
|
@ -259,7 +259,7 @@ static void *vnodeAsyncLoop(void *arg) {
|
|||
if (worker->runningTask == NULL) {
|
||||
worker->state = EVA_WORKER_STATE_IDLE;
|
||||
async->numIdleWorkers++;
|
||||
taosThreadCondWait(&async->hasTask, &async->mutex);
|
||||
(void)taosThreadCondWait(&async->hasTask, &async->mutex);
|
||||
async->numIdleWorkers--;
|
||||
worker->state = EVA_WORKER_STATE_ACTIVE;
|
||||
} else {
|
||||
|
@ -271,7 +271,7 @@ static void *vnodeAsyncLoop(void *arg) {
|
|||
(void)taosThreadMutexUnlock(&async->mutex);
|
||||
|
||||
// do run the task
|
||||
worker->runningTask->execute(worker->runningTask->arg);
|
||||
(void)worker->runningTask->execute(worker->runningTask->arg);
|
||||
}
|
||||
|
||||
_exit:
|
||||
|
@ -334,8 +334,8 @@ static int32_t vnodeAsyncInit(SVAsync **async, const char *label) {
|
|||
strcpy((char *)((*async) + 1), label);
|
||||
(*async)->label = (const char *)((*async) + 1);
|
||||
|
||||
taosThreadMutexInit(&(*async)->mutex, NULL);
|
||||
taosThreadCondInit(&(*async)->hasTask, NULL);
|
||||
(void)taosThreadMutexInit(&(*async)->mutex, NULL);
|
||||
(void)taosThreadCondInit(&(*async)->hasTask, NULL);
|
||||
(*async)->stop = false;
|
||||
|
||||
// worker
|
||||
|
@ -356,8 +356,8 @@ static int32_t vnodeAsyncInit(SVAsync **async, const char *label) {
|
|||
(*async)->chList.next = &(*async)->chList;
|
||||
ret = vHashInit(&(*async)->channelTable, vnodeAsyncChannelHash, vnodeAsyncChannelCompare);
|
||||
if (ret != 0) {
|
||||
taosThreadMutexDestroy(&(*async)->mutex);
|
||||
taosThreadCondDestroy(&(*async)->hasTask);
|
||||
(void)taosThreadMutexDestroy(&(*async)->mutex);
|
||||
(void)taosThreadCondDestroy(&(*async)->hasTask);
|
||||
taosMemoryFree(*async);
|
||||
return ret;
|
||||
}
|
||||
|
@ -371,9 +371,9 @@ static int32_t vnodeAsyncInit(SVAsync **async, const char *label) {
|
|||
}
|
||||
ret = vHashInit(&(*async)->taskTable, vnodeAsyncTaskHash, vnodeAsyncTaskCompare);
|
||||
if (ret != 0) {
|
||||
vHashDestroy(&(*async)->channelTable);
|
||||
taosThreadMutexDestroy(&(*async)->mutex);
|
||||
taosThreadCondDestroy(&(*async)->hasTask);
|
||||
(void)vHashDestroy(&(*async)->channelTable);
|
||||
(void)taosThreadMutexDestroy(&(*async)->mutex);
|
||||
(void)taosThreadCondDestroy(&(*async)->hasTask);
|
||||
taosMemoryFree(*async);
|
||||
return ret;
|
||||
}
|
||||
|
@ -402,7 +402,7 @@ static int32_t vnodeAsyncDestroy(SVAsync **async) {
|
|||
continue;
|
||||
}
|
||||
|
||||
taosThreadJoin((*async)->workers[i].thread, NULL);
|
||||
(void)taosThreadJoin((*async)->workers[i].thread, NULL);
|
||||
ASSERT((*async)->workers[i].state == EVA_WORKER_STATE_STOP);
|
||||
(*async)->workers[i].state = EVA_WORKER_STATE_UINIT;
|
||||
}
|
||||
|
@ -425,11 +425,11 @@ static int32_t vnodeAsyncDestroy(SVAsync **async) {
|
|||
ASSERT((*async)->numChannels == 0);
|
||||
ASSERT((*async)->numTasks == 0);
|
||||
|
||||
taosThreadMutexDestroy(&(*async)->mutex);
|
||||
taosThreadCondDestroy(&(*async)->hasTask);
|
||||
(void)taosThreadMutexDestroy(&(*async)->mutex);
|
||||
(void)taosThreadCondDestroy(&(*async)->hasTask);
|
||||
|
||||
vHashDestroy(&(*async)->channelTable);
|
||||
vHashDestroy(&(*async)->taskTable);
|
||||
(void)vHashDestroy(&(*async)->channelTable);
|
||||
(void)vHashDestroy(&(*async)->taskTable);
|
||||
taosMemoryFree(*async);
|
||||
*async = NULL;
|
||||
|
||||
|
@ -442,11 +442,11 @@ static int32_t vnodeAsyncLaunchWorker(SVAsync *async) {
|
|||
if (async->workers[i].state == EVA_WORKER_STATE_ACTIVE) {
|
||||
continue;
|
||||
} else if (async->workers[i].state == EVA_WORKER_STATE_STOP) {
|
||||
taosThreadJoin(async->workers[i].thread, NULL);
|
||||
(void)taosThreadJoin(async->workers[i].thread, NULL);
|
||||
async->workers[i].state = EVA_WORKER_STATE_UINIT;
|
||||
}
|
||||
|
||||
taosThreadCreate(&async->workers[i].thread, NULL, vnodeAsyncLoop, &async->workers[i]);
|
||||
(void)taosThreadCreate(&async->workers[i].thread, NULL, vnodeAsyncLoop, &async->workers[i]);
|
||||
async->workers[i].state = EVA_WORKER_STATE_ACTIVE;
|
||||
async->numLaunchWorkers++;
|
||||
break;
|
||||
|
@ -461,20 +461,20 @@ int32_t vnodeAsyncOpen(int32_t numOfThreads) {
|
|||
// vnode-commit
|
||||
code = vnodeAsyncInit(&vnodeAsyncs[1], "vnode-commit");
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
vnodeAsyncSetWorkers(1, numOfThreads);
|
||||
(void)vnodeAsyncSetWorkers(1, numOfThreads);
|
||||
|
||||
// vnode-merge
|
||||
code = vnodeAsyncInit(&vnodeAsyncs[2], "vnode-merge");
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
vnodeAsyncSetWorkers(2, numOfThreads);
|
||||
(void)vnodeAsyncSetWorkers(2, numOfThreads);
|
||||
|
||||
_exit:
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t vnodeAsyncClose() {
|
||||
vnodeAsyncDestroy(&vnodeAsyncs[1]);
|
||||
vnodeAsyncDestroy(&vnodeAsyncs[2]);
|
||||
(void)vnodeAsyncDestroy(&vnodeAsyncs[1]);
|
||||
(void)vnodeAsyncDestroy(&vnodeAsyncs[2]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -501,7 +501,7 @@ int32_t vnodeAsync(SVAChannelID *channelID, EVAPriority priority, int32_t (*exec
|
|||
task->arg = arg;
|
||||
task->state = EVA_TASK_STATE_WAITTING;
|
||||
task->numWait = 0;
|
||||
taosThreadCondInit(&task->waitCond, NULL);
|
||||
(void)taosThreadCondInit(&task->waitCond, NULL);
|
||||
|
||||
// schedule task
|
||||
(void)taosThreadMutexLock(&async->mutex);
|
||||
|
@ -512,10 +512,10 @@ int32_t vnodeAsync(SVAChannelID *channelID, EVAPriority priority, int32_t (*exec
|
|||
SVAChannel channel = {
|
||||
.channelId = channelID->id,
|
||||
};
|
||||
vHashGet(async->channelTable, &channel, (void **)&task->channel);
|
||||
(void)vHashGet(async->channelTable, &channel, (void **)&task->channel);
|
||||
if (task->channel == NULL) {
|
||||
(void)taosThreadMutexUnlock(&async->mutex);
|
||||
taosThreadCondDestroy(&task->waitCond);
|
||||
(void)taosThreadCondDestroy(&task->waitCond);
|
||||
taosMemoryFree(task);
|
||||
return TSDB_CODE_INVALID_PARA;
|
||||
}
|
||||
|
@ -527,7 +527,7 @@ int32_t vnodeAsync(SVAChannelID *channelID, EVAPriority priority, int32_t (*exec
|
|||
int32_t ret = vHashPut(async->taskTable, task);
|
||||
if (ret != 0) {
|
||||
(void)taosThreadMutexUnlock(&async->mutex);
|
||||
taosThreadCondDestroy(&task->waitCond);
|
||||
(void)taosThreadCondDestroy(&task->waitCond);
|
||||
taosMemoryFree(task);
|
||||
return ret;
|
||||
}
|
||||
|
@ -548,9 +548,9 @@ int32_t vnodeAsync(SVAChannelID *channelID, EVAPriority priority, int32_t (*exec
|
|||
|
||||
// signal worker or launch new worker
|
||||
if (async->numIdleWorkers > 0) {
|
||||
taosThreadCondSignal(&(async->hasTask));
|
||||
(void)taosThreadCondSignal(&(async->hasTask));
|
||||
} else if (async->numLaunchWorkers < async->numWorkers) {
|
||||
vnodeAsyncLaunchWorker(async);
|
||||
(void)vnodeAsyncLaunchWorker(async);
|
||||
}
|
||||
} else if (task->channel->scheduled->state == EVA_TASK_STATE_RUNNING ||
|
||||
priority >= VATASK_PIORITY(task->channel->scheduled)) {
|
||||
|
@ -603,14 +603,14 @@ int32_t vnodeAWait(SVATaskID *taskID) {
|
|||
|
||||
(void)taosThreadMutexLock(&async->mutex);
|
||||
|
||||
vHashGet(async->taskTable, &task2, (void **)&task);
|
||||
(void)vHashGet(async->taskTable, &task2, (void **)&task);
|
||||
if (task) {
|
||||
task->numWait++;
|
||||
taosThreadCondWait(&task->waitCond, &async->mutex);
|
||||
(void)taosThreadCondWait(&task->waitCond, &async->mutex);
|
||||
task->numWait--;
|
||||
|
||||
if (task->numWait == 0) {
|
||||
taosThreadCondDestroy(&task->waitCond);
|
||||
(void)taosThreadCondDestroy(&task->waitCond);
|
||||
taosMemoryFree(task);
|
||||
}
|
||||
}
|
||||
|
@ -636,14 +636,14 @@ int32_t vnodeACancel(SVATaskID *taskID) {
|
|||
|
||||
(void)taosThreadMutexLock(&async->mutex);
|
||||
|
||||
vHashGet(async->taskTable, &task2, (void **)&task);
|
||||
(void)vHashGet(async->taskTable, &task2, (void **)&task);
|
||||
if (task) {
|
||||
if (task->state == EVA_TASK_STATE_WAITTING) {
|
||||
cancel = task->cancel;
|
||||
arg = task->arg;
|
||||
task->next->prev = task->prev;
|
||||
task->prev->next = task->next;
|
||||
vnodeAsyncTaskDone(async, task);
|
||||
(void)vnodeAsyncTaskDone(async, task);
|
||||
} else {
|
||||
ret = TSDB_CODE_FAILED;
|
||||
}
|
||||
|
@ -736,12 +736,12 @@ int32_t vnodeAChannelDestroy(SVAChannelID *channelID, bool waitRunning) {
|
|||
|
||||
(void)taosThreadMutexLock(&async->mutex);
|
||||
|
||||
vHashGet(async->channelTable, &channel2, (void **)&channel);
|
||||
(void)vHashGet(async->channelTable, &channel2, (void **)&channel);
|
||||
if (channel) {
|
||||
// unregister channel
|
||||
channel->next->prev = channel->prev;
|
||||
channel->prev->next = channel->next;
|
||||
vHashDrop(async->channelTable, channel);
|
||||
(void)vHashDrop(async->channelTable, channel);
|
||||
async->numChannels--;
|
||||
|
||||
// cancel all waiting tasks
|
||||
|
@ -756,7 +756,7 @@ int32_t vnodeAChannelDestroy(SVAChannelID *channelID, bool waitRunning) {
|
|||
.arg = task->arg,
|
||||
}));
|
||||
}
|
||||
vnodeAsyncTaskDone(async, task);
|
||||
(void)vnodeAsyncTaskDone(async, task);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -771,7 +771,7 @@ int32_t vnodeAChannelDestroy(SVAChannelID *channelID, bool waitRunning) {
|
|||
.arg = channel->scheduled->arg,
|
||||
}));
|
||||
}
|
||||
vnodeAsyncTaskDone(async, channel->scheduled);
|
||||
(void)vnodeAsyncTaskDone(async, channel->scheduled);
|
||||
}
|
||||
taosMemoryFree(channel);
|
||||
} else {
|
||||
|
@ -779,10 +779,10 @@ int32_t vnodeAChannelDestroy(SVAChannelID *channelID, bool waitRunning) {
|
|||
// wait task
|
||||
SVATask *task = channel->scheduled;
|
||||
task->numWait++;
|
||||
taosThreadCondWait(&task->waitCond, &async->mutex);
|
||||
(void)taosThreadCondWait(&task->waitCond, &async->mutex);
|
||||
task->numWait--;
|
||||
if (task->numWait == 0) {
|
||||
taosThreadCondDestroy(&task->waitCond);
|
||||
(void)taosThreadCondDestroy(&task->waitCond);
|
||||
taosMemoryFree(task);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ static int32_t vnodeBufPoolCreate(SVnode *pVnode, int32_t id, int64_t size, SVBu
|
|||
memset(pPool, 0, sizeof(SVBufPool));
|
||||
|
||||
// query handle list
|
||||
taosThreadMutexInit(&pPool->mutex, NULL);
|
||||
(void)taosThreadMutexInit(&pPool->mutex, NULL);
|
||||
pPool->nQuery = 0;
|
||||
pPool->qList.pNext = &pPool->qList;
|
||||
pPool->qList.ppNext = &pPool->qList.pNext;
|
||||
|
@ -61,10 +61,10 @@ static int32_t vnodeBufPoolCreate(SVnode *pVnode, int32_t id, int64_t size, SVBu
|
|||
static int vnodeBufPoolDestroy(SVBufPool *pPool) {
|
||||
vnodeBufPoolReset(pPool);
|
||||
if (pPool->lock) {
|
||||
taosThreadSpinDestroy(pPool->lock);
|
||||
(void)taosThreadSpinDestroy(pPool->lock);
|
||||
taosMemoryFree((void *)pPool->lock);
|
||||
}
|
||||
taosThreadMutexDestroy(&pPool->mutex);
|
||||
(void)taosThreadMutexDestroy(&pPool->mutex);
|
||||
taosMemoryFree(pPool);
|
||||
return 0;
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ int vnodeOpenBufPool(SVnode *pVnode) {
|
|||
int32_t code;
|
||||
if ((code = vnodeBufPoolCreate(pVnode, i, size, &pVnode->aBufPool[i]))) {
|
||||
vError("vgId:%d, failed to open vnode buffer pool since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
vnodeCloseBufPool(pVnode);
|
||||
(void)vnodeCloseBufPool(pVnode);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ int vnodeOpenBufPool(SVnode *pVnode) {
|
|||
int vnodeCloseBufPool(SVnode *pVnode) {
|
||||
for (int32_t i = 0; i < VNODE_BUFPOOL_SEGMENTS; i++) {
|
||||
if (pVnode->aBufPool[i]) {
|
||||
vnodeBufPoolDestroy(pVnode->aBufPool[i]);
|
||||
(void)vnodeBufPoolDestroy(pVnode->aBufPool[i]);
|
||||
pVnode->aBufPool[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ void *vnodeBufPoolMallocAligned(SVBufPool *pPool, int size) {
|
|||
pNode = taosMemoryMalloc(sizeof(*pNode) + size);
|
||||
if (pNode == NULL) {
|
||||
if (pPool->lock) {
|
||||
taosThreadSpinUnlock(pPool->lock);
|
||||
(void)taosThreadSpinUnlock(pPool->lock);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ void *vnodeBufPoolMallocAligned(SVBufPool *pPool, int size) {
|
|||
|
||||
pPool->size = pPool->size + sizeof(*pNode) + size;
|
||||
}
|
||||
if (pPool->lock) taosThreadSpinUnlock(pPool->lock);
|
||||
if (pPool->lock) (void)taosThreadSpinUnlock(pPool->lock);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,7 @@ void *vnodeBufPoolMalloc(SVBufPool *pPool, int size) {
|
|||
// allocate a new node
|
||||
pNode = taosMemoryMalloc(sizeof(*pNode) + size);
|
||||
if (pNode == NULL) {
|
||||
if (pPool->lock) taosThreadSpinUnlock(pPool->lock);
|
||||
if (pPool->lock) (void)taosThreadSpinUnlock(pPool->lock);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,7 @@ void *vnodeBufPoolMalloc(SVBufPool *pPool, int size) {
|
|||
|
||||
pPool->size = pPool->size + sizeof(*pNode) + size;
|
||||
}
|
||||
if (pPool->lock) taosThreadSpinUnlock(pPool->lock);
|
||||
if (pPool->lock) (void)taosThreadSpinUnlock(pPool->lock);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,7 @@ void vnodeBufPoolAddToFreeList(SVBufPool *pPool) {
|
|||
vInfo("vgId:%d, buffer pool of id %d size changed from %" PRId64 " to %" PRId64, TD_VID(pVnode), pPool->id,
|
||||
pPool->node.size, size);
|
||||
|
||||
vnodeBufPoolDestroy(pPool);
|
||||
(void)vnodeBufPoolDestroy(pPool);
|
||||
pPool = pNewPool;
|
||||
pVnode->aBufPool[pPool->id] = pPool;
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ void vnodeBufPoolAddToFreeList(SVBufPool *pPool) {
|
|||
vnodeBufPoolReset(pPool);
|
||||
pPool->freeNext = pVnode->freeList;
|
||||
pVnode->freeList = pPool;
|
||||
taosThreadCondSignal(&pVnode->poolNotEmpty);
|
||||
(void)taosThreadCondSignal(&pVnode->poolNotEmpty);
|
||||
}
|
||||
|
||||
void vnodeBufPoolUnRef(SVBufPool *pPool, bool proactive) {
|
||||
|
|
|
@ -127,7 +127,7 @@ int vnodeEncodeConfig(const void *pObj, SJson *pJson) {
|
|||
if (pNodeRetentions == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tjsonAddItemToObject(pJson, "retentions", pNodeRetentions);
|
||||
TAOS_CHECK_RETURN(tjsonAddItemToObject(pJson, "retentions", pNodeRetentions));
|
||||
for (int32_t i = 0; i < nRetention; ++i) {
|
||||
SJson *pNodeRetention = tjsonCreateObject();
|
||||
const SRetention *pRetention = pCfg->tsdbCfg.retentions + i;
|
||||
|
@ -353,7 +353,7 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
|
|||
if (info == NULL) return -1;
|
||||
tjsonGetNumberValue(info, "nodePort", pNode->nodePort, code);
|
||||
if (code) return code;
|
||||
tjsonGetStringValue(info, "nodeFqdn", pNode->nodeFqdn);
|
||||
(void)tjsonGetStringValue(info, "nodeFqdn", pNode->nodeFqdn);
|
||||
tjsonGetNumberValue(info, "nodeId", pNode->nodeId, code);
|
||||
if (code) return code;
|
||||
tjsonGetNumberValue(info, "clusterId", pNode->clusterId, code);
|
||||
|
|
|
@ -91,7 +91,7 @@ static int32_t vnodeGetBufPoolToUse(SVnode *pVnode) {
|
|||
|
||||
struct timeval tv;
|
||||
struct timespec ts;
|
||||
taosGetTimeOfDay(&tv);
|
||||
(void)taosGetTimeOfDay(&tv);
|
||||
ts.tv_nsec = tv.tv_usec * 1000 + WAIT_TIME_MILI_SEC * 1000000;
|
||||
if (ts.tv_nsec > 999999999l) {
|
||||
ts.tv_sec = tv.tv_sec + 1;
|
||||
|
@ -199,7 +199,7 @@ _exit:
|
|||
vInfo("vgId:%d, vnode info is saved, fname:%s replica:%d selfIndex:%d changeVersion:%d", pInfo->config.vgId, fname,
|
||||
pInfo->config.syncCfg.replicaNum, pInfo->config.syncCfg.myIndex, pInfo->config.syncCfg.changeVersion);
|
||||
}
|
||||
taosCloseFile(&pFile);
|
||||
(void)taosCloseFile(&pFile);
|
||||
taosMemoryFree(data);
|
||||
return code;
|
||||
}
|
||||
|
@ -259,7 +259,7 @@ _exit:
|
|||
vError("vgId:%d %s failed at %s:%d since %s", pInfo->config.vgId, __func__, __FILE__, lino, tstrerror(code));
|
||||
}
|
||||
taosMemoryFree(pData);
|
||||
taosCloseFile(&pFile);
|
||||
(void)taosCloseFile(&pFile);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -270,7 +270,7 @@ static int32_t vnodePrepareCommit(SVnode *pVnode, SCommitInfo *pInfo) {
|
|||
int64_t lastCommitted = pInfo->info.state.committed;
|
||||
|
||||
// wait last commit task
|
||||
vnodeAWait(&pVnode->commitTask);
|
||||
(void)vnodeAWait(&pVnode->commitTask);
|
||||
|
||||
code = syncNodeGetConfig(pVnode->sync, &pVnode->config.syncCfg);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
@ -285,7 +285,7 @@ static int32_t vnodePrepareCommit(SVnode *pVnode, SCommitInfo *pInfo) {
|
|||
pInfo->txn = metaGetTxn(pVnode->pMeta);
|
||||
|
||||
// save info
|
||||
vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN);
|
||||
(void)vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN);
|
||||
|
||||
vDebug("vgId:%d, save config while prepare commit", TD_VID(pVnode));
|
||||
code = vnodeSaveInfo(dir, &pInfo->info);
|
||||
|
@ -395,8 +395,8 @@ _exit:
|
|||
}
|
||||
|
||||
int vnodeSyncCommit(SVnode *pVnode) {
|
||||
vnodeAsyncCommit(pVnode);
|
||||
vnodeAWait(&pVnode->commitTask);
|
||||
(void)vnodeAsyncCommit(pVnode);
|
||||
(void)vnodeAWait(&pVnode->commitTask);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -416,9 +416,9 @@ static int vnodeCommitImpl(SCommitInfo *pInfo) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN);
|
||||
(void)vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN);
|
||||
|
||||
syncBeginSnapshot(pVnode->sync, pInfo->info.state.committed);
|
||||
(void)syncBeginSnapshot(pVnode->sync, pInfo->info.state.committed);
|
||||
|
||||
code = tsdbCommitBegin(pVnode->pTsdb, pInfo);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
@ -455,7 +455,7 @@ static int vnodeCommitImpl(SCommitInfo *pInfo) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
syncEndSnapshot(pVnode->sync);
|
||||
(void)syncEndSnapshot(pVnode->sync);
|
||||
|
||||
_exit:
|
||||
if (code) {
|
||||
|
@ -470,7 +470,7 @@ bool vnodeShouldRollback(SVnode *pVnode) {
|
|||
char tFName[TSDB_FILENAME_LEN] = {0};
|
||||
int32_t offset = 0;
|
||||
|
||||
vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, tFName, TSDB_FILENAME_LEN);
|
||||
(void)vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, tFName, TSDB_FILENAME_LEN);
|
||||
offset = strlen(tFName);
|
||||
snprintf(tFName + offset, TSDB_FILENAME_LEN - offset - 1, "%s%s", TD_DIRSEP, VND_INFO_FNAME_TMP);
|
||||
|
||||
|
@ -481,7 +481,7 @@ void vnodeRollback(SVnode *pVnode) {
|
|||
char tFName[TSDB_FILENAME_LEN] = {0};
|
||||
int32_t offset = 0;
|
||||
|
||||
vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, tFName, TSDB_FILENAME_LEN);
|
||||
(void)vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, tFName, TSDB_FILENAME_LEN);
|
||||
offset = strlen(tFName);
|
||||
snprintf(tFName + offset, TSDB_FILENAME_LEN - offset - 1, "%s%s", TD_DIRSEP, VND_INFO_FNAME_TMP);
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ int32_t vHashPut(SVHashTable* ht, void* obj) {
|
|||
}
|
||||
|
||||
if (ht->numEntries >= ht->numBuckets) {
|
||||
vHashRehash(ht, ht->numBuckets * 2);
|
||||
(void)vHashRehash(ht, ht->numBuckets * 2);
|
||||
bucketIndex = ht->hash(obj) % ht->numBuckets;
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ int32_t vHashDrop(SVHashTable* ht, const void* obj) {
|
|||
taosMemoryFree(tmp);
|
||||
ht->numEntries--;
|
||||
if (ht->numBuckets > VNODE_HASH_DEFAULT_NUM_BUCKETS && ht->numEntries < ht->numBuckets / 4) {
|
||||
vHashRehash(ht, ht->numBuckets / 2);
|
||||
(void)vHashRehash(ht, ht->numBuckets / 2);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ int vnodeInit(int nthreads) {
|
|||
|
||||
void vnodeCleanup() {
|
||||
if (atomic_val_compare_exchange_32(&VINIT, 1, 0) == 0) return;
|
||||
vnodeAsyncClose();
|
||||
(void)vnodeAsyncClose();
|
||||
walCleanUp();
|
||||
smaCleanUp();
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ int32_t vnodeCreate(const char *path, SVnodeCfg *pCfg, int32_t diskPrimary, STfs
|
|||
vError("vgId:%d, failed to prepare vnode dir since %s, path: %s", pCfg->vgId, strerror(errno), path);
|
||||
return TAOS_SYSTEM_ERROR(errno);
|
||||
}
|
||||
vnodeGetPrimaryDir(path, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN);
|
||||
(void)vnodeGetPrimaryDir(path, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN);
|
||||
|
||||
if (pCfg) {
|
||||
info.config = *pCfg;
|
||||
|
@ -88,7 +88,7 @@ int32_t vnodeAlterReplica(const char *path, SAlterVnodeReplicaReq *pReq, int32_t
|
|||
char dir[TSDB_FILENAME_LEN] = {0};
|
||||
int32_t ret = 0;
|
||||
|
||||
vnodeGetPrimaryDir(path, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN);
|
||||
(void)vnodeGetPrimaryDir(path, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN);
|
||||
|
||||
ret = vnodeLoadInfo(dir, &info);
|
||||
if (ret < 0) {
|
||||
|
@ -221,7 +221,7 @@ int32_t vnodeAlterHashRange(const char *srcPath, const char *dstPath, SAlterVnod
|
|||
char dir[TSDB_FILENAME_LEN] = {0};
|
||||
int32_t ret = 0;
|
||||
|
||||
vnodeGetPrimaryDir(srcPath, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN);
|
||||
(void)vnodeGetPrimaryDir(srcPath, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN);
|
||||
|
||||
ret = vnodeLoadInfo(dir, &info);
|
||||
if (ret < 0) {
|
||||
|
@ -283,7 +283,7 @@ int32_t vnodeRestoreVgroupId(const char *srcPath, const char *dstPath, int32_t s
|
|||
char dir[TSDB_FILENAME_LEN] = {0};
|
||||
int32_t code = 0;
|
||||
|
||||
vnodeGetPrimaryDir(dstPath, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN);
|
||||
(void)vnodeGetPrimaryDir(dstPath, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN);
|
||||
if (vnodeLoadInfo(dir, &info) == 0) {
|
||||
if (info.config.vgId != dstVgId) {
|
||||
vError("vgId:%d, unexpected vnode config.vgId:%d", dstVgId, info.config.vgId);
|
||||
|
@ -292,7 +292,7 @@ int32_t vnodeRestoreVgroupId(const char *srcPath, const char *dstPath, int32_t s
|
|||
return dstVgId;
|
||||
}
|
||||
|
||||
vnodeGetPrimaryDir(srcPath, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN);
|
||||
(void)vnodeGetPrimaryDir(srcPath, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN);
|
||||
if (vnodeLoadInfo(dir, &info) < 0) {
|
||||
vError("vgId:%d, failed to read vnode config from %s since %s", srcVgId, srcPath, tstrerror(terrno));
|
||||
return -1;
|
||||
|
@ -317,7 +317,7 @@ int32_t vnodeRestoreVgroupId(const char *srcPath, const char *dstPath, int32_t s
|
|||
|
||||
void vnodeDestroy(int32_t vgId, const char *path, STfs *pTfs, int32_t nodeId) {
|
||||
vInfo("path:%s is removed while destroy vnode", path);
|
||||
tfsRmdir(pTfs, path);
|
||||
(void)tfsRmdir(pTfs, path);
|
||||
|
||||
// int32_t nlevel = tfsGetLevel(pTfs);
|
||||
if (nodeId > 0 && vgId > 0 /*&& nlevel > 1*/ && tsS3Enabled) {
|
||||
|
@ -351,7 +351,7 @@ SVnode *vnodeOpen(const char *path, int32_t diskPrimary, STfs *pTfs, SMsgCb msgC
|
|||
vError("failed to open vnode from %s since %s. diskPrimary:%d", path, terrstr(), diskPrimary);
|
||||
return NULL;
|
||||
}
|
||||
vnodeGetPrimaryDir(path, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN);
|
||||
(void)vnodeGetPrimaryDir(path, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN);
|
||||
|
||||
info.config = vnodeCfgDefault;
|
||||
|
||||
|
@ -401,12 +401,12 @@ SVnode *vnodeOpen(const char *path, int32_t diskPrimary, STfs *pTfs, SMsgCb msgC
|
|||
pVnode->pTfs = pTfs;
|
||||
pVnode->diskPrimary = diskPrimary;
|
||||
pVnode->msgCb = msgCb;
|
||||
taosThreadMutexInit(&pVnode->lock, NULL);
|
||||
(void)taosThreadMutexInit(&pVnode->lock, NULL);
|
||||
pVnode->blocked = false;
|
||||
|
||||
tsem_init(&pVnode->syncSem, 0, 0);
|
||||
taosThreadMutexInit(&pVnode->mutex, NULL);
|
||||
taosThreadCondInit(&pVnode->poolNotEmpty, NULL);
|
||||
(void)taosThreadMutexInit(&pVnode->mutex, NULL);
|
||||
(void)taosThreadCondInit(&pVnode->poolNotEmpty, NULL);
|
||||
|
||||
if (vnodeAChannelInit(1, &pVnode->commitChannel) != 0) {
|
||||
vError("vgId:%d, failed to init commit channel", TD_VID(pVnode));
|
||||
|
@ -439,7 +439,7 @@ SVnode *vnodeOpen(const char *path, int32_t diskPrimary, STfs *pTfs, SMsgCb msgC
|
|||
|
||||
// open wal
|
||||
sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_WAL_DIR);
|
||||
taosRealPath(tdir, NULL, sizeof(tdir));
|
||||
(void)taosRealPath(tdir, NULL, sizeof(tdir));
|
||||
|
||||
pVnode->pWal = walOpen(tdir, &(pVnode->config.walCfg));
|
||||
if (pVnode->pWal == NULL) {
|
||||
|
@ -449,7 +449,7 @@ SVnode *vnodeOpen(const char *path, int32_t diskPrimary, STfs *pTfs, SMsgCb msgC
|
|||
|
||||
// open tq
|
||||
sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_TQ_DIR);
|
||||
taosRealPath(tdir, NULL, sizeof(tdir));
|
||||
(void)taosRealPath(tdir, NULL, sizeof(tdir));
|
||||
|
||||
// open query
|
||||
if (vnodeQueryOpen(pVnode)) {
|
||||
|
@ -502,7 +502,7 @@ SVnode *vnodeOpen(const char *path, int32_t diskPrimary, STfs *pTfs, SMsgCb msgC
|
|||
counter = taos_counter_new(VNODE_METRIC_SQL_COUNT, "counter for insert sql", label_count, sample_labels);
|
||||
vInfo("vgId:%d, new metric:%p", TD_VID(pVnode), counter);
|
||||
if (taos_collector_registry_register_metric(counter) == 1) {
|
||||
taos_counter_destroy(counter);
|
||||
(void)taos_counter_destroy(counter);
|
||||
counter = taos_collector_registry_get_metric(VNODE_METRIC_SQL_COUNT);
|
||||
vInfo("vgId:%d, get metric from registry:%p", TD_VID(pVnode), counter);
|
||||
}
|
||||
|
@ -516,10 +516,10 @@ _err:
|
|||
if (pVnode->pQuery) vnodeQueryClose(pVnode);
|
||||
if (pVnode->pTq) tqClose(pVnode->pTq);
|
||||
if (pVnode->pWal) walClose(pVnode->pWal);
|
||||
if (pVnode->pTsdb) tsdbClose(&pVnode->pTsdb);
|
||||
if (pVnode->pSma) smaClose(pVnode->pSma);
|
||||
if (pVnode->pMeta) metaClose(&pVnode->pMeta);
|
||||
if (pVnode->freeList) vnodeCloseBufPool(pVnode);
|
||||
if (pVnode->pTsdb) (void)tsdbClose(&pVnode->pTsdb);
|
||||
if (pVnode->pSma) (void)smaClose(pVnode->pSma);
|
||||
if (pVnode->pMeta) (void)metaClose(&pVnode->pMeta);
|
||||
if (pVnode->freeList) (void)vnodeCloseBufPool(pVnode);
|
||||
|
||||
taosMemoryFree(pVnode);
|
||||
return NULL;
|
||||
|
@ -534,22 +534,22 @@ void vnodePostClose(SVnode *pVnode) { vnodeSyncPostClose(pVnode); }
|
|||
|
||||
void vnodeClose(SVnode *pVnode) {
|
||||
if (pVnode) {
|
||||
vnodeAWait(&pVnode->commitTask);
|
||||
vnodeAChannelDestroy(&pVnode->commitChannel, true);
|
||||
(void)vnodeAWait(&pVnode->commitTask);
|
||||
(void)vnodeAChannelDestroy(&pVnode->commitChannel, true);
|
||||
vnodeSyncClose(pVnode);
|
||||
vnodeQueryClose(pVnode);
|
||||
tqClose(pVnode->pTq);
|
||||
walClose(pVnode->pWal);
|
||||
if (pVnode->pTsdb) tsdbClose(&pVnode->pTsdb);
|
||||
smaClose(pVnode->pSma);
|
||||
(void)smaClose(pVnode->pSma);
|
||||
if (pVnode->pMeta) metaClose(&pVnode->pMeta);
|
||||
vnodeCloseBufPool(pVnode);
|
||||
(void)vnodeCloseBufPool(pVnode);
|
||||
|
||||
// destroy handle
|
||||
tsem_destroy(&pVnode->syncSem);
|
||||
taosThreadCondDestroy(&pVnode->poolNotEmpty);
|
||||
taosThreadMutexDestroy(&pVnode->mutex);
|
||||
taosThreadMutexDestroy(&pVnode->lock);
|
||||
(void)taosThreadMutexDestroy(&pVnode->mutex);
|
||||
(void)taosThreadMutexDestroy(&pVnode->lock);
|
||||
taosMemoryFree(pVnode);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -209,7 +209,7 @@ static void vnodeSnapReaderDestroyTsdbRanges(SVSnapReader *pReader) {
|
|||
for (int32_t j = 0; j < TSDB_RETENTION_MAX; ++j) {
|
||||
TFileSetRangeArray **ppRanges = vnodeSnapReaderGetTsdbRanges(pReader, tsdbTyps[j]);
|
||||
if (ppRanges == NULL) continue;
|
||||
tsdbTFileSetRangeArrayDestroy(ppRanges);
|
||||
(void)tsdbTFileSetRangeArrayDestroy(ppRanges);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -218,15 +218,15 @@ void vnodeSnapReaderClose(SVSnapReader *pReader) {
|
|||
vnodeSnapReaderDestroyTsdbRanges(pReader);
|
||||
|
||||
if (pReader->pRsmaReader) {
|
||||
rsmaSnapReaderClose(&pReader->pRsmaReader);
|
||||
(void)rsmaSnapReaderClose(&pReader->pRsmaReader);
|
||||
}
|
||||
|
||||
if (pReader->pTsdbReader) {
|
||||
tsdbSnapReaderClose(&pReader->pTsdbReader);
|
||||
(void)tsdbSnapReaderClose(&pReader->pTsdbReader);
|
||||
}
|
||||
|
||||
if (pReader->pTsdbRAWReader) {
|
||||
tsdbSnapRAWReaderClose(&pReader->pTsdbRAWReader);
|
||||
(void)tsdbSnapRAWReaderClose(&pReader->pTsdbRAWReader);
|
||||
}
|
||||
|
||||
if (pReader->pMetaReader) {
|
||||
|
@ -260,7 +260,7 @@ int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData)
|
|||
char fName[TSDB_FILENAME_LEN];
|
||||
int32_t offset = 0;
|
||||
|
||||
vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, fName, TSDB_FILENAME_LEN);
|
||||
(void)vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, fName, TSDB_FILENAME_LEN);
|
||||
offset = strlen(fName);
|
||||
snprintf(fName + offset, TSDB_FILENAME_LEN - offset - 1, "%s%s", TD_DIRSEP, VND_INFO_FNAME);
|
||||
|
||||
|
@ -272,13 +272,13 @@ int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData)
|
|||
|
||||
int64_t size;
|
||||
if (taosFStatFile(pFile, &size, NULL) < 0) {
|
||||
taosCloseFile(&pFile);
|
||||
(void)taosCloseFile(&pFile);
|
||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
|
||||
}
|
||||
|
||||
*ppData = taosMemoryMalloc(sizeof(SSnapDataHdr) + size + 1);
|
||||
if (*ppData == NULL) {
|
||||
taosCloseFile(&pFile);
|
||||
(void)taosCloseFile(&pFile);
|
||||
TSDB_CHECK_CODE(code = TSDB_CODE_OUT_OF_MEMORY, lino, _exit);
|
||||
}
|
||||
((SSnapDataHdr *)(*ppData))->type = SNAP_DATA_CFG;
|
||||
|
@ -287,11 +287,11 @@ int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData)
|
|||
|
||||
if (taosReadFile(pFile, ((SSnapDataHdr *)(*ppData))->data, size) < 0) {
|
||||
taosMemoryFree(*ppData);
|
||||
taosCloseFile(&pFile);
|
||||
(void)taosCloseFile(&pFile);
|
||||
TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit);
|
||||
}
|
||||
|
||||
taosCloseFile(&pFile);
|
||||
(void)taosCloseFile(&pFile);
|
||||
|
||||
pReader->cfgDone = 1;
|
||||
goto _exit;
|
||||
|
@ -590,15 +590,15 @@ extern int32_t tsdbDisableAndCancelAllBgTask(STsdb *pTsdb);
|
|||
extern int32_t tsdbEnableBgTask(STsdb *pTsdb);
|
||||
|
||||
static int32_t vnodeCancelAndDisableAllBgTask(SVnode *pVnode) {
|
||||
tsdbDisableAndCancelAllBgTask(pVnode->pTsdb);
|
||||
vnodeSyncCommit(pVnode);
|
||||
vnodeAChannelDestroy(&pVnode->commitChannel, true);
|
||||
(void)tsdbDisableAndCancelAllBgTask(pVnode->pTsdb);
|
||||
(void)vnodeSyncCommit(pVnode);
|
||||
(void)vnodeAChannelDestroy(&pVnode->commitChannel, true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t vnodeEnableBgTask(SVnode *pVnode) {
|
||||
tsdbEnableBgTask(pVnode->pTsdb);
|
||||
vnodeAChannelInit(1, &pVnode->commitChannel);
|
||||
(void)tsdbEnableBgTask(pVnode->pTsdb);
|
||||
(void)vnodeAChannelInit(1, &pVnode->commitChannel);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -646,7 +646,7 @@ static void vnodeSnapWriterDestroyTsdbRanges(SVSnapWriter *pWriter) {
|
|||
for (int32_t j = 0; j < TSDB_RETENTION_MAX; ++j) {
|
||||
TFileSetRangeArray **ppRanges = vnodeSnapWriterGetTsdbRanges(pWriter, tsdbTyps[j]);
|
||||
if (ppRanges == NULL) continue;
|
||||
tsdbTFileSetRangeArrayDestroy(ppRanges);
|
||||
(void)tsdbTFileSetRangeArrayDestroy(ppRanges);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -658,15 +658,15 @@ int32_t vnodeSnapWriterClose(SVSnapWriter *pWriter, int8_t rollback, SSnapshot *
|
|||
|
||||
// prepare
|
||||
if (pWriter->pTsdbSnapWriter) {
|
||||
tsdbSnapWriterPrepareClose(pWriter->pTsdbSnapWriter);
|
||||
(void)tsdbSnapWriterPrepareClose(pWriter->pTsdbSnapWriter);
|
||||
}
|
||||
|
||||
if (pWriter->pTsdbSnapRAWWriter) {
|
||||
tsdbSnapRAWWriterPrepareClose(pWriter->pTsdbSnapRAWWriter);
|
||||
(void)tsdbSnapRAWWriterPrepareClose(pWriter->pTsdbSnapRAWWriter);
|
||||
}
|
||||
|
||||
if (pWriter->pRsmaSnapWriter) {
|
||||
rsmaSnapWriterPrepareClose(pWriter->pRsmaSnapWriter);
|
||||
(void)rsmaSnapWriterPrepareClose(pWriter->pRsmaSnapWriter);
|
||||
}
|
||||
|
||||
// commit json
|
||||
|
@ -681,7 +681,7 @@ int32_t vnodeSnapWriterClose(SVSnapWriter *pWriter, int8_t rollback, SSnapshot *
|
|||
.applyTerm = pWriter->info.state.commitTerm};
|
||||
pVnode->statis = pWriter->info.statis;
|
||||
char dir[TSDB_FILENAME_LEN] = {0};
|
||||
vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN);
|
||||
(void)vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN);
|
||||
|
||||
code = vnodeCommitInfo(dir);
|
||||
if (code) goto _exit;
|
||||
|
@ -740,7 +740,7 @@ int32_t vnodeSnapWriterClose(SVSnapWriter *pWriter, int8_t rollback, SSnapshot *
|
|||
if (code) goto _exit;
|
||||
}
|
||||
|
||||
vnodeBegin(pVnode);
|
||||
(void)vnodeBegin(pVnode);
|
||||
|
||||
_exit:
|
||||
if (code) {
|
||||
|
@ -768,7 +768,7 @@ static int32_t vnodeSnapWriteInfo(SVSnapWriter *pWriter, uint8_t *pData, uint32_
|
|||
|
||||
// modify info as needed
|
||||
char dir[TSDB_FILENAME_LEN] = {0};
|
||||
vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN);
|
||||
(void)vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN);
|
||||
|
||||
SVnodeStats vndStats = pWriter->info.config.vndStats;
|
||||
pWriter->info.config = pVnode->config;
|
||||
|
|
|
@ -207,7 +207,7 @@ static int32_t vnodePreProcessDropTtlMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
||||
tSerializeSVDropTtlTableReq((char *)pContNew + sizeof(SMsgHead), reqLenNew, &ttlReq);
|
||||
(void)tSerializeSVDropTtlTableReq((char *)pContNew + sizeof(SMsgHead), reqLenNew, &ttlReq);
|
||||
pContNew->contLen = htonl(reqLenNew);
|
||||
pContNew->vgId = pContOld->vgId;
|
||||
|
||||
|
@ -422,7 +422,7 @@ static int32_t vnodePreProcessDeleteMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
((SMsgHead *)pCont)->vgId = TD_VID(pVnode);
|
||||
|
||||
tEncoderInit(pCoder, pCont + sizeof(SMsgHead), size);
|
||||
tEncodeDeleteRes(pCoder, &res);
|
||||
(void)tEncodeDeleteRes(pCoder, &res);
|
||||
tEncoderClear(pCoder);
|
||||
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
|
@ -632,7 +632,7 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t ver, SRpcMsg
|
|||
} break;
|
||||
case TDMT_STREAM_CONSEN_CHKPT: {
|
||||
if (pVnode->restored) {
|
||||
tqProcessTaskConsenChkptIdReq(pVnode->pTq, pMsg);
|
||||
(void)tqProcessTaskConsenChkptIdReq(pVnode->pTq, pMsg);
|
||||
}
|
||||
} break;
|
||||
case TDMT_STREAM_TASK_PAUSE: {
|
||||
|
@ -649,7 +649,7 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t ver, SRpcMsg
|
|||
} break;
|
||||
case TDMT_VND_STREAM_TASK_RESET: {
|
||||
if (pVnode->restored && vnodeIsLeader(pVnode)) {
|
||||
tqProcessTaskResetReq(pVnode->pTq, pMsg);
|
||||
(void)tqProcessTaskResetReq(pVnode->pTq, pMsg);
|
||||
}
|
||||
} break;
|
||||
case TDMT_VND_ALTER_CONFIRM:
|
||||
|
@ -871,7 +871,7 @@ int32_t vnodeProcessStreamMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo)
|
|||
}
|
||||
|
||||
void smaHandleRes(void *pVnode, int64_t smaId, const SArray *data) {
|
||||
tdProcessTSmaInsert(((SVnode *)pVnode)->pSma, smaId, (const char *)data);
|
||||
(void)tdProcessTSmaInsert(((SVnode *)pVnode)->pSma, smaId, (const char *)data);
|
||||
}
|
||||
|
||||
void vnodeUpdateMetaRsp(SVnode *pVnode, STableMetaRsp *pMetaRsp) {
|
||||
|
@ -942,7 +942,7 @@ static int32_t vnodeProcessDropTtlTbReq(SVnode *pVnode, int64_t ver, void *pReq,
|
|||
int ret = 0;
|
||||
if (ttlReq.nUids > 0) {
|
||||
metaDropTables(pVnode->pMeta, ttlReq.pTbUids);
|
||||
tqUpdateTbUidList(pVnode->pTq, ttlReq.pTbUids, false);
|
||||
(void)tqUpdateTbUidList(pVnode->pTq, ttlReq.pTbUids, false);
|
||||
}
|
||||
|
||||
end:
|
||||
|
@ -1142,7 +1142,7 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq,
|
|||
}
|
||||
} else {
|
||||
cRsp.code = TSDB_CODE_SUCCESS;
|
||||
tdFetchTbUidList(pVnode->pSma, &pStore, pCreateReq->ctb.suid, pCreateReq->uid);
|
||||
(void)tdFetchTbUidList(pVnode->pSma, &pStore, pCreateReq->ctb.suid, pCreateReq->uid);
|
||||
if (taosArrayPush(tbUids, &pCreateReq->uid) == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
rcode = -1;
|
||||
|
@ -1159,11 +1159,11 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq,
|
|||
}
|
||||
|
||||
vDebug("vgId:%d, add %d new created tables into query table list", TD_VID(pVnode), (int32_t)taosArrayGetSize(tbUids));
|
||||
tqUpdateTbUidList(pVnode->pTq, tbUids, true);
|
||||
(void)tqUpdateTbUidList(pVnode->pTq, tbUids, true);
|
||||
if (tdUpdateTbUidList(pVnode->pSma, pStore, true) < 0) {
|
||||
goto _exit;
|
||||
}
|
||||
tdUidStoreFree(pStore);
|
||||
(void)tdUidStoreFree(pStore);
|
||||
|
||||
// prepare rsp
|
||||
int32_t ret = 0;
|
||||
|
@ -1175,13 +1175,13 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq,
|
|||
goto _exit;
|
||||
}
|
||||
tEncoderInit(&encoder, pRsp->pCont, pRsp->contLen);
|
||||
tEncodeSVCreateTbBatchRsp(&encoder, &rsp);
|
||||
(void)tEncodeSVCreateTbBatchRsp(&encoder, &rsp);
|
||||
|
||||
if (tsEnableAudit && tsEnableAuditCreateTable) {
|
||||
int64_t clusterId = pVnode->config.syncCfg.nodeInfo[0].clusterId;
|
||||
|
||||
SName name = {0};
|
||||
tNameFromString(&name, pVnode->config.dbname, T_NAME_ACCT | T_NAME_DB);
|
||||
(void)tNameFromString(&name, pVnode->config.dbname, T_NAME_ACCT | T_NAME_DB);
|
||||
|
||||
SStringBuilder sb = {0};
|
||||
for (int32_t i = 0; i < tbNames->size; i++) {
|
||||
|
@ -1329,7 +1329,7 @@ _exit:
|
|||
tEncodeSize(tEncodeSVAlterTbRsp, &vAlterTbRsp, pRsp->contLen, ret);
|
||||
pRsp->pCont = rpcMallocCont(pRsp->contLen);
|
||||
tEncoderInit(&ec, pRsp->pCont, pRsp->contLen);
|
||||
tEncodeSVAlterTbRsp(&ec, &vAlterTbRsp);
|
||||
(void)tEncodeSVAlterTbRsp(&ec, &vAlterTbRsp);
|
||||
tEncoderClear(&ec);
|
||||
if (vMetaRsp.pSchemas) {
|
||||
taosMemoryFree(vMetaRsp.pSchemas);
|
||||
|
@ -1384,7 +1384,7 @@ static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t ver, void *pReq, in
|
|||
}
|
||||
} else {
|
||||
dropTbRsp.code = TSDB_CODE_SUCCESS;
|
||||
if (tbUid > 0) tdFetchTbUidList(pVnode->pSma, &pStore, pDropTbReq->suid, tbUid);
|
||||
if (tbUid > 0) (void)tdFetchTbUidList(pVnode->pSma, &pStore, pDropTbReq->suid, tbUid);
|
||||
}
|
||||
|
||||
if (taosArrayPush(rsp.pArray, &dropTbRsp) == NULL) {
|
||||
|
@ -1404,14 +1404,14 @@ static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t ver, void *pReq, in
|
|||
}
|
||||
}
|
||||
|
||||
tqUpdateTbUidList(pVnode->pTq, tbUids, false);
|
||||
(void)tqUpdateTbUidList(pVnode->pTq, tbUids, false);
|
||||
tdUpdateTbUidList(pVnode->pSma, pStore, false);
|
||||
|
||||
if (tsEnableAuditCreateTable) {
|
||||
int64_t clusterId = pVnode->config.syncCfg.nodeInfo[0].clusterId;
|
||||
|
||||
SName name = {0};
|
||||
tNameFromString(&name, pVnode->config.dbname, T_NAME_ACCT | T_NAME_DB);
|
||||
(void)tNameFromString(&name, pVnode->config.dbname, T_NAME_ACCT | T_NAME_DB);
|
||||
|
||||
SStringBuilder sb = {0};
|
||||
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
|
||||
|
@ -1435,7 +1435,7 @@ static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t ver, void *pReq, in
|
|||
|
||||
_exit:
|
||||
taosArrayDestroy(tbUids);
|
||||
tdUidStoreFree(pStore);
|
||||
(void)tdUidStoreFree(pStore);
|
||||
tDecoderClear(&decoder);
|
||||
tEncodeSize(tEncodeSVDropTbBatchRsp, &rsp, pRsp->contLen, ret);
|
||||
pRsp->pCont = rpcMallocCont(pRsp->contLen);
|
||||
|
@ -1876,7 +1876,7 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t ver, void *pReq, in
|
|||
if (taosArrayGetSize(newTbUids) > 0) {
|
||||
vDebug("vgId:%d, add %d table into query table list in handling submit", TD_VID(pVnode),
|
||||
(int32_t)taosArrayGetSize(newTbUids));
|
||||
tqUpdateTbUidList(pVnode->pTq, newTbUids, true);
|
||||
(void)tqUpdateTbUidList(pVnode->pTq, newTbUids, true);
|
||||
}
|
||||
|
||||
_exit:
|
||||
|
@ -1885,13 +1885,13 @@ _exit:
|
|||
tEncodeSize(tEncodeSSubmitRsp2, pSubmitRsp, pRsp->contLen, ret);
|
||||
pRsp->pCont = rpcMallocCont(pRsp->contLen);
|
||||
tEncoderInit(&ec, pRsp->pCont, pRsp->contLen);
|
||||
tEncodeSSubmitRsp2(&ec, pSubmitRsp);
|
||||
(void)tEncodeSSubmitRsp2(&ec, pSubmitRsp);
|
||||
tEncoderClear(&ec);
|
||||
|
||||
// update statistics
|
||||
atomic_add_fetch_64(&pVnode->statis.nInsert, pSubmitRsp->affectedRows);
|
||||
atomic_add_fetch_64(&pVnode->statis.nInsertSuccess, pSubmitRsp->affectedRows);
|
||||
atomic_add_fetch_64(&pVnode->statis.nBatchInsert, 1);
|
||||
(void)atomic_add_fetch_64(&pVnode->statis.nInsert, pSubmitRsp->affectedRows);
|
||||
(void)atomic_add_fetch_64(&pVnode->statis.nInsertSuccess, pSubmitRsp->affectedRows);
|
||||
(void)atomic_add_fetch_64(&pVnode->statis.nBatchInsert, 1);
|
||||
|
||||
if (tsEnableMonitor && pSubmitRsp->affectedRows > 0 && strlen(pOriginalMsg->info.conn.user) > 0) {
|
||||
const char *sample_labels[] = {VNODE_METRIC_TAG_VALUE_INSERT_AFFECTED_ROWS,
|
||||
|
@ -1901,11 +1901,11 @@ _exit:
|
|||
pVnode->monitor.strVgId,
|
||||
pOriginalMsg->info.conn.user,
|
||||
"Success"};
|
||||
taos_counter_add(pVnode->monitor.insertCounter, pSubmitRsp->affectedRows, sample_labels);
|
||||
(void)taos_counter_add(pVnode->monitor.insertCounter, pSubmitRsp->affectedRows, sample_labels);
|
||||
}
|
||||
|
||||
if (code == 0) {
|
||||
atomic_add_fetch_64(&pVnode->statis.nBatchInsertSuccess, 1);
|
||||
(void)atomic_add_fetch_64(&pVnode->statis.nBatchInsertSuccess, 1);
|
||||
code = tdProcessRSmaSubmit(pVnode->pSma, ver, pSubmitReq, pReq, len);
|
||||
}
|
||||
/*
|
||||
|
@ -2125,10 +2125,10 @@ static int32_t vnodeProcessAlterConfigReq(SVnode *pVnode, int64_t ver, void *pRe
|
|||
if (req.sttTrigger > 1 && pVnode->config.sttTrigger > 1) {
|
||||
pVnode->config.sttTrigger = req.sttTrigger;
|
||||
} else {
|
||||
vnodeAWait(&pVnode->commitTask);
|
||||
tsdbDisableAndCancelAllBgTask(pVnode->pTsdb);
|
||||
(void)vnodeAWait(&pVnode->commitTask);
|
||||
(void)tsdbDisableAndCancelAllBgTask(pVnode->pTsdb);
|
||||
pVnode->config.sttTrigger = req.sttTrigger;
|
||||
tsdbEnableBgTask(pVnode->pTsdb);
|
||||
(void)tsdbEnableBgTask(pVnode->pTsdb);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2144,11 +2144,11 @@ static int32_t vnodeProcessAlterConfigReq(SVnode *pVnode, int64_t ver, void *pRe
|
|||
}
|
||||
|
||||
if (walChanged) {
|
||||
walAlter(pVnode->pWal, &pVnode->config.walCfg);
|
||||
(void)walAlter(pVnode->pWal, &pVnode->config.walCfg);
|
||||
}
|
||||
|
||||
if (tsdbChanged) {
|
||||
tsdbSetKeepCfg(pVnode->pTsdb, &pVnode->config.tsdbCfg);
|
||||
(void)tsdbSetKeepCfg(pVnode->pTsdb, &pVnode->config.tsdbCfg);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -2220,7 +2220,8 @@ static int32_t vnodeProcessDeleteReq(SVnode *pVnode, int64_t ver, void *pReq, in
|
|||
}
|
||||
|
||||
tDecoderInit(pCoder, pReq, len);
|
||||
tDecodeDeleteRes(pCoder, pRes);
|
||||
code = tDecodeDeleteRes(pCoder, pRes);
|
||||
if (code) goto _err;
|
||||
|
||||
if (pRes->affectedRows > 0) {
|
||||
for (int32_t iUid = 0; iUid < taosArrayGetSize(pRes->uidList); iUid++) {
|
||||
|
@ -2243,7 +2244,8 @@ static int32_t vnodeProcessDeleteReq(SVnode *pVnode, int64_t ver, void *pReq, in
|
|||
pRsp->pCont = rpcMallocCont(pRsp->contLen);
|
||||
SEncoder ec = {0};
|
||||
tEncoderInit(&ec, pRsp->pCont, pRsp->contLen);
|
||||
tEncodeSVDeleteRsp(&ec, &rsp);
|
||||
code = tEncodeSVDeleteRsp(&ec, &rsp);
|
||||
if (code) goto _err;
|
||||
tEncoderClear(&ec);
|
||||
return code;
|
||||
|
||||
|
@ -2325,7 +2327,7 @@ static int32_t vnodeProcessCompactVnodeReq(SVnode *pVnode, int64_t ver, void *pR
|
|||
}
|
||||
|
||||
static int32_t vnodeProcessConfigChangeReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
||||
syncCheckMember(pVnode->sync);
|
||||
(void)syncCheckMember(pVnode->sync);
|
||||
|
||||
pRsp->msgType = TDMT_SYNC_CONFIG_CHANGE_RSP;
|
||||
pRsp->code = TSDB_CODE_SUCCESS;
|
||||
|
|
|
@ -28,7 +28,7 @@ static inline void vnodeWaitBlockMsg(SVnode *pVnode, const SRpcMsg *pMsg) {
|
|||
const STraceId *trace = &pMsg->info.traceId;
|
||||
vGTrace("vgId:%d, msg:%p wait block, type:%s sec:%d seq:%" PRId64, pVnode->config.vgId, pMsg,
|
||||
TMSG_INFO(pMsg->msgType), pVnode->blockSec, pVnode->blockSeq);
|
||||
tsem_wait(&pVnode->syncSem);
|
||||
(void)tsem_wait(&pVnode->syncSem);
|
||||
}
|
||||
|
||||
static inline void vnodePostBlockMsg(SVnode *pVnode, const SRpcMsg *pMsg) {
|
||||
|
@ -41,7 +41,7 @@ static inline void vnodePostBlockMsg(SVnode *pVnode, const SRpcMsg *pMsg) {
|
|||
pVnode->blocked = false;
|
||||
pVnode->blockSec = 0;
|
||||
pVnode->blockSeq = 0;
|
||||
tsem_post(&pVnode->syncSem);
|
||||
(void)tsem_post(&pVnode->syncSem);
|
||||
}
|
||||
(void)taosThreadMutexUnlock(&pVnode->lock);
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ void vnodeRedirectRpcMsg(SVnode *pVnode, SRpcMsg *pMsg, int32_t code) {
|
|||
if (rsp.pCont == NULL) {
|
||||
pMsg->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
} else {
|
||||
tSerializeSEpSet(rsp.pCont, contLen, &newEpSet);
|
||||
(void)tSerializeSEpSet(rsp.pCont, contLen, &newEpSet);
|
||||
rsp.contLen = contLen;
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ void vnodeProposeCommitOnNeed(SVnode *pVnode, bool atExit) {
|
|||
rpcFreeCont(rpcMsg.pCont);
|
||||
rpcMsg.pCont = NULL;
|
||||
} else {
|
||||
tmsgPutToQueue(&pVnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||
(void)tmsgPutToQueue(&pVnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -556,7 +556,7 @@ static void vnodeRestoreFinish(const SSyncFSM *pFsm, const SyncIndex commitIdx)
|
|||
} while (true);
|
||||
|
||||
ASSERT(commitIdx == vnodeSyncAppliedIndex(pFsm));
|
||||
walApplyVer(pVnode->pWal, commitIdx);
|
||||
(void)walApplyVer(pVnode->pWal, commitIdx);
|
||||
pVnode->restored = true;
|
||||
|
||||
SStreamMeta *pMeta = pVnode->pTq->pStreamMeta;
|
||||
|
@ -602,13 +602,13 @@ static void vnodeBecomeFollower(const SSyncFSM *pFsm) {
|
|||
if (pVnode->blocked) {
|
||||
pVnode->blocked = false;
|
||||
vDebug("vgId:%d, become follower and post block", pVnode->config.vgId);
|
||||
tsem_post(&pVnode->syncSem);
|
||||
(void)tsem_post(&pVnode->syncSem);
|
||||
}
|
||||
(void)taosThreadMutexUnlock(&pVnode->lock);
|
||||
|
||||
if (pVnode->pTq) {
|
||||
tqUpdateNodeStage(pVnode->pTq, false);
|
||||
tqStopStreamTasksAsync(pVnode->pTq);
|
||||
(void)tqStopStreamTasksAsync(pVnode->pTq);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -620,7 +620,7 @@ static void vnodeBecomeLearner(const SSyncFSM *pFsm) {
|
|||
if (pVnode->blocked) {
|
||||
pVnode->blocked = false;
|
||||
vDebug("vgId:%d, become learner and post block", pVnode->config.vgId);
|
||||
tsem_post(&pVnode->syncSem);
|
||||
(void)tsem_post(&pVnode->syncSem);
|
||||
}
|
||||
(void)taosThreadMutexUnlock(&pVnode->lock);
|
||||
}
|
||||
|
@ -743,14 +743,14 @@ int32_t vnodeSyncStart(SVnode *pVnode) {
|
|||
|
||||
void vnodeSyncPreClose(SVnode *pVnode) {
|
||||
vInfo("vgId:%d, sync pre close", pVnode->config.vgId);
|
||||
syncLeaderTransfer(pVnode->sync);
|
||||
(void)syncLeaderTransfer(pVnode->sync);
|
||||
syncPreStop(pVnode->sync);
|
||||
|
||||
(void)taosThreadMutexLock(&pVnode->lock);
|
||||
if (pVnode->blocked) {
|
||||
vInfo("vgId:%d, post block after close sync", pVnode->config.vgId);
|
||||
pVnode->blocked = false;
|
||||
tsem_post(&pVnode->syncSem);
|
||||
(void)tsem_post(&pVnode->syncSem);
|
||||
}
|
||||
(void)taosThreadMutexUnlock(&pVnode->lock);
|
||||
}
|
||||
|
@ -785,7 +785,7 @@ void vnodeSyncCheckTimeout(SVnode *pVnode) {
|
|||
pVnode->blocked = false;
|
||||
pVnode->blockSec = 0;
|
||||
pVnode->blockSeq = 0;
|
||||
tsem_post(&pVnode->syncSem);
|
||||
(void)tsem_post(&pVnode->syncSem);
|
||||
}
|
||||
}
|
||||
(void)taosThreadMutexUnlock(&pVnode->lock);
|
||||
|
|
|
@ -1002,7 +1002,7 @@ int32_t doDeleteTimeWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock, S
|
|||
|
||||
int32_t getNextQualifiedWindow(SInterval* pInterval, STimeWindow* pNext, SDataBlockInfo* pDataBlockInfo,
|
||||
TSKEY* primaryKeys, int32_t prevPosition, int32_t order);
|
||||
void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoData* p, int32_t status);
|
||||
int32_t extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoData* p, int32_t status);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -295,7 +295,7 @@ qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* pReaderHandle, int3
|
|||
return NULL;
|
||||
}
|
||||
|
||||
createRawScanOperatorInfo(pReaderHandle, pTaskInfo, &pTaskInfo->pRoot);
|
||||
code = createRawScanOperatorInfo(pReaderHandle, pTaskInfo, &pTaskInfo->pRoot);
|
||||
if (NULL == pTaskInfo->pRoot || code != 0) {
|
||||
taosMemoryFree(pTaskInfo);
|
||||
return NULL;
|
||||
|
@ -1160,7 +1160,12 @@ SMqBatchMetaRsp* qStreamExtractMetaMsg(qTaskInfo_t tinfo) {
|
|||
|
||||
void qStreamExtractOffset(qTaskInfo_t tinfo, STqOffsetVal* pOffset) {
|
||||
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
|
||||
tOffsetCopy(pOffset, &pTaskInfo->streamInfo.currentOffset);
|
||||
int32_t code = tOffsetCopy(pOffset, &pTaskInfo->streamInfo.currentOffset);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
|
||||
pTaskInfo->code = code;
|
||||
T_LONG_JMP(pTaskInfo->env, code);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t initQueryTableDataCondForTmq(SQueryTableDataCond* pCond, SSnapContext* sContext, SMetaTableInfo* pMtInfo) {
|
||||
|
@ -1231,7 +1236,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
|||
}
|
||||
|
||||
if (subType == TOPIC_SUB_TYPE__COLUMN) {
|
||||
extractOperatorInTree(pOperator, QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN, id, &pOperator);
|
||||
code = extractOperatorInTree(pOperator, QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN, id, &pOperator);
|
||||
if (pOperator == NULL || code != 0) {
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ static UNUSED_FUNC void* u_realloc(void* p, size_t __size) {
|
|||
static int32_t setBlockSMAInfo(SqlFunctionCtx* pCtx, SExprInfo* pExpr, SSDataBlock* pBlock);
|
||||
|
||||
static int32_t initCtxOutputBuffer(SqlFunctionCtx* pCtx, int32_t size);
|
||||
static void doApplyScalarCalculation(SOperatorInfo* pOperator, SSDataBlock* pBlock, int32_t order, int32_t scanFlag);
|
||||
static void doApplyScalarCalculation(SOperatorInfo* pOperator, SSDataBlock* pBlock, int32_t order, int32_t scanFlag);
|
||||
|
||||
static int32_t doSetInputDataBlock(SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t order, int32_t scanFlag,
|
||||
bool createDummyCol);
|
||||
|
@ -193,7 +193,7 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR
|
|||
// add a new result set for a new group
|
||||
SResultRowPosition pos = {.pageId = pResult->pageId, .offset = pResult->offset};
|
||||
int32_t code = tSimpleHashPut(pSup->pResultRowHashTable, pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes), &pos,
|
||||
sizeof(SResultRowPosition));
|
||||
sizeof(SResultRowPosition));
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
|
||||
T_LONG_JMP(pTaskInfo->env, code);
|
||||
|
@ -522,7 +522,7 @@ int32_t setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t n
|
|||
if (!pResInfo->initialized) {
|
||||
if (pCtx[i].functionId != -1) {
|
||||
int32_t code = pCtx[i].fpSet.init(&pCtx[i], pResInfo);
|
||||
if (code != TSDB_CODE_SUCCESS && fmIsUserDefinedFunc(pCtx[i].functionId)){
|
||||
if (code != TSDB_CODE_SUCCESS && fmIsUserDefinedFunc(pCtx[i].functionId)) {
|
||||
pResInfo->initialized = false;
|
||||
return TSDB_CODE_UDF_FUNC_EXEC_FAILURE;
|
||||
}
|
||||
|
@ -567,7 +567,8 @@ int32_t doFilter(SSDataBlock* pBlock, SFilterInfo* pFilterInfo, SColMatchInfo* p
|
|||
code = filterExecute(pFilterInfo, pBlock, &p, NULL, param1.numOfCols, &status);
|
||||
QUERY_CHECK_CODE(code, lino, _err);
|
||||
|
||||
extractQualifiedTupleByFilterResult(pBlock, p, status);
|
||||
code = extractQualifiedTupleByFilterResult(pBlock, p, status);
|
||||
QUERY_CHECK_CODE(code, lino, _err);
|
||||
|
||||
if (pColMatchInfo != NULL) {
|
||||
size_t size = taosArrayGetSize(pColMatchInfo->pList);
|
||||
|
@ -591,18 +592,20 @@ _err:
|
|||
return code;
|
||||
}
|
||||
|
||||
void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoData* p, int32_t status) {
|
||||
int32_t extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoData* p, int32_t status) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int8_t* pIndicator = (int8_t*)p->pData;
|
||||
if (status == FILTER_RESULT_ALL_QUALIFIED) {
|
||||
// here nothing needs to be done
|
||||
} else if (status == FILTER_RESULT_NONE_QUALIFIED) {
|
||||
trimDataBlock(pBlock, pBlock->info.rows, NULL);
|
||||
code = trimDataBlock(pBlock, pBlock->info.rows, NULL);
|
||||
pBlock->info.rows = 0;
|
||||
} else if (status == FILTER_RESULT_PARTIAL_QUALIFIED) {
|
||||
trimDataBlock(pBlock, pBlock->info.rows, (bool*)pIndicator);
|
||||
code = trimDataBlock(pBlock, pBlock->info.rows, (bool*)pIndicator);
|
||||
} else {
|
||||
qError("unknown filter result type: %d", status);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
void doUpdateNumOfRows(SqlFunctionCtx* pCtx, SResultRow* pRow, int32_t numOfExprs, const int32_t* rowEntryOffset) {
|
||||
|
@ -639,7 +642,7 @@ void copyResultrowToDataBlock(SExprInfo* pExprInfo, int32_t numOfExprs, SResultR
|
|||
pCtx[j].resultInfo = getResultEntryInfo(pRow, j, rowEntryOffset);
|
||||
if (pCtx[j].fpSet.finalize) {
|
||||
if (strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_group_key") == 0 ||
|
||||
strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_group_const_value") == 0) {
|
||||
strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_group_const_value") == 0) {
|
||||
// for groupkey along with functions that output multiple lines(e.g. Histogram)
|
||||
// need to match groupkey result for each output row of that function.
|
||||
if (pCtx[j].resultInfo->numOfRes != 0) {
|
||||
|
@ -678,7 +681,7 @@ _end:
|
|||
|
||||
// todo refactor. SResultRow has direct pointer in miainfo
|
||||
void finalizeResultRows(SDiskbasedBuf* pBuf, SResultRowPosition* resultRowPosition, SExprSupp* pSup,
|
||||
SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo) {
|
||||
SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo) {
|
||||
SFilePage* page = getBufPage(pBuf, resultRowPosition->pageId);
|
||||
if (page == NULL) {
|
||||
qError("failed to get buffer, code:%s, %s", tstrerror(terrno), GET_TASKID(pTaskInfo));
|
||||
|
@ -694,7 +697,7 @@ void finalizeResultRows(SDiskbasedBuf* pBuf, SResultRowPosition* resultRowPositi
|
|||
doUpdateNumOfRows(pCtx, pRow, pSup->numOfExprs, rowEntryOffset);
|
||||
if (pRow->numOfRows == 0) {
|
||||
releaseBufPage(pBuf, page);
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t size = pBlock->info.capacity;
|
||||
|
|
|
@ -308,7 +308,10 @@ int32_t mJoinFilterAndMarkHashRows(SSDataBlock* pBlock, SFilterInfo* pFilterInfo
|
|||
}
|
||||
}
|
||||
|
||||
extractQualifiedTupleByFilterResult(pBlock, p, status);
|
||||
code = extractQualifiedTupleByFilterResult(pBlock, p, status);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
code = TSDB_CODE_SUCCESS;
|
||||
|
||||
|
@ -375,7 +378,10 @@ int32_t mJoinFilterAndMarkRows(SSDataBlock* pBlock, SFilterInfo* pFilterInfo, SM
|
|||
}
|
||||
}
|
||||
|
||||
extractQualifiedTupleByFilterResult(pBlock, p, status);
|
||||
code = extractQualifiedTupleByFilterResult(pBlock, p, status);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _return;
|
||||
}
|
||||
|
||||
code = TSDB_CODE_SUCCESS;
|
||||
|
||||
|
|
|
@ -1311,7 +1311,8 @@ static void destroyTableScanOperatorInfo(void* param) {
|
|||
}
|
||||
|
||||
int32_t createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* readHandle,
|
||||
STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo, SOperatorInfo** pOptrInfo) {
|
||||
STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo,
|
||||
SOperatorInfo** pOptrInfo) {
|
||||
QRY_OPTR_CHECK(pOptrInfo);
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
@ -1404,7 +1405,7 @@ _error:
|
|||
int32_t createTableSeqScanOperatorInfo(void* pReadHandle, SExecTaskInfo* pTaskInfo, SOperatorInfo** pOptrInfo) {
|
||||
QRY_OPTR_CHECK(pOptrInfo);
|
||||
|
||||
int32_t code = 0;
|
||||
int32_t code = 0;
|
||||
STableScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STableScanInfo));
|
||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||
if (pInfo == NULL || pOperator == NULL) {
|
||||
|
@ -1422,7 +1423,7 @@ int32_t createTableSeqScanOperatorInfo(void* pReadHandle, SExecTaskInfo* pTaskIn
|
|||
*pOptrInfo = pOperator;
|
||||
return code;
|
||||
|
||||
_end:
|
||||
_end:
|
||||
if (pInfo != NULL) {
|
||||
taosMemoryFree(pInfo);
|
||||
}
|
||||
|
@ -2413,10 +2414,14 @@ _end:
|
|||
return code;
|
||||
}
|
||||
|
||||
static void doBlockDataWindowFilter(SSDataBlock* pBlock, int32_t tsIndex, STimeWindow* pWindow, const char* id) {
|
||||
static int32_t doBlockDataWindowFilter(SSDataBlock* pBlock, int32_t tsIndex, STimeWindow* pWindow, const char* id) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
bool* p = NULL;
|
||||
if (pWindow->skey != INT64_MIN || pWindow->ekey != INT64_MAX) {
|
||||
bool* p = taosMemoryCalloc(pBlock->info.rows, sizeof(bool));
|
||||
bool hasUnqualified = false;
|
||||
p = taosMemoryCalloc(pBlock->info.rows, sizeof(bool));
|
||||
QUERY_CHECK_NULL(p, code, lino, _end, terrno);
|
||||
bool hasUnqualified = false;
|
||||
|
||||
SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, tsIndex);
|
||||
|
||||
|
@ -2445,19 +2450,28 @@ static void doBlockDataWindowFilter(SSDataBlock* pBlock, int32_t tsIndex, STimeW
|
|||
}
|
||||
|
||||
if (hasUnqualified) {
|
||||
trimDataBlock(pBlock, pBlock->info.rows, p);
|
||||
code = trimDataBlock(pBlock, pBlock->info.rows, p);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
}
|
||||
|
||||
taosMemoryFree(p);
|
||||
}
|
||||
|
||||
_end:
|
||||
taosMemoryFree(p);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static void doBlockDataPrimaryKeyFilter(SSDataBlock* pBlock, STqOffsetVal* offset) {
|
||||
static int32_t doBlockDataPrimaryKeyFilter(SSDataBlock* pBlock, STqOffsetVal* offset) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
if (pBlock->info.window.skey != offset->ts || offset->primaryKey.type == 0) {
|
||||
return;
|
||||
return code;
|
||||
}
|
||||
bool* p = taosMemoryCalloc(pBlock->info.rows, sizeof(bool));
|
||||
bool hasUnqualified = false;
|
||||
QUERY_CHECK_NULL(p, code, lino, _end, terrno);
|
||||
bool hasUnqualified = false;
|
||||
|
||||
SColumnInfoData* pColTs = taosArrayGet(pBlock->pDataBlock, 0);
|
||||
SColumnInfoData* pColPk = taosArrayGet(pBlock->pDataBlock, 1);
|
||||
|
@ -2485,16 +2499,26 @@ static void doBlockDataPrimaryKeyFilter(SSDataBlock* pBlock, STqOffsetVal* offse
|
|||
}
|
||||
|
||||
if (hasUnqualified) {
|
||||
trimDataBlock(pBlock, pBlock->info.rows, p);
|
||||
code = trimDataBlock(pBlock, pBlock->info.rows, p);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
}
|
||||
|
||||
_end:
|
||||
taosMemoryFree(p);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
// re-build the delete block, ONLY according to the split timestamp
|
||||
static void rebuildDeleteBlockData(SSDataBlock* pBlock, STimeWindow* pWindow, const char* id) {
|
||||
static int32_t rebuildDeleteBlockData(SSDataBlock* pBlock, STimeWindow* pWindow, const char* id) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
int32_t numOfRows = pBlock->info.rows;
|
||||
bool* p = taosMemoryCalloc(numOfRows, sizeof(bool));
|
||||
QUERY_CHECK_NULL(p, code, lino, _end, terrno);
|
||||
|
||||
bool hasUnqualified = false;
|
||||
int64_t skey = pWindow->skey;
|
||||
int64_t ekey = pWindow->ekey;
|
||||
|
@ -2531,14 +2555,20 @@ static void rebuildDeleteBlockData(SSDataBlock* pBlock, STimeWindow* pWindow, co
|
|||
}
|
||||
|
||||
if (hasUnqualified) {
|
||||
trimDataBlock(pBlock, pBlock->info.rows, p);
|
||||
code = trimDataBlock(pBlock, pBlock->info.rows, p);
|
||||
qDebug("%s re-build delete datablock, start key revised to:%" PRId64 ", rows:%" PRId64, id, skey,
|
||||
pBlock->info.rows);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
} else {
|
||||
qDebug("%s not update the delete block", id);
|
||||
}
|
||||
|
||||
_end:
|
||||
taosMemoryFree(p);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t colIdComparFn(const void* param1, const void* param2) {
|
||||
|
@ -2657,7 +2687,8 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock
|
|||
}
|
||||
|
||||
// filter the block extracted from WAL files, according to the time window apply additional time window filter
|
||||
doBlockDataWindowFilter(pInfo->pRes, pInfo->primaryTsIndex, pTimeWindow, id);
|
||||
code = doBlockDataWindowFilter(pInfo->pRes, pInfo->primaryTsIndex, pTimeWindow, id);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
pInfo->pRes->info.dataLoad = 1;
|
||||
|
||||
code = blockDataUpdateTsWindow(pInfo->pRes, pInfo->primaryTsIndex);
|
||||
|
@ -2676,14 +2707,19 @@ _end:
|
|||
return code;
|
||||
}
|
||||
|
||||
static void processPrimaryKey(SSDataBlock* pBlock, bool hasPrimaryKey, STqOffsetVal* offset) {
|
||||
SValue val = {0};
|
||||
static int32_t processPrimaryKey(SSDataBlock* pBlock, bool hasPrimaryKey, STqOffsetVal* offset) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SValue val = {0};
|
||||
if (hasPrimaryKey) {
|
||||
doBlockDataPrimaryKeyFilter(pBlock, offset);
|
||||
code = doBlockDataPrimaryKeyFilter(pBlock, offset);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
SColumnInfoData* pColPk = taosArrayGet(pBlock->pDataBlock, 1);
|
||||
|
||||
if (pBlock->info.rows < 1) {
|
||||
return;
|
||||
return code;
|
||||
}
|
||||
void* tmp = colDataGetData(pColPk, pBlock->info.rows - 1);
|
||||
val.type = pColPk->info.type;
|
||||
|
@ -2696,6 +2732,7 @@ static void processPrimaryKey(SSDataBlock* pBlock, bool hasPrimaryKey, STqOffset
|
|||
}
|
||||
}
|
||||
tqOffsetResetToData(offset, pBlock->info.id.uid, pBlock->info.window.ekey, val);
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t doQueueScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRes) {
|
||||
|
@ -2711,7 +2748,7 @@ static int32_t doQueueScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRes) {
|
|||
|
||||
if (isTaskKilled(pTaskInfo)) {
|
||||
(*ppRes) = NULL;
|
||||
return code;
|
||||
return pTaskInfo->code;
|
||||
}
|
||||
|
||||
if (pTaskInfo->streamInfo.currentOffset.type == TMQ_OFFSET__SNAPSHOT_DATA) {
|
||||
|
@ -2720,9 +2757,9 @@ static int32_t doQueueScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRes) {
|
|||
|
||||
if (pResult && pResult->info.rows > 0) {
|
||||
bool hasPrimaryKey = pAPI->tqReaderFn.tqGetTablePrimaryKey(pInfo->tqReader);
|
||||
processPrimaryKey(pResult, hasPrimaryKey, &pTaskInfo->streamInfo.currentOffset);
|
||||
qDebug("tmqsnap doQueueScan get data uid:%" PRId64 "", pResult->info.id.uid);
|
||||
if (pResult->info.rows > 0) {
|
||||
code = processPrimaryKey(pResult, hasPrimaryKey, &pTaskInfo->streamInfo.currentOffset);
|
||||
qDebug("tmqsnap doQueueScan get data utid:%" PRId64 "", pResult->info.id.uid);
|
||||
if (pResult->info.rows > 0 || code != TSDB_CODE_SUCCESS) {
|
||||
(*ppRes) = pResult;
|
||||
return code;
|
||||
}
|
||||
|
@ -3156,7 +3193,8 @@ FETCH_NEXT_BLOCK:
|
|||
|
||||
code = setBlockGroupIdByUid(pInfo, pDelBlock);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
rebuildDeleteBlockData(pDelBlock, &pStreamInfo->fillHistoryWindow, id);
|
||||
code = rebuildDeleteBlockData(pDelBlock, &pStreamInfo->fillHistoryWindow, id);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
printSpecDataBlock(pDelBlock, getStreamOpName(pOperator->operatorType), "delete recv filtered",
|
||||
GET_TASKID(pTaskInfo));
|
||||
if (pDelBlock->info.rows == 0) {
|
||||
|
@ -3479,7 +3517,7 @@ static int32_t doRawScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRes) {
|
|||
|
||||
if (pBlock && pBlock->info.rows > 0) {
|
||||
bool hasPrimaryKey = pAPI->snapshotFn.taosXGetTablePrimaryKey(pInfo->sContext);
|
||||
processPrimaryKey(pBlock, hasPrimaryKey, &pTaskInfo->streamInfo.currentOffset);
|
||||
code = processPrimaryKey(pBlock, hasPrimaryKey, &pTaskInfo->streamInfo.currentOffset);
|
||||
qDebug("tmqsnap doRawScan get data uid:%" PRId64 "", pBlock->info.id.uid);
|
||||
(*ppRes) = pBlock;
|
||||
return code;
|
||||
|
@ -3493,7 +3531,7 @@ static int32_t doRawScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRes) {
|
|||
tDeleteSchemaWrapper(mtInfo.schema);
|
||||
goto _end;
|
||||
}
|
||||
STqOffsetVal offset = {0};
|
||||
STqOffsetVal offset = {0};
|
||||
if (mtInfo.uid == 0 || pInfo->sContext->withMeta == ONLY_META) { // read snapshot done, change to get data from wal
|
||||
qDebug("tmqsnap read snapshot done, change to get data from wal");
|
||||
tqOffsetResetToLog(&offset, pInfo->sContext->snapVersion + 1);
|
||||
|
@ -3964,7 +4002,7 @@ int32_t createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhysiNode*
|
|||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
|
||||
pInfo->updateWin = (STimeWindow){.skey = INT64_MAX, .ekey = INT64_MAX};
|
||||
createSpecialDataBlock(STREAM_CLEAR, &pInfo->pUpdateDataRes);
|
||||
code = createSpecialDataBlock(STREAM_CLEAR, &pInfo->pUpdateDataRes);
|
||||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
|
||||
if (hasPrimaryKeyCol(pInfo)) {
|
||||
|
@ -4123,7 +4161,7 @@ static EDealRes tagScanRewriteTagColumn(SNode** pNode, void* pContext) {
|
|||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
STagScanFilterContext* pCtx = (STagScanFilterContext*)pContext;
|
||||
SColumnNode* pSColumnNode = NULL;
|
||||
SColumnNode* pSColumnNode = NULL;
|
||||
if (QUERY_NODE_COLUMN == nodeType((*pNode))) {
|
||||
pSColumnNode = *(SColumnNode**)pNode;
|
||||
} else if (QUERY_NODE_FUNCTION == nodeType((*pNode))) {
|
||||
|
@ -4484,8 +4522,8 @@ static void destroyTagScanOperatorInfo(void* param) {
|
|||
}
|
||||
|
||||
int32_t createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysiNode* pTagScanNode,
|
||||
STableListInfo* pTableListInfo, SNode* pTagCond, SNode* pTagIndexCond,
|
||||
SExecTaskInfo* pTaskInfo, SOperatorInfo** pOptrInfo) {
|
||||
STableListInfo* pTableListInfo, SNode* pTagCond, SNode* pTagIndexCond,
|
||||
SExecTaskInfo* pTaskInfo, SOperatorInfo** pOptrInfo) {
|
||||
QRY_OPTR_CHECK(pOptrInfo);
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
@ -5083,7 +5121,7 @@ _end:
|
|||
|
||||
static SSDataBlock* doTableMergeScanParaSubTables(SOperatorInfo* pOperator) {
|
||||
SSDataBlock* pRes = NULL;
|
||||
int32_t code = doTableMergeScanParaSubTablesNext(pOperator, &pRes);
|
||||
int32_t code = doTableMergeScanParaSubTablesNext(pOperator, &pRes);
|
||||
return pRes;
|
||||
}
|
||||
|
||||
|
@ -5317,7 +5355,7 @@ int32_t startDurationForGroupTableMergeScan(SOperatorInfo* pOperator) {
|
|||
|
||||
pInfo->pSortHandle = NULL;
|
||||
code = tsortCreateSortHandle(pInfo->pSortInfo, SORT_BLOCK_TS_MERGE, pInfo->bufPageSize, numOfBufPage,
|
||||
pInfo->pSortInputBlock, pTaskInfo->id.str, 0, 0, 0, &pInfo->pSortHandle);
|
||||
pInfo->pSortInputBlock, pTaskInfo->id.str, 0, 0, 0, &pInfo->pSortHandle);
|
||||
if (code) {
|
||||
return code;
|
||||
}
|
||||
|
@ -5569,7 +5607,7 @@ _end:
|
|||
|
||||
static SSDataBlock* doTableMergeScan(SOperatorInfo* pOperator) {
|
||||
SSDataBlock* pRes = NULL;
|
||||
int32_t code = doTableMergeScanNext(pOperator, &pRes);
|
||||
int32_t code = doTableMergeScanNext(pOperator, &pRes);
|
||||
return pRes;
|
||||
}
|
||||
|
||||
|
@ -5626,10 +5664,11 @@ int32_t getTableMergeScanExplainExecInfo(SOperatorInfo* pOptr, void** pOptrExpla
|
|||
}
|
||||
|
||||
int32_t createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* readHandle,
|
||||
STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo, SOperatorInfo** pOptrInfo) {
|
||||
STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo,
|
||||
SOperatorInfo** pOptrInfo) {
|
||||
QRY_OPTR_CHECK(pOptrInfo);
|
||||
|
||||
int32_t code = 0;
|
||||
int32_t code = 0;
|
||||
STableMergeScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STableMergeScanInfo));
|
||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||
if (pInfo == NULL || pOperator == NULL) {
|
||||
|
@ -5641,7 +5680,7 @@ int32_t createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SR
|
|||
|
||||
int32_t numOfCols = 0;
|
||||
code = extractColMatchInfo(pTableScanNode->scan.pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID,
|
||||
&pInfo->base.matchInfo);
|
||||
&pInfo->base.matchInfo);
|
||||
int32_t lino = 0;
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
|
@ -5867,7 +5906,7 @@ int32_t getTableCountScanSupp(SNodeList* groupTags, SName* tableName, SNodeList*
|
|||
}
|
||||
|
||||
int32_t createTableCountScanOperatorInfo(SReadHandle* readHandle, STableCountScanPhysiNode* pTblCountScanNode,
|
||||
SExecTaskInfo* pTaskInfo, SOperatorInfo** pOptrInfo) {
|
||||
SExecTaskInfo* pTaskInfo, SOperatorInfo** pOptrInfo) {
|
||||
QRY_OPTR_CHECK(pOptrInfo);
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
@ -6040,7 +6079,7 @@ _end:
|
|||
}
|
||||
|
||||
static int32_t doTableCountScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRes) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||
STableCountScanOperatorInfo* pInfo = pOperator->info;
|
||||
STableCountScanSupp* pSupp = &pInfo->supp;
|
||||
|
@ -6062,7 +6101,7 @@ static int32_t doTableCountScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRe
|
|||
|
||||
static SSDataBlock* doTableCountScan(SOperatorInfo* pOperator) {
|
||||
SSDataBlock* pRes = NULL;
|
||||
int32_t code = doTableCountScanNext(pOperator, &pRes);
|
||||
int32_t code = doTableCountScanNext(pOperator, &pRes);
|
||||
return pRes;
|
||||
}
|
||||
|
||||
|
|
|
@ -510,18 +510,16 @@ int32_t doStreamEventDecodeOpState(void* buf, int32_t len, SOperatorInfo* pOpera
|
|||
int32_t mapSize = 0;
|
||||
buf = taosDecodeFixedI32(buf, &mapSize);
|
||||
for (int32_t i = 0; i < mapSize; i++) {
|
||||
SSessionKey key = {0};
|
||||
SResultWindowInfo winfo = {0};
|
||||
buf = decodeSSessionKey(buf, &key);
|
||||
buf = decodeSSessionKey(buf, &winfo.sessionWin);
|
||||
int32_t winCode = TSDB_CODE_SUCCESS;
|
||||
code = pAggSup->stateStore.streamStateSessionAddIfNotExist(
|
||||
pAggSup->pState, &winfo.sessionWin, pAggSup->gap, (void**)&winfo.pStatePos, &pAggSup->resultRowSize, &winCode);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
ASSERT(winCode == TSDB_CODE_SUCCESS);
|
||||
|
||||
buf = decodeSResultWindowInfo(buf, &winfo, pInfo->streamAggSup.resultRowSize);
|
||||
code =
|
||||
tSimpleHashPut(pInfo->streamAggSup.pResultRows, &key, sizeof(SSessionKey), &winfo, sizeof(SResultWindowInfo));
|
||||
tSimpleHashPut(pInfo->streamAggSup.pResultRows, &winfo.sessionWin, sizeof(SSessionKey), &winfo, sizeof(SResultWindowInfo));
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
}
|
||||
|
||||
|
|
|
@ -5183,7 +5183,7 @@ int32_t createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhysiNode*
|
|||
pInfo->pDelWins = taosArrayInit(4, sizeof(SWinKey));
|
||||
pInfo->delIndex = 0;
|
||||
|
||||
createSpecialDataBlock(STREAM_DELETE_RESULT, &pInfo->pDelRes);
|
||||
code = createSpecialDataBlock(STREAM_DELETE_RESULT, &pInfo->pDelRes);
|
||||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
|
||||
initResultRowInfo(&pInfo->binfo.resultRowInfo);
|
||||
|
|
|
@ -103,11 +103,11 @@ typedef void* queue[2];
|
|||
#define TRANS_MAGIC_NUM 0x5f375a86
|
||||
#define TRANS_NOVALID_PACKET(src) ((src) != TRANS_MAGIC_NUM ? 1 : 0)
|
||||
|
||||
typedef struct SRpcMsg STransMsg;
|
||||
typedef SRpcCtx STransCtx;
|
||||
typedef SRpcCtxVal STransCtxVal;
|
||||
typedef SRpcInfo STrans;
|
||||
typedef SRpcConnInfo STransHandleInfo;
|
||||
typedef struct SRpcMsg STransMsg;
|
||||
typedef SRpcCtx STransCtx;
|
||||
typedef SRpcCtxVal STransCtxVal;
|
||||
typedef SRpcInfo STrans;
|
||||
typedef SRpcConnInfo STransHandleInfo;
|
||||
|
||||
// ref mgt handle
|
||||
typedef struct SExHandle {
|
||||
|
@ -250,10 +250,10 @@ typedef struct {
|
|||
int8_t stop;
|
||||
} SAsyncPool;
|
||||
|
||||
SAsyncPool* transAsyncPoolCreate(uv_loop_t* loop, int sz, void* arg, AsyncCB cb);
|
||||
void transAsyncPoolDestroy(SAsyncPool* pool);
|
||||
int transAsyncSend(SAsyncPool* pool, queue* mq);
|
||||
bool transAsyncPoolIsEmpty(SAsyncPool* pool);
|
||||
int32_t transAsyncPoolCreate(uv_loop_t* loop, int sz, void* arg, AsyncCB cb, SAsyncPool** pPool);
|
||||
void transAsyncPoolDestroy(SAsyncPool* pool);
|
||||
int transAsyncSend(SAsyncPool* pool, queue* mq);
|
||||
bool transAsyncPoolIsEmpty(SAsyncPool* pool);
|
||||
|
||||
#define TRANS_DESTROY_ASYNC_POOL_MSG(pool, msgType, freeFunc, param) \
|
||||
do { \
|
||||
|
@ -279,6 +279,7 @@ bool transAsyncPoolIsEmpty(SAsyncPool* pool);
|
|||
if (exh2 == NULL || id != exh2->refId) { \
|
||||
tTrace("handle %p except, may already freed, ignore msg, ref1:%" PRIu64 ", ref2:%" PRIu64, exh1, \
|
||||
exh2 ? exh2->refId : 0, id); \
|
||||
code = terrno; \
|
||||
goto _return1; \
|
||||
} \
|
||||
} else if (id == 0) { \
|
||||
|
@ -287,6 +288,7 @@ bool transAsyncPoolIsEmpty(SAsyncPool* pool);
|
|||
if (exh2 == NULL || id == exh2->refId) { \
|
||||
tTrace("handle %p except, may already freed, ignore msg, ref1:%" PRIu64 ", ref2:%" PRIu64, exh1, id, \
|
||||
exh2 ? exh2->refId : 0); \
|
||||
code = terrno; \
|
||||
goto _return1; \
|
||||
} else { \
|
||||
id = exh1->refId; \
|
||||
|
@ -297,13 +299,13 @@ bool transAsyncPoolIsEmpty(SAsyncPool* pool);
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
int transInitBuffer(SConnBuffer* buf);
|
||||
int transClearBuffer(SConnBuffer* buf);
|
||||
int transDestroyBuffer(SConnBuffer* buf);
|
||||
int transAllocBuffer(SConnBuffer* connBuf, uv_buf_t* uvBuf);
|
||||
bool transReadComplete(SConnBuffer* connBuf);
|
||||
int transResetBuffer(SConnBuffer* connBuf, int8_t resetBuf);
|
||||
int transDumpFromBuffer(SConnBuffer* connBuf, char** buf, int8_t resetBuf);
|
||||
int32_t transInitBuffer(SConnBuffer* buf);
|
||||
int32_t transClearBuffer(SConnBuffer* buf);
|
||||
int32_t transDestroyBuffer(SConnBuffer* buf);
|
||||
int32_t transAllocBuffer(SConnBuffer* connBuf, uv_buf_t* uvBuf);
|
||||
bool transReadComplete(SConnBuffer* connBuf);
|
||||
int transResetBuffer(SConnBuffer* connBuf, int8_t resetBuf);
|
||||
int transDumpFromBuffer(SConnBuffer* connBuf, char** buf, int8_t resetBuf);
|
||||
|
||||
int transSetConnOption(uv_tcp_t* stream, int keepalive);
|
||||
|
||||
|
@ -316,14 +318,14 @@ void transUnrefCliHandle(void* handle);
|
|||
int transReleaseCliHandle(void* handle);
|
||||
int transReleaseSrvHandle(void* handle);
|
||||
|
||||
int transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pMsg, STransCtx* pCtx);
|
||||
int transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pMsg, STransMsg* pRsp);
|
||||
int transSendRecvWithTimeout(void* shandle, SEpSet* pEpSet, STransMsg* pMsg, STransMsg* pRsp, int8_t* epUpdated,
|
||||
int32_t timeoutMs);
|
||||
int transSendResponse(const STransMsg* msg);
|
||||
int transRegisterMsg(const STransMsg* msg);
|
||||
int transSetDefaultAddr(void* shandle, const char* ip, const char* fqdn);
|
||||
void transSetIpWhiteList(void* shandle, void* arg, FilteFunc* func);
|
||||
int transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pMsg, STransCtx* pCtx);
|
||||
int transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pMsg, STransMsg* pRsp);
|
||||
int transSendRecvWithTimeout(void* shandle, SEpSet* pEpSet, STransMsg* pMsg, STransMsg* pRsp, int8_t* epUpdated,
|
||||
int32_t timeoutMs);
|
||||
int transSendResponse(const STransMsg* msg);
|
||||
int transRegisterMsg(const STransMsg* msg);
|
||||
int transSetDefaultAddr(void* shandle, const char* ip, const char* fqdn);
|
||||
int32_t transSetIpWhiteList(void* shandle, void* arg, FilteFunc* func);
|
||||
|
||||
int transSockInfo2Str(struct sockaddr* sockname, char* dst);
|
||||
|
||||
|
@ -363,7 +365,7 @@ typedef struct {
|
|||
* init queue
|
||||
* note: queue'size is small, default 1
|
||||
*/
|
||||
void transQueueInit(STransQueue* queue, void (*freeFunc)(const void* arg));
|
||||
int32_t transQueueInit(STransQueue* queue, void (*freeFunc)(const void* arg));
|
||||
|
||||
/*
|
||||
* put arg into queue
|
||||
|
@ -420,7 +422,7 @@ typedef struct SDelayQueue {
|
|||
uv_loop_t* loop;
|
||||
} SDelayQueue;
|
||||
|
||||
int transDQCreate(uv_loop_t* loop, SDelayQueue** queue);
|
||||
int32_t transDQCreate(uv_loop_t* loop, SDelayQueue** queue);
|
||||
void transDQDestroy(SDelayQueue* queue, void (*freeFunc)(void* arg));
|
||||
SDelayTask* transDQSched(SDelayQueue* queue, void (*func)(void* arg), void* arg, uint64_t timeoutMs);
|
||||
void transDQCancel(SDelayQueue* queue, SDelayTask* task);
|
||||
|
@ -433,9 +435,9 @@ bool transEpSetIsEqual2(SEpSet* a, SEpSet* b);
|
|||
*/
|
||||
void transThreadOnce();
|
||||
|
||||
void transInit();
|
||||
void transCleanup();
|
||||
void transPrintEpSet(SEpSet* pEpSet);
|
||||
int32_t transInit();
|
||||
void transCleanup();
|
||||
void transPrintEpSet(SEpSet* pEpSet);
|
||||
|
||||
void transFreeMsg(void* msg);
|
||||
int32_t transCompressMsg(char* msg, int32_t len);
|
||||
|
|
|
@ -719,9 +719,8 @@ int64_t transInitHttpChanImpl() {
|
|||
goto _ERROR;
|
||||
}
|
||||
|
||||
http->asyncPool = transAsyncPoolCreate(http->loop, 1, http, httpAsyncCb);
|
||||
if (http->asyncPool == NULL) {
|
||||
code = terrno;
|
||||
code = transAsyncPoolCreate(http->loop, 1, http, httpAsyncCb, &http->asyncPool);
|
||||
if (code != 0) {
|
||||
goto _ERROR;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,18 +27,20 @@ int (*transReleaseHandle[])(void* handle) = {transReleaseSrvHandle, transRelease
|
|||
|
||||
static int32_t transValidLocalFqdn(const char* localFqdn, uint32_t* ip) {
|
||||
int32_t code = taosGetIpv4FromFqdn(localFqdn, ip);
|
||||
if (code) {
|
||||
terrno = TSDB_CODE_RPC_FQDN_ERROR;
|
||||
return -1;
|
||||
if (code != 0) {
|
||||
return TSDB_CODE_RPC_FQDN_ERROR;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
void* rpcOpen(const SRpcInit* pInit) {
|
||||
rpcInit();
|
||||
int32_t code = rpcInit();
|
||||
if (code != 0) {
|
||||
TAOS_CHECK_GOTO(code, NULL, _end);
|
||||
}
|
||||
|
||||
SRpcInfo* pRpc = taosMemoryCalloc(1, sizeof(SRpcInfo));
|
||||
if (pRpc == NULL) {
|
||||
return NULL;
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end);
|
||||
}
|
||||
if (pInit->label) {
|
||||
int len = strlen(pInit->label) > sizeof(pRpc->label) ? sizeof(pRpc->label) : strlen(pInit->label);
|
||||
|
@ -84,10 +86,9 @@ void* rpcOpen(const SRpcInit* pInit) {
|
|||
|
||||
uint32_t ip = 0;
|
||||
if (pInit->connType == TAOS_CONN_SERVER) {
|
||||
if (transValidLocalFqdn(pInit->localFqdn, &ip) != 0) {
|
||||
tError("invalid fqdn:%s, errmsg:%s", pInit->localFqdn, terrstr());
|
||||
taosMemoryFree(pRpc);
|
||||
return NULL;
|
||||
if ((code = transValidLocalFqdn(pInit->localFqdn, &ip)) != 0) {
|
||||
tError("invalid fqdn:%s, errmsg:%s", pInit->localFqdn, tstrerror(code));
|
||||
TAOS_CHECK_GOTO(code, NULL, _end);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,14 +106,19 @@ void* rpcOpen(const SRpcInit* pInit) {
|
|||
(*taosInitHandle[pRpc->connType])(ip, pInit->localPort, pRpc->label, pRpc->numOfThreads, NULL, pRpc);
|
||||
|
||||
if (pRpc->tcphandle == NULL) {
|
||||
taosMemoryFree(pRpc);
|
||||
return NULL;
|
||||
tError("failed to init rpc handle");
|
||||
TAOS_CHECK_GOTO(terrno, NULL, _end);
|
||||
}
|
||||
|
||||
int64_t refId = transAddExHandle(transGetInstMgt(), pRpc);
|
||||
transAcquireExHandle(transGetInstMgt(), refId);
|
||||
pRpc->refId = refId;
|
||||
return (void*)refId;
|
||||
_end:
|
||||
taosMemoryFree(pRpc);
|
||||
terrno = code;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
void rpcClose(void* arg) {
|
||||
tInfo("start to close rpc");
|
||||
|
@ -186,7 +192,7 @@ int rpcSetDefaultAddr(void* thandle, const char* ip, const char* fqdn) {
|
|||
return transSetDefaultAddr(thandle, ip, fqdn);
|
||||
}
|
||||
// server only
|
||||
void rpcSetIpWhite(void* thandle, void* arg) { transSetIpWhiteList(thandle, arg, NULL); }
|
||||
int32_t rpcSetIpWhite(void* thandle, void* arg) { return transSetIpWhiteList(thandle, arg, NULL); }
|
||||
|
||||
void* rpcAllocHandle() { return (void*)transAllocHandle(); }
|
||||
|
||||
|
@ -202,10 +208,8 @@ int32_t rpcCvtErrCode(int32_t code) {
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t rpcInit() {
|
||||
transInit();
|
||||
return 0;
|
||||
}
|
||||
int32_t rpcInit() { return transInit(); }
|
||||
|
||||
void rpcCleanup(void) {
|
||||
transCleanup();
|
||||
transHttpEnvDestroy();
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -67,7 +67,11 @@ int32_t transDecompressMsg(char** msg, int32_t len) {
|
|||
STransCompMsg* pComp = (STransCompMsg*)pCont;
|
||||
int32_t oriLen = htonl(pComp->contLen);
|
||||
|
||||
char* buf = taosMemoryCalloc(1, oriLen + sizeof(STransMsgHead));
|
||||
char* buf = taosMemoryCalloc(1, oriLen + sizeof(STransMsgHead));
|
||||
if (buf == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
STransMsgHead* pNewHead = (STransMsgHead*)buf;
|
||||
int32_t decompLen = LZ4_decompress_safe(pCont + sizeof(STransCompMsg), (char*)pNewHead->content,
|
||||
len - sizeof(STransMsgHead) - sizeof(STransCompMsg), oriLen);
|
||||
|
@ -78,7 +82,7 @@ int32_t transDecompressMsg(char** msg, int32_t len) {
|
|||
taosMemoryFree(pHead);
|
||||
*msg = buf;
|
||||
if (decompLen != oriLen) {
|
||||
return -1;
|
||||
return TSDB_CODE_INVALID_MSG;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -98,26 +102,33 @@ int transSockInfo2Str(struct sockaddr* sockname, char* dst) {
|
|||
sprintf(dst, "%s:%d", buf, ntohs(addr.sin_port));
|
||||
return r;
|
||||
}
|
||||
int transInitBuffer(SConnBuffer* buf) {
|
||||
buf->cap = BUFFER_CAP;
|
||||
int32_t transInitBuffer(SConnBuffer* buf) {
|
||||
buf->buf = taosMemoryCalloc(1, BUFFER_CAP);
|
||||
if (buf->buf == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
buf->cap = BUFFER_CAP;
|
||||
buf->left = -1;
|
||||
buf->len = 0;
|
||||
buf->total = 0;
|
||||
buf->invalid = 0;
|
||||
return 0;
|
||||
}
|
||||
int transDestroyBuffer(SConnBuffer* p) {
|
||||
int32_t transDestroyBuffer(SConnBuffer* p) {
|
||||
taosMemoryFree(p->buf);
|
||||
p->buf = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int transClearBuffer(SConnBuffer* buf) {
|
||||
int32_t transClearBuffer(SConnBuffer* buf) {
|
||||
SConnBuffer* p = buf;
|
||||
if (p->cap > BUFFER_CAP) {
|
||||
p->cap = BUFFER_CAP;
|
||||
p->buf = taosMemoryRealloc(p->buf, BUFFER_CAP);
|
||||
if (p->buf == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
p->left = -1;
|
||||
p->len = 0;
|
||||
|
@ -126,27 +137,31 @@ int transClearBuffer(SConnBuffer* buf) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int transDumpFromBuffer(SConnBuffer* connBuf, char** buf, int8_t resetBuf) {
|
||||
int32_t transDumpFromBuffer(SConnBuffer* connBuf, char** buf, int8_t resetBuf) {
|
||||
static const int HEADSIZE = sizeof(STransMsgHead);
|
||||
|
||||
SConnBuffer* p = connBuf;
|
||||
int32_t code = 0;
|
||||
SConnBuffer* p = connBuf;
|
||||
if (p->left != 0 || p->total <= 0) {
|
||||
return -1;
|
||||
return TSDB_CODE_INVALID_MSG;
|
||||
}
|
||||
int total = p->total;
|
||||
if (total >= HEADSIZE && !p->invalid) {
|
||||
*buf = taosMemoryCalloc(1, total);
|
||||
if (*buf == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
memcpy(*buf, p->buf, total);
|
||||
if (transResetBuffer(connBuf, resetBuf) < 0) {
|
||||
return -1;
|
||||
if ((code = transResetBuffer(connBuf, resetBuf)) < 0) {
|
||||
return code;
|
||||
}
|
||||
} else {
|
||||
total = -1;
|
||||
return TSDB_CODE_INVALID_MSG;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
int transResetBuffer(SConnBuffer* connBuf, int8_t resetBuf) {
|
||||
int32_t transResetBuffer(SConnBuffer* connBuf, int8_t resetBuf) {
|
||||
SConnBuffer* p = connBuf;
|
||||
if (p->total < p->len) {
|
||||
int left = p->len - p->total;
|
||||
|
@ -162,15 +177,18 @@ int transResetBuffer(SConnBuffer* connBuf, int8_t resetBuf) {
|
|||
if (resetBuf) {
|
||||
p->cap = BUFFER_CAP;
|
||||
p->buf = taosMemoryRealloc(p->buf, p->cap);
|
||||
if (p->buf == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ASSERTS(0, "invalid read from sock buf");
|
||||
return -1;
|
||||
return TSDB_CODE_INVALID_MSG;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int transAllocBuffer(SConnBuffer* connBuf, uv_buf_t* uvBuf) {
|
||||
int32_t transAllocBuffer(SConnBuffer* connBuf, uv_buf_t* uvBuf) {
|
||||
/*
|
||||
* formate of data buffer:
|
||||
* |<--------------------------data from socket------------------------------->|
|
||||
|
@ -187,6 +205,9 @@ int transAllocBuffer(SConnBuffer* connBuf, uv_buf_t* uvBuf) {
|
|||
} else {
|
||||
p->cap = p->left + p->len;
|
||||
p->buf = taosMemoryRealloc(p->buf, p->cap);
|
||||
if (p->buf == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
uvBuf->base = p->buf + p->len;
|
||||
uvBuf->len = p->left;
|
||||
}
|
||||
|
@ -222,19 +243,19 @@ int transSetConnOption(uv_tcp_t* stream, int keepalive) {
|
|||
// int ret = uv_tcp_keepalive(stream, 5, 60);
|
||||
}
|
||||
|
||||
SAsyncPool* transAsyncPoolCreate(uv_loop_t* loop, int sz, void* arg, AsyncCB cb) {
|
||||
int32_t transAsyncPoolCreate(uv_loop_t* loop, int sz, void* arg, AsyncCB cb, SAsyncPool** pPool) {
|
||||
SAsyncPool* pool = taosMemoryCalloc(1, sizeof(SAsyncPool));
|
||||
if (pool == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
// return NULL;
|
||||
}
|
||||
int32_t code = 0;
|
||||
|
||||
pool->nAsync = sz;
|
||||
pool->asyncs = taosMemoryCalloc(1, sizeof(uv_async_t) * pool->nAsync);
|
||||
if (pool->asyncs == NULL) {
|
||||
taosMemoryFree(pool);
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
int i = 0, err = 0;
|
||||
|
@ -243,7 +264,7 @@ SAsyncPool* transAsyncPoolCreate(uv_loop_t* loop, int sz, void* arg, AsyncCB cb)
|
|||
|
||||
SAsyncItem* item = taosMemoryCalloc(1, sizeof(SAsyncItem));
|
||||
if (item == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
break;
|
||||
}
|
||||
item->pThrd = arg;
|
||||
|
@ -254,7 +275,7 @@ SAsyncPool* transAsyncPoolCreate(uv_loop_t* loop, int sz, void* arg, AsyncCB cb)
|
|||
err = uv_async_init(loop, async, cb);
|
||||
if (err != 0) {
|
||||
tError("failed to init async, reason:%s", uv_err_name(err));
|
||||
terrno = TSDB_CODE_THIRDPARTY_ERROR;
|
||||
code = TSDB_CODE_THIRDPARTY_ERROR;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -264,10 +285,14 @@ SAsyncPool* transAsyncPoolCreate(uv_loop_t* loop, int sz, void* arg, AsyncCB cb)
|
|||
pool = NULL;
|
||||
}
|
||||
|
||||
return pool;
|
||||
*pPool = pool;
|
||||
return 0;
|
||||
// return pool;
|
||||
}
|
||||
|
||||
void transAsyncPoolDestroy(SAsyncPool* pool) {
|
||||
if (pool == NULL) return;
|
||||
|
||||
for (int i = 0; i < pool->nAsync; i++) {
|
||||
uv_async_t* async = &(pool->asyncs[i]);
|
||||
SAsyncItem* item = async->data;
|
||||
|
@ -289,7 +314,7 @@ bool transAsyncPoolIsEmpty(SAsyncPool* pool) {
|
|||
}
|
||||
int transAsyncSend(SAsyncPool* pool, queue* q) {
|
||||
if (atomic_load_8(&pool->stop) == 1) {
|
||||
return -1;
|
||||
return TSDB_CODE_RPC_ASYNC_MODULE_QUIT;
|
||||
}
|
||||
int idx = pool->index % pool->nAsync;
|
||||
|
||||
|
@ -303,7 +328,12 @@ int transAsyncSend(SAsyncPool* pool, queue* q) {
|
|||
taosThreadMutexLock(&item->mtx);
|
||||
QUEUE_PUSH(&item->qmsg, q);
|
||||
taosThreadMutexUnlock(&item->mtx);
|
||||
return uv_async_send(async);
|
||||
int ret = uv_async_send(async);
|
||||
if (ret != 0) {
|
||||
tError("failed to send async,reason:%s", uv_err_name(ret));
|
||||
return TSDB_CODE_THIRDPARTY_ERROR;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void transCtxInit(STransCtx* ctx) {
|
||||
|
@ -408,9 +438,14 @@ void transReqQueueClear(queue* q) {
|
|||
}
|
||||
}
|
||||
|
||||
void transQueueInit(STransQueue* queue, void (*freeFunc)(const void* arg)) {
|
||||
int32_t transQueueInit(STransQueue* queue, void (*freeFunc)(const void* arg)) {
|
||||
queue->q = taosArrayInit(2, sizeof(void*));
|
||||
queue->freeFunc = (void (*)(const void*))freeFunc;
|
||||
|
||||
if (queue->q == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
bool transQueuePush(STransQueue* queue, void* arg) {
|
||||
if (queue->q == NULL) {
|
||||
|
@ -513,20 +548,44 @@ static void transDQTimeout(uv_timer_t* timer) {
|
|||
uv_timer_start(queue->timer, transDQTimeout, timeout, 0);
|
||||
}
|
||||
}
|
||||
int transDQCreate(uv_loop_t* loop, SDelayQueue** queue) {
|
||||
uv_timer_t* timer = taosMemoryCalloc(1, sizeof(uv_timer_t));
|
||||
uv_timer_init(loop, timer);
|
||||
int32_t transDQCreate(uv_loop_t* loop, SDelayQueue** queue) {
|
||||
int32_t code = 0;
|
||||
Heap* heap = NULL;
|
||||
uv_timer_t* timer = NULL;
|
||||
SDelayQueue* q = NULL;
|
||||
|
||||
Heap* heap = heapCreate(timeCompare);
|
||||
timer = taosMemoryCalloc(1, sizeof(uv_timer_t));
|
||||
if (timer == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
SDelayQueue* q = taosMemoryCalloc(1, sizeof(SDelayQueue));
|
||||
heap = heapCreate(timeCompare);
|
||||
if (heap == NULL) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _return1);
|
||||
}
|
||||
|
||||
q = taosMemoryCalloc(1, sizeof(SDelayQueue));
|
||||
if (q == NULL) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _return1);
|
||||
}
|
||||
q->heap = heap;
|
||||
q->timer = timer;
|
||||
q->loop = loop;
|
||||
q->timer->data = q;
|
||||
|
||||
int err = uv_timer_init(loop, timer);
|
||||
if (err != 0) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_THIRDPARTY_ERROR, NULL, _return1);
|
||||
}
|
||||
|
||||
*queue = q;
|
||||
return 0;
|
||||
|
||||
_return1:
|
||||
taosMemoryFree(timer);
|
||||
heapDestroy(heap);
|
||||
taosMemoryFree(q);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
void transDQDestroy(SDelayQueue* queue, void (*freeFunc)(void* arg)) {
|
||||
|
@ -578,6 +637,10 @@ void transDQCancel(SDelayQueue* queue, SDelayTask* task) {
|
|||
SDelayTask* transDQSched(SDelayQueue* queue, void (*func)(void* arg), void* arg, uint64_t timeoutMs) {
|
||||
uint64_t now = taosGetTimestampMs();
|
||||
SDelayTask* task = taosMemoryCalloc(1, sizeof(SDelayTask));
|
||||
if (task == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
task->func = func;
|
||||
task->arg = arg;
|
||||
task->execTime = now + timeoutMs;
|
||||
|
@ -648,9 +711,13 @@ static void transDestroyEnv() {
|
|||
transCloseRefMgt(transSyncMsgMgt);
|
||||
}
|
||||
|
||||
void transInit() {
|
||||
int32_t transInit() {
|
||||
// init env
|
||||
taosThreadOnce(&transModuleInit, transInitEnv);
|
||||
int32_t code = taosThreadOnce(&transModuleInit, transInitEnv);
|
||||
if (code != 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t transGetRefMgt() { return refMgt; }
|
||||
|
@ -709,29 +776,6 @@ void transDestroySyncMsg(void* msg) {
|
|||
taosMemoryFree(pSyncMsg);
|
||||
}
|
||||
|
||||
// void subnetIp2int(const char* const ip_addr, uint8_t* dst) {
|
||||
// char ip_addr_cpy[20];
|
||||
// char ip[5];
|
||||
|
||||
// tstrncpy(ip_addr_cpy, ip_addr, sizeof(ip_addr_cpy));
|
||||
|
||||
// char *s_start, *s_end;
|
||||
// s_start = ip_addr_cpy;
|
||||
// s_end = ip_addr_cpy;
|
||||
|
||||
// int32_t k = 0;
|
||||
|
||||
// for (k = 0; *s_start != '\0'; s_start = s_end) {
|
||||
// for (s_end = s_start; *s_end != '.' && *s_end != '\0'; s_end++) {
|
||||
// }
|
||||
// if (*s_end == '.') {
|
||||
// *s_end = '\0';
|
||||
// s_end++;
|
||||
// }
|
||||
// dst[k++] = (char)atoi(s_start);
|
||||
// }
|
||||
// }
|
||||
|
||||
uint32_t subnetIpRang2Int(SIpV4Range* pRange) {
|
||||
uint32_t ip = pRange->ip;
|
||||
return ((ip & 0xFF) << 24) | ((ip & 0xFF00) << 8) | ((ip & 0xFF0000) >> 8) | ((ip >> 24) & 0xFF);
|
||||
|
@ -778,7 +822,11 @@ int32_t transUtilSIpRangeToStr(SIpV4Range* pRange, char* buf) {
|
|||
struct in_addr addr;
|
||||
addr.s_addr = pRange->ip;
|
||||
|
||||
uv_inet_ntop(AF_INET, &addr, buf, 32);
|
||||
int32_t err = uv_inet_ntop(AF_INET, &addr, buf, 32);
|
||||
if (err != 0) {
|
||||
tError("failed to convert ip to string, reason:%s", uv_strerror(err));
|
||||
return TSDB_CODE_THIRDPARTY_ERROR;
|
||||
}
|
||||
|
||||
len = strlen(buf);
|
||||
|
||||
|
@ -794,14 +842,23 @@ int32_t transUtilSWhiteListToStr(SIpWhiteList* pList, char** ppBuf) {
|
|||
*ppBuf = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t len = 0;
|
||||
char* pBuf = taosMemoryCalloc(1, pList->num * 36);
|
||||
if (pBuf == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
for (int i = 0; i < pList->num; i++) {
|
||||
SIpV4Range* pRange = &pList->pIpRange[i];
|
||||
|
||||
char tbuf[32] = {0};
|
||||
int tlen = transUtilSIpRangeToStr(pRange, tbuf);
|
||||
if (tlen < 0) {
|
||||
taosMemoryFree(pBuf);
|
||||
return tlen;
|
||||
}
|
||||
|
||||
len += sprintf(pBuf + len, "%s,", tbuf);
|
||||
}
|
||||
if (len > 0) {
|
||||
|
|
|
@ -122,7 +122,7 @@ typedef struct SServerObj {
|
|||
|
||||
SIpWhiteListTab* uvWhiteListCreate();
|
||||
void uvWhiteListDestroy(SIpWhiteListTab* pWhite);
|
||||
void uvWhiteListAdd(SIpWhiteListTab* pWhite, char* user, SIpWhiteList* pList, int64_t ver);
|
||||
int32_t uvWhiteListAdd(SIpWhiteListTab* pWhite, char* user, SIpWhiteList* pList, int64_t ver);
|
||||
void uvWhiteListUpdate(SIpWhiteListTab* pWhite, SHashObj* pTable);
|
||||
bool uvWhiteListCheckConn(SIpWhiteListTab* pWhite, SSvrConn* pConn);
|
||||
bool uvWhiteListFilte(SIpWhiteListTab* pWhite, char* user, uint32_t ip, int64_t ver);
|
||||
|
@ -164,7 +164,7 @@ static FORCE_INLINE SSvrConn* createConn(void* hThrd);
|
|||
static FORCE_INLINE void destroyConn(SSvrConn* conn, bool clear /*clear handle or not*/);
|
||||
static FORCE_INLINE void destroyConnRegArg(SSvrConn* conn);
|
||||
|
||||
static int reallocConnRef(SSvrConn* conn);
|
||||
static int32_t reallocConnRef(SSvrConn* conn);
|
||||
|
||||
static void uvHandleQuit(SSvrMsg* msg, SWorkThrd* thrd);
|
||||
static void uvHandleRelease(SSvrMsg* msg, SWorkThrd* thrd);
|
||||
|
@ -181,8 +181,8 @@ static void* transWorkerThread(void* arg);
|
|||
static void* transAcceptThread(void* arg);
|
||||
|
||||
// add handle loop
|
||||
static bool addHandleToWorkloop(SWorkThrd* pThrd, char* pipeName);
|
||||
static bool addHandleToAcceptloop(void* arg);
|
||||
static int32_t addHandleToWorkloop(SWorkThrd* pThrd, char* pipeName);
|
||||
static int32_t addHandleToAcceptloop(void* arg);
|
||||
|
||||
#define SRV_RELEASE_UV(loop) \
|
||||
do { \
|
||||
|
@ -202,7 +202,11 @@ static bool addHandleToAcceptloop(void* arg);
|
|||
void uvAllocRecvBufferCb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) {
|
||||
SSvrConn* conn = handle->data;
|
||||
SConnBuffer* pBuf = &conn->readBuf;
|
||||
transAllocBuffer(pBuf, buf);
|
||||
int32_t code = transAllocBuffer(pBuf, buf);
|
||||
if (code < 0) {
|
||||
tError("conn %p failed to alloc buffer, since %s", conn, tstrerror(code));
|
||||
// destroyConn(conn, true);
|
||||
}
|
||||
}
|
||||
|
||||
// refers specifically to query or insert timeout
|
||||
|
@ -221,8 +225,16 @@ static bool uvCheckIp(SIpV4Range* pRange, int32_t ip) {
|
|||
}
|
||||
SIpWhiteListTab* uvWhiteListCreate() {
|
||||
SIpWhiteListTab* pWhiteList = taosMemoryCalloc(1, sizeof(SIpWhiteListTab));
|
||||
if (pWhiteList == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pWhiteList->pList = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), 0, HASH_NO_LOCK);
|
||||
if (pWhiteList->pList == NULL) {
|
||||
taosMemoryFree(pWhiteList);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pWhiteList->ver = -1;
|
||||
return pWhiteList;
|
||||
}
|
||||
|
@ -240,17 +252,26 @@ void uvWhiteListDestroy(SIpWhiteListTab* pWhite) {
|
|||
taosMemoryFree(pWhite);
|
||||
}
|
||||
|
||||
void uvWhiteListToStr(SWhiteUserList* plist, char* user, char** ppBuf) {
|
||||
int32_t uvWhiteListToStr(SWhiteUserList* plist, char* user, char** ppBuf) {
|
||||
char* tmp = NULL;
|
||||
int32_t tlen = transUtilSWhiteListToStr(plist->pList, &tmp);
|
||||
if (tlen < 0) {
|
||||
return tlen;
|
||||
}
|
||||
|
||||
char* pBuf = taosMemoryCalloc(1, tlen + 64);
|
||||
if (pBuf == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
char* pBuf = taosMemoryCalloc(1, tlen + 64);
|
||||
int32_t len = sprintf(pBuf, "user: %s, ver: %" PRId64 ", ip: {%s}", user, plist->ver, tmp);
|
||||
taosMemoryFree(tmp);
|
||||
|
||||
*ppBuf = pBuf;
|
||||
return len;
|
||||
}
|
||||
void uvWhiteListDebug(SIpWhiteListTab* pWrite) {
|
||||
int32_t code = 0;
|
||||
SHashObj* pWhiteList = pWrite->pList;
|
||||
void* pIter = taosHashIterate(pWhiteList, NULL);
|
||||
while (pIter) {
|
||||
|
@ -262,23 +283,35 @@ void uvWhiteListDebug(SIpWhiteListTab* pWrite) {
|
|||
SWhiteUserList* pUserList = *(SWhiteUserList**)pIter;
|
||||
|
||||
char* buf = NULL;
|
||||
uvWhiteListToStr(pUserList, user, &buf);
|
||||
tDebug("ip-white-list %s", buf);
|
||||
|
||||
code = uvWhiteListToStr(pUserList, user, &buf);
|
||||
if (code != 0) {
|
||||
tDebug("ip-white-list failed to debug to str since %s", buf);
|
||||
}
|
||||
taosMemoryFree(buf);
|
||||
pIter = taosHashIterate(pWhiteList, pIter);
|
||||
}
|
||||
}
|
||||
void uvWhiteListAdd(SIpWhiteListTab* pWhite, char* user, SIpWhiteList* plist, int64_t ver) {
|
||||
int32_t uvWhiteListAdd(SIpWhiteListTab* pWhite, char* user, SIpWhiteList* plist, int64_t ver) {
|
||||
int32_t code = 0;
|
||||
SHashObj* pWhiteList = pWhite->pList;
|
||||
|
||||
SWhiteUserList** ppUserList = taosHashGet(pWhiteList, user, strlen(user));
|
||||
if (ppUserList == NULL || *ppUserList == NULL) {
|
||||
SWhiteUserList* pUserList = taosMemoryCalloc(1, sizeof(SWhiteUserList));
|
||||
if (pUserList == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
pUserList->ver = ver;
|
||||
|
||||
pUserList->pList = plist;
|
||||
|
||||
taosHashPut(pWhiteList, user, strlen(user), &pUserList, sizeof(void*));
|
||||
code = taosHashPut(pWhiteList, user, strlen(user), &pUserList, sizeof(void*));
|
||||
if (code != 0) {
|
||||
taosMemoryFree(pUserList);
|
||||
return code;
|
||||
}
|
||||
} else {
|
||||
SWhiteUserList* pUserList = *ppUserList;
|
||||
|
||||
|
@ -287,6 +320,7 @@ void uvWhiteListAdd(SIpWhiteListTab* pWhite, char* user, SIpWhiteList* plist, in
|
|||
pUserList->pList = plist;
|
||||
}
|
||||
uvWhiteListDebug(pWhite);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void uvWhiteListUpdate(SIpWhiteListTab* pWhite, SHashObj* pTable) {
|
||||
|
@ -584,6 +618,10 @@ static int uvPrepareSendData(SSvrMsg* smsg, uv_buf_t* wb) {
|
|||
STransMsg* pMsg = &smsg->msg;
|
||||
if (pMsg->pCont == 0) {
|
||||
pMsg->pCont = (void*)rpcMallocCont(0);
|
||||
if (pMsg->pCont == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
pMsg->contLen = 0;
|
||||
}
|
||||
STransMsgHead* pHead = transHeadFromCont(pMsg->pCont);
|
||||
|
@ -598,7 +636,7 @@ static int uvPrepareSendData(SSvrMsg* smsg, uv_buf_t* wb) {
|
|||
if (pConn->inType == TDMT_SCH_DROP_TASK && pMsg->code == TSDB_CODE_VND_INVALID_VGROUP_ID) {
|
||||
transQueuePop(&pConn->srvMsgs);
|
||||
destroySmsg(smsg);
|
||||
return -1;
|
||||
return TSDB_CODE_INVALID_MSG;
|
||||
}
|
||||
|
||||
if (pConn->status == ConnNormal) {
|
||||
|
@ -764,7 +802,11 @@ static void uvShutDownCb(uv_shutdown_t* req, int status) {
|
|||
}
|
||||
static bool uvRecvReleaseReq(SSvrConn* pConn, STransMsgHead* pHead) {
|
||||
if ((pHead)->release == 1 && (pHead->msgLen) == sizeof(*pHead)) {
|
||||
reallocConnRef(pConn);
|
||||
int32_t code = reallocConnRef(pConn);
|
||||
if (code != 0) {
|
||||
destroyConn(pConn, true);
|
||||
return true;
|
||||
}
|
||||
tTrace("conn %p received release request", pConn);
|
||||
|
||||
STraceId traceId = pHead->traceId;
|
||||
|
@ -935,23 +977,21 @@ void uvOnConnectionCb(uv_stream_t* q, ssize_t nread, const uv_buf_t* buf) {
|
|||
return;
|
||||
}
|
||||
|
||||
// uv_handle_type pending = uv_pipe_pending_type(pipe);
|
||||
|
||||
SSvrConn* pConn = createConn(pThrd);
|
||||
if (pConn == NULL) {
|
||||
uv_close((uv_handle_t*)q, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
pConn->pTransInst = pThrd->pTransInst;
|
||||
/* init conn timer*/
|
||||
// uv_timer_init(pThrd->loop, &pConn->pTimer);
|
||||
// pConn->pTimer.data = pConn;
|
||||
|
||||
pConn->hostThrd = pThrd;
|
||||
|
||||
// init client handle
|
||||
pConn->pTcp = (uv_tcp_t*)taosMemoryMalloc(sizeof(uv_tcp_t));
|
||||
uv_tcp_init(pThrd->loop, pConn->pTcp);
|
||||
pConn->pTcp->data = pConn;
|
||||
|
||||
// transSetConnOption((uv_tcp_t*)pConn->pTcp);
|
||||
// pConn->pTransInst = pThrd->pTransInst;
|
||||
// /* init conn timer*/
|
||||
// // uv_timer_init(pThrd->loop, &pConn->pTimer);
|
||||
// // pConn->pTimer.data = pConn;
|
||||
// pConn->hostThrd = pThrd;
|
||||
// // init client handle
|
||||
// pConn->pTcp = (uv_tcp_t*)taosMemoryMalloc(sizeof(uv_tcp_t));
|
||||
// uv_tcp_init(pThrd->loop, pConn->pTcp);
|
||||
// pConn->pTcp->data = pConn;
|
||||
|
||||
if (uv_accept(q, (uv_stream_t*)(pConn->pTcp)) == 0) {
|
||||
uv_os_fd_t fd;
|
||||
|
@ -1005,17 +1045,36 @@ void uvOnPipeConnectionCb(uv_connect_t* connect, int status) {
|
|||
SWorkThrd* pThrd = container_of(connect, SWorkThrd, connect_req);
|
||||
uv_read_start((uv_stream_t*)pThrd->pipe, uvAllocConnBufferCb, uvOnConnectionCb);
|
||||
}
|
||||
static bool addHandleToWorkloop(SWorkThrd* pThrd, char* pipeName) {
|
||||
static int32_t addHandleToWorkloop(SWorkThrd* pThrd, char* pipeName) {
|
||||
int32_t code = 0;
|
||||
pThrd->loop = (uv_loop_t*)taosMemoryMalloc(sizeof(uv_loop_t));
|
||||
if (0 != uv_loop_init(pThrd->loop)) {
|
||||
return false;
|
||||
if (pThrd->loop == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
if ((code = uv_loop_init(pThrd->loop)) != 0) {
|
||||
tError("failed to init loop since %s", uv_err_name(code));
|
||||
return TSDB_CODE_THIRDPARTY_ERROR;
|
||||
}
|
||||
|
||||
#if defined(WINDOWS) || defined(DARWIN)
|
||||
uv_pipe_init(pThrd->loop, pThrd->pipe, 1);
|
||||
code = uv_pipe_init(pThrd->loop, pThrd->pipe, 1);
|
||||
if (code != 0) {
|
||||
tError("failed to init pip since %s", uv_err_name(code));
|
||||
return TSDB_CODE_THIRDPARTY_ERROR;
|
||||
}
|
||||
#else
|
||||
uv_pipe_init(pThrd->loop, pThrd->pipe, 1);
|
||||
uv_pipe_open(pThrd->pipe, pThrd->fd);
|
||||
code = uv_pipe_init(pThrd->loop, pThrd->pipe, 1);
|
||||
if (code != 0) {
|
||||
tError("failed to init pip since %s", uv_err_name(code));
|
||||
return TSDB_CODE_THIRDPARTY_ERROR;
|
||||
}
|
||||
|
||||
code = uv_pipe_open(pThrd->pipe, pThrd->fd);
|
||||
if (code != 0) {
|
||||
tError("failed to open pip since %s", uv_err_name(code));
|
||||
return TSDB_CODE_THIRDPARTY_ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
pThrd->pipe->data = pThrd;
|
||||
|
@ -1023,50 +1082,86 @@ static bool addHandleToWorkloop(SWorkThrd* pThrd, char* pipeName) {
|
|||
QUEUE_INIT(&pThrd->msg);
|
||||
|
||||
pThrd->prepare = taosMemoryCalloc(1, sizeof(uv_prepare_t));
|
||||
uv_prepare_init(pThrd->loop, pThrd->prepare);
|
||||
uv_prepare_start(pThrd->prepare, uvPrepareCb);
|
||||
if (pThrd->prepare == NULL) {
|
||||
tError("failed to init prepare");
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
code = uv_prepare_init(pThrd->loop, pThrd->prepare);
|
||||
if (code != 0) {
|
||||
tError("failed to init prepare since %s", uv_err_name(code));
|
||||
return TSDB_CODE_THIRDPARTY_ERROR;
|
||||
}
|
||||
|
||||
code = uv_prepare_start(pThrd->prepare, uvPrepareCb);
|
||||
if (code != 0) {
|
||||
tError("failed to start prepare since %s", uv_err_name(code));
|
||||
return TSDB_CODE_THIRDPARTY_ERROR;
|
||||
}
|
||||
pThrd->prepare->data = pThrd;
|
||||
|
||||
// conn set
|
||||
QUEUE_INIT(&pThrd->conn);
|
||||
|
||||
pThrd->asyncPool = transAsyncPoolCreate(pThrd->loop, 8, pThrd, uvWorkerAsyncCb);
|
||||
code = transAsyncPoolCreate(pThrd->loop, 8, pThrd, uvWorkerAsyncCb, &pThrd->asyncPool);
|
||||
if (code != 0) {
|
||||
tError("failed to init async pool since:%s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
#if defined(WINDOWS) || defined(DARWIN)
|
||||
uv_pipe_connect(&pThrd->connect_req, pThrd->pipe, pipeName, uvOnPipeConnectionCb);
|
||||
|
||||
#else
|
||||
uv_read_start((uv_stream_t*)pThrd->pipe, uvAllocConnBufferCb, uvOnConnectionCb);
|
||||
code = uv_read_start((uv_stream_t*)pThrd->pipe, uvAllocConnBufferCb, uvOnConnectionCb);
|
||||
if (code != 0) {
|
||||
tError("failed to start read pipe:%s", uv_err_name(code));
|
||||
return TSDB_CODE_THIRDPARTY_ERROR;
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool addHandleToAcceptloop(void* arg) {
|
||||
static int32_t addHandleToAcceptloop(void* arg) {
|
||||
// impl later
|
||||
SServerObj* srv = arg;
|
||||
|
||||
int err = 0;
|
||||
if ((err = uv_tcp_init(srv->loop, &srv->server)) != 0) {
|
||||
tError("failed to init accept server:%s", uv_err_name(err));
|
||||
return false;
|
||||
int code = 0;
|
||||
if ((code = uv_tcp_init(srv->loop, &srv->server)) != 0) {
|
||||
tError("failed to init accept server since %s", uv_err_name(code));
|
||||
return TSDB_CODE_THIRDPARTY_ERROR;
|
||||
}
|
||||
|
||||
// register an async here to quit server gracefully
|
||||
srv->pAcceptAsync = taosMemoryCalloc(1, sizeof(uv_async_t));
|
||||
uv_async_init(srv->loop, srv->pAcceptAsync, uvAcceptAsyncCb);
|
||||
if (srv->pAcceptAsync == NULL) {
|
||||
tError("failed to create async since %s", tstrerror(TSDB_CODE_OUT_OF_MEMORY));
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
code = uv_async_init(srv->loop, srv->pAcceptAsync, uvAcceptAsyncCb);
|
||||
if (code != 0) {
|
||||
tError("failed to init async since:%s", uv_err_name(code));
|
||||
return TSDB_CODE_THIRDPARTY_ERROR;
|
||||
}
|
||||
srv->pAcceptAsync->data = srv;
|
||||
|
||||
struct sockaddr_in bind_addr;
|
||||
uv_ip4_addr("0.0.0.0", srv->port, &bind_addr);
|
||||
if ((err = uv_tcp_bind(&srv->server, (const struct sockaddr*)&bind_addr, 0)) != 0) {
|
||||
tError("failed to bind:%s", uv_err_name(err));
|
||||
return false;
|
||||
if ((code = uv_ip4_addr("0.0.0.0", srv->port, &bind_addr)) != 0) {
|
||||
tError("failed to bind addr since %s", uv_err_name(code));
|
||||
return TSDB_CODE_THIRDPARTY_ERROR;
|
||||
}
|
||||
if ((err = uv_listen((uv_stream_t*)&srv->server, 4096 * 2, uvOnAcceptCb)) != 0) {
|
||||
tError("failed to listen:%s", uv_err_name(err));
|
||||
terrno = TSDB_CODE_RPC_PORT_EADDRINUSE;
|
||||
return false;
|
||||
|
||||
if ((code = uv_tcp_bind(&srv->server, (const struct sockaddr*)&bind_addr, 0)) != 0) {
|
||||
tError("failed to bind since %s", uv_err_name(code));
|
||||
return TSDB_CODE_THIRDPARTY_ERROR;
|
||||
}
|
||||
return true;
|
||||
if ((code = uv_listen((uv_stream_t*)&srv->server, 4096 * 2, uvOnAcceptCb)) != 0) {
|
||||
tError("failed to listen since %s", uv_err_name(code));
|
||||
return TSDB_CODE_RPC_PORT_EADDRINUSE;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void* transWorkerThread(void* arg) {
|
||||
setThreadName("trans-svr-work");
|
||||
SWorkThrd* pThrd = (SWorkThrd*)arg;
|
||||
|
@ -1076,35 +1171,84 @@ void* transWorkerThread(void* arg) {
|
|||
}
|
||||
|
||||
static FORCE_INLINE SSvrConn* createConn(void* hThrd) {
|
||||
int32_t code = 0;
|
||||
SWorkThrd* pThrd = hThrd;
|
||||
|
||||
SSvrConn* pConn = (SSvrConn*)taosMemoryCalloc(1, sizeof(SSvrConn));
|
||||
if (pConn == NULL) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end);
|
||||
}
|
||||
|
||||
transReqQueueInit(&pConn->wreqQueue);
|
||||
QUEUE_INIT(&pConn->queue);
|
||||
|
||||
QUEUE_PUSH(&pThrd->conn, &pConn->queue);
|
||||
|
||||
transQueueInit(&pConn->srvMsgs, NULL);
|
||||
if ((code = transQueueInit(&pConn->srvMsgs, NULL)) != 0) {
|
||||
TAOS_CHECK_GOTO(code, NULL, _end);
|
||||
}
|
||||
|
||||
if ((code = transInitBuffer(&pConn->readBuf)) != 0) {
|
||||
TAOS_CHECK_GOTO(code, NULL, _end);
|
||||
}
|
||||
|
||||
memset(&pConn->regArg, 0, sizeof(pConn->regArg));
|
||||
pConn->broken = false;
|
||||
pConn->status = ConnNormal;
|
||||
transInitBuffer(&pConn->readBuf);
|
||||
|
||||
SExHandle* exh = taosMemoryMalloc(sizeof(SExHandle));
|
||||
if (exh == NULL) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end);
|
||||
}
|
||||
|
||||
exh->handle = pConn;
|
||||
exh->pThrd = pThrd;
|
||||
exh->refId = transAddExHandle(transGetRefMgt(), exh);
|
||||
if (exh->refId < 0) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_REF_INVALID_ID, NULL, _end);
|
||||
}
|
||||
|
||||
QUEUE_INIT(&exh->q);
|
||||
transAcquireExHandle(transGetRefMgt(), exh->refId);
|
||||
|
||||
SExHandle* pSelf = transAcquireExHandle(transGetRefMgt(), exh->refId);
|
||||
if (pSelf != exh) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_REF_INVALID_ID, NULL, _end);
|
||||
}
|
||||
|
||||
STrans* pTransInst = pThrd->pTransInst;
|
||||
pConn->refId = exh->refId;
|
||||
QUEUE_INIT(&exh->q);
|
||||
transRefSrvHandle(pConn);
|
||||
tTrace("%s handle %p, conn %p created, refId:%" PRId64, transLabel(pTransInst), exh, pConn, pConn->refId);
|
||||
|
||||
pConn->pTransInst = pThrd->pTransInst;
|
||||
/* init conn timer*/
|
||||
// uv_timer_init(pThrd->loop, &pConn->pTimer);
|
||||
// pConn->pTimer.data = pConn;
|
||||
pConn->hostThrd = pThrd;
|
||||
// init client handle
|
||||
pConn->pTcp = (uv_tcp_t*)taosMemoryMalloc(sizeof(uv_tcp_t));
|
||||
if (pConn->pTcp == NULL) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end);
|
||||
}
|
||||
|
||||
code = uv_tcp_init(pThrd->loop, pConn->pTcp);
|
||||
if (code != 0) {
|
||||
tError("%s failed to create conn since %s" PRId64, transLabel(pTransInst), uv_strerror(code));
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_THIRDPARTY_ERROR, NULL, _end);
|
||||
}
|
||||
pConn->pTcp->data = pConn;
|
||||
|
||||
return pConn;
|
||||
_end:
|
||||
if (pConn) {
|
||||
transQueueDestroy(&pConn->srvMsgs);
|
||||
transDestroyBuffer(&pConn->readBuf);
|
||||
taosMemoryFree(pConn->pTcp);
|
||||
taosMemoryFree(pConn);
|
||||
pConn = NULL;
|
||||
}
|
||||
tError("%s failed to create conn since %s" PRId64, transLabel(pTransInst), tstrerror(code));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static FORCE_INLINE void destroyConn(SSvrConn* conn, bool clear) {
|
||||
|
@ -1125,16 +1269,33 @@ static FORCE_INLINE void destroyConnRegArg(SSvrConn* conn) {
|
|||
conn->regArg.init = 0;
|
||||
}
|
||||
}
|
||||
static int reallocConnRef(SSvrConn* conn) {
|
||||
transReleaseExHandle(transGetRefMgt(), conn->refId);
|
||||
transRemoveExHandle(transGetRefMgt(), conn->refId);
|
||||
static int32_t reallocConnRef(SSvrConn* conn) {
|
||||
if (conn->refId > 0) {
|
||||
transReleaseExHandle(transGetRefMgt(), conn->refId);
|
||||
transRemoveExHandle(transGetRefMgt(), conn->refId);
|
||||
}
|
||||
// avoid app continue to send msg on invalid handle
|
||||
SExHandle* exh = taosMemoryMalloc(sizeof(SExHandle));
|
||||
if (exh == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
exh->handle = conn;
|
||||
exh->pThrd = conn->hostThrd;
|
||||
exh->refId = transAddExHandle(transGetRefMgt(), exh);
|
||||
if (exh->refId < 0) {
|
||||
taosMemoryFree(exh);
|
||||
return TSDB_CODE_REF_INVALID_ID;
|
||||
}
|
||||
|
||||
QUEUE_INIT(&exh->q);
|
||||
transAcquireExHandle(transGetRefMgt(), exh->refId);
|
||||
SExHandle* pSelf = transAcquireExHandle(transGetRefMgt(), exh->refId);
|
||||
if (pSelf != exh) {
|
||||
tError("conn %p failed to acquire handle", conn);
|
||||
taosMemoryFree(exh);
|
||||
return TSDB_CODE_REF_INVALID_ID;
|
||||
}
|
||||
|
||||
conn->refId = exh->refId;
|
||||
|
||||
return 0;
|
||||
|
@ -1204,24 +1365,41 @@ static void uvPipeListenCb(uv_stream_t* handle, int status) {
|
|||
}
|
||||
|
||||
void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads, void* fp, void* shandle) {
|
||||
int32_t code = 0;
|
||||
|
||||
SServerObj* srv = taosMemoryCalloc(1, sizeof(SServerObj));
|
||||
srv->loop = (uv_loop_t*)taosMemoryMalloc(sizeof(uv_loop_t));
|
||||
if (srv == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
tError("failed to init server since: %s", tstrerror(code));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
srv->ip = ip;
|
||||
srv->port = port;
|
||||
srv->numOfThreads = numOfThreads;
|
||||
srv->workerIdx = 0;
|
||||
srv->numOfWorkerReady = 0;
|
||||
srv->loop = (uv_loop_t*)taosMemoryMalloc(sizeof(uv_loop_t));
|
||||
srv->pThreadObj = (SWorkThrd**)taosMemoryCalloc(srv->numOfThreads, sizeof(SWorkThrd*));
|
||||
srv->pipe = (uv_pipe_t**)taosMemoryCalloc(srv->numOfThreads, sizeof(uv_pipe_t*));
|
||||
srv->ip = ip;
|
||||
srv->port = port;
|
||||
uv_loop_init(srv->loop);
|
||||
if (srv->loop == NULL || srv->pThreadObj == NULL || srv->pipe == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto End;
|
||||
}
|
||||
|
||||
char pipeName[PATH_MAX];
|
||||
code = uv_loop_init(srv->loop);
|
||||
if (code != 0) {
|
||||
tError("failed to init server since: %s", uv_err_name(code));
|
||||
code = TSDB_CODE_THIRDPARTY_ERROR;
|
||||
goto End;
|
||||
}
|
||||
|
||||
if (false == taosValidIpAndPort(srv->ip, srv->port)) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
tError("invalid ip/port, %d:%d, reason:%s", srv->ip, srv->port, terrstr());
|
||||
goto End;
|
||||
}
|
||||
char pipeName[PATH_MAX];
|
||||
|
||||
#if defined(WINDOWS) || defined(DARWIN)
|
||||
int ret = uv_pipe_init(srv->loop, &srv->pipeListen, 0);
|
||||
|
@ -1259,7 +1437,7 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
|
|||
srv->pipe[i] = (uv_pipe_t*)taosMemoryCalloc(2, sizeof(uv_pipe_t));
|
||||
thrd->pipe = &(srv->pipe[i][1]); // init read
|
||||
|
||||
if (false == addHandleToWorkloop(thrd, pipeName)) {
|
||||
if ((code = addHandleToWorkloop(thrd, pipeName)) != 0) {
|
||||
goto End;
|
||||
}
|
||||
|
||||
|
@ -1276,27 +1454,53 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
|
|||
|
||||
for (int i = 0; i < srv->numOfThreads; i++) {
|
||||
SWorkThrd* thrd = (SWorkThrd*)taosMemoryCalloc(1, sizeof(SWorkThrd));
|
||||
if (thrd == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto End;
|
||||
}
|
||||
|
||||
thrd->pTransInst = shandle;
|
||||
thrd->quit = false;
|
||||
thrd->pTransInst = shandle;
|
||||
thrd->pWhiteList = uvWhiteListCreate();
|
||||
|
||||
srv->pipe[i] = (uv_pipe_t*)taosMemoryCalloc(2, sizeof(uv_pipe_t));
|
||||
srv->pThreadObj[i] = thrd;
|
||||
|
||||
uv_os_sock_t fds[2];
|
||||
if (uv_socketpair(SOCK_STREAM, 0, fds, UV_NONBLOCK_PIPE, UV_NONBLOCK_PIPE) != 0) {
|
||||
if (thrd->pWhiteList == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto End;
|
||||
}
|
||||
|
||||
uv_pipe_init(srv->loop, &(srv->pipe[i][0]), 1);
|
||||
uv_pipe_open(&(srv->pipe[i][0]), fds[1]);
|
||||
srv->pipe[i] = (uv_pipe_t*)taosMemoryCalloc(2, sizeof(uv_pipe_t));
|
||||
if (srv->pipe[i] == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto End;
|
||||
}
|
||||
|
||||
srv->pThreadObj[i] = thrd;
|
||||
|
||||
uv_os_sock_t fds[2];
|
||||
if ((code = uv_socketpair(SOCK_STREAM, 0, fds, UV_NONBLOCK_PIPE, UV_NONBLOCK_PIPE)) != 0) {
|
||||
tError("failed to create pipe, errmsg: %s", uv_err_name(code));
|
||||
code = TSDB_CODE_THIRDPARTY_ERROR;
|
||||
goto End;
|
||||
}
|
||||
|
||||
code = uv_pipe_init(srv->loop, &(srv->pipe[i][0]), 1);
|
||||
if (code != 0) {
|
||||
tError("failed to init pipe, errmsg: %s", uv_err_name(code));
|
||||
code = TSDB_CODE_THIRDPARTY_ERROR;
|
||||
goto End;
|
||||
}
|
||||
|
||||
code = uv_pipe_open(&(srv->pipe[i][0]), fds[1]);
|
||||
if (code != 0) {
|
||||
tError("failed to init pipe, errmsg: %s", uv_err_name(code));
|
||||
code = TSDB_CODE_THIRDPARTY_ERROR;
|
||||
goto End;
|
||||
}
|
||||
|
||||
thrd->pipe = &(srv->pipe[i][1]); // init read
|
||||
thrd->fd = fds[0];
|
||||
|
||||
if (false == addHandleToWorkloop(thrd, pipeName)) {
|
||||
if ((code = addHandleToWorkloop(thrd, pipeName)) != 0) {
|
||||
goto End;
|
||||
}
|
||||
|
||||
|
@ -1311,15 +1515,17 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
|
|||
}
|
||||
#endif
|
||||
|
||||
if (false == addHandleToAcceptloop(srv)) {
|
||||
if ((code = addHandleToAcceptloop(srv)) != 0) {
|
||||
goto End;
|
||||
}
|
||||
|
||||
int err = taosThreadCreate(&srv->thread, NULL, transAcceptThread, (void*)srv);
|
||||
if (err == 0) {
|
||||
code = taosThreadCreate(&srv->thread, NULL, transAcceptThread, (void*)srv);
|
||||
if (code == 0) {
|
||||
tDebug("success to create accept-thread");
|
||||
} else {
|
||||
tError("failed to create accept-thread");
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
tError("failed to create accept-thread since %s", tstrerror(code));
|
||||
|
||||
goto End;
|
||||
// clear all resource later
|
||||
}
|
||||
|
@ -1328,6 +1534,7 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
|
|||
return srv;
|
||||
End:
|
||||
transCloseServer(srv);
|
||||
terrno = code;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1341,9 +1548,14 @@ void uvHandleQuit(SSvrMsg* msg, SWorkThrd* thrd) {
|
|||
taosMemoryFree(msg);
|
||||
}
|
||||
void uvHandleRelease(SSvrMsg* msg, SWorkThrd* thrd) {
|
||||
int32_t code = 0;
|
||||
SSvrConn* conn = msg->pConn;
|
||||
if (conn->status == ConnAcquire) {
|
||||
reallocConnRef(conn);
|
||||
code = reallocConnRef(conn);
|
||||
if (code != 0) {
|
||||
destroyConn(conn, true);
|
||||
return;
|
||||
}
|
||||
if (!transQueuePush(&conn->srvMsgs, msg)) {
|
||||
return;
|
||||
}
|
||||
|
@ -1387,30 +1599,43 @@ void uvHandleRegister(SSvrMsg* msg, SWorkThrd* thrd) {
|
|||
}
|
||||
void uvHandleUpdate(SSvrMsg* msg, SWorkThrd* thrd) {
|
||||
SUpdateIpWhite* req = msg->arg;
|
||||
if (req != NULL) {
|
||||
for (int i = 0; i < req->numOfUser; i++) {
|
||||
SUpdateUserIpWhite* pUser = &req->pUserIpWhite[i];
|
||||
|
||||
int32_t sz = pUser->numOfRange * sizeof(SIpV4Range);
|
||||
SIpWhiteList* pList = taosMemoryCalloc(1, sz + sizeof(SIpWhiteList));
|
||||
pList->num = pUser->numOfRange;
|
||||
|
||||
memcpy(pList->pIpRange, pUser->pIpRanges, sz);
|
||||
uvWhiteListAdd(thrd->pWhiteList, pUser->user, pList, pUser->ver);
|
||||
}
|
||||
|
||||
thrd->pWhiteList->ver = req->ver;
|
||||
thrd->enableIpWhiteList = 1;
|
||||
|
||||
tFreeSUpdateIpWhiteReq(req);
|
||||
taosMemoryFree(req);
|
||||
} else {
|
||||
if (req == NULL) {
|
||||
tDebug("ip-white-list disable on trans");
|
||||
thrd->enableIpWhiteList = 0;
|
||||
taosMemoryFree(msg);
|
||||
return;
|
||||
}
|
||||
int32_t code = 0;
|
||||
for (int i = 0; i < req->numOfUser; i++) {
|
||||
SUpdateUserIpWhite* pUser = &req->pUserIpWhite[i];
|
||||
|
||||
int32_t sz = pUser->numOfRange * sizeof(SIpV4Range);
|
||||
|
||||
SIpWhiteList* pList = taosMemoryCalloc(1, sz + sizeof(SIpWhiteList));
|
||||
if (pList == NULL) {
|
||||
tError("failed to create ip-white-list since %s", tstrerror(code));
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
break;
|
||||
}
|
||||
pList->num = pUser->numOfRange;
|
||||
memcpy(pList->pIpRange, pUser->pIpRanges, sz);
|
||||
code = uvWhiteListAdd(thrd->pWhiteList, pUser->user, pList, pUser->ver);
|
||||
if (code != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (code == 0) {
|
||||
thrd->pWhiteList->ver = req->ver;
|
||||
thrd->enableIpWhiteList = 1;
|
||||
} else {
|
||||
tError("failed to update ip-white-list since %s", tstrerror(code));
|
||||
}
|
||||
tFreeSUpdateIpWhiteReq(req);
|
||||
taosMemoryFree(req);
|
||||
taosMemoryFree(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
void destroyWorkThrd(SWorkThrd* pThrd) {
|
||||
if (pThrd == NULL) {
|
||||
return;
|
||||
|
@ -1483,6 +1708,7 @@ void transUnrefSrvHandle(void* handle) {
|
|||
}
|
||||
|
||||
int transReleaseSrvHandle(void* handle) {
|
||||
int32_t code = 0;
|
||||
SRpcHandleInfo* info = handle;
|
||||
SExHandle* exh = info->handle;
|
||||
int64_t refId = info->refId;
|
||||
|
@ -1495,12 +1721,19 @@ int transReleaseSrvHandle(void* handle) {
|
|||
STransMsg tmsg = {.code = 0, .info.handle = exh, .info.ahandle = NULL, .info.refId = refId};
|
||||
|
||||
SSvrMsg* m = taosMemoryCalloc(1, sizeof(SSvrMsg));
|
||||
if (m == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _return1;
|
||||
}
|
||||
|
||||
m->msg = tmsg;
|
||||
m->type = Release;
|
||||
|
||||
tDebug("%s conn %p start to release", transLabel(pThrd->pTransInst), exh->handle);
|
||||
if (0 != transAsyncSend(pThrd->asyncPool, &m->q)) {
|
||||
if ((code = transAsyncSend(pThrd->asyncPool, &m->q)) != 0) {
|
||||
destroySmsg(m);
|
||||
transReleaseExHandle(transGetRefMgt(), refId);
|
||||
return code;
|
||||
}
|
||||
|
||||
transReleaseExHandle(transGetRefMgt(), refId);
|
||||
|
@ -1508,13 +1741,15 @@ int transReleaseSrvHandle(void* handle) {
|
|||
_return1:
|
||||
tDebug("handle %p failed to send to release handle", exh);
|
||||
transReleaseExHandle(transGetRefMgt(), refId);
|
||||
return -1;
|
||||
return code;
|
||||
_return2:
|
||||
tDebug("handle %p failed to send to release handle", exh);
|
||||
return -1;
|
||||
return code;
|
||||
}
|
||||
|
||||
int transSendResponse(const STransMsg* msg) {
|
||||
int32_t code = 0;
|
||||
|
||||
if (msg->info.noResp) {
|
||||
rpcFreeCont(msg->pCont);
|
||||
tTrace("no need send resp");
|
||||
|
@ -1536,13 +1771,20 @@ int transSendResponse(const STransMsg* msg) {
|
|||
ASYNC_ERR_JRET(pThrd);
|
||||
|
||||
SSvrMsg* m = taosMemoryCalloc(1, sizeof(SSvrMsg));
|
||||
if (m == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _return1;
|
||||
}
|
||||
|
||||
m->msg = tmsg;
|
||||
m->type = Normal;
|
||||
|
||||
STraceId* trace = (STraceId*)&msg->info.traceId;
|
||||
tGDebug("conn %p start to send resp (1/2)", exh->handle);
|
||||
if (0 != transAsyncSend(pThrd->asyncPool, &m->q)) {
|
||||
if ((code = transAsyncSend(pThrd->asyncPool, &m->q)) != 0) {
|
||||
destroySmsg(m);
|
||||
transReleaseExHandle(transGetRefMgt(), refId);
|
||||
return code;
|
||||
}
|
||||
|
||||
transReleaseExHandle(transGetRefMgt(), refId);
|
||||
|
@ -1552,13 +1794,15 @@ _return1:
|
|||
tDebug("handle %p failed to send resp", exh);
|
||||
rpcFreeCont(msg->pCont);
|
||||
transReleaseExHandle(transGetRefMgt(), refId);
|
||||
return -1;
|
||||
return code;
|
||||
_return2:
|
||||
tDebug("handle %p failed to send resp", exh);
|
||||
rpcFreeCont(msg->pCont);
|
||||
return -1;
|
||||
return code;
|
||||
}
|
||||
int transRegisterMsg(const STransMsg* msg) {
|
||||
int32_t code = 0;
|
||||
|
||||
SExHandle* exh = msg->info.handle;
|
||||
int64_t refId = msg->info.refId;
|
||||
ASYNC_CHECK_HANDLE(exh, refId);
|
||||
|
@ -1572,13 +1816,20 @@ int transRegisterMsg(const STransMsg* msg) {
|
|||
ASYNC_ERR_JRET(pThrd);
|
||||
|
||||
SSvrMsg* m = taosMemoryCalloc(1, sizeof(SSvrMsg));
|
||||
if (m == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _return1;
|
||||
}
|
||||
|
||||
m->msg = tmsg;
|
||||
m->type = Register;
|
||||
|
||||
STrans* pTransInst = pThrd->pTransInst;
|
||||
tDebug("%s conn %p start to register brokenlink callback", transLabel(pTransInst), exh->handle);
|
||||
if (0 != transAsyncSend(pThrd->asyncPool, &m->q)) {
|
||||
if ((code = transAsyncSend(pThrd->asyncPool, &m->q)) != 0) {
|
||||
destroySmsg(m);
|
||||
transReleaseExHandle(transGetRefMgt(), refId);
|
||||
return code;
|
||||
}
|
||||
|
||||
transReleaseExHandle(transGetRefMgt(), refId);
|
||||
|
@ -1588,29 +1839,56 @@ _return1:
|
|||
tDebug("handle %p failed to register brokenlink", exh);
|
||||
rpcFreeCont(msg->pCont);
|
||||
transReleaseExHandle(transGetRefMgt(), refId);
|
||||
return -1;
|
||||
return code;
|
||||
_return2:
|
||||
tDebug("handle %p failed to register brokenlink", exh);
|
||||
rpcFreeCont(msg->pCont);
|
||||
return -1;
|
||||
return code;
|
||||
}
|
||||
void transSetIpWhiteList(void* thandle, void* arg, FilteFunc* func) {
|
||||
|
||||
int32_t transSetIpWhiteList(void* thandle, void* arg, FilteFunc* func) {
|
||||
STrans* pTransInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)thandle);
|
||||
if (pTransInst == NULL) {
|
||||
return TSDB_CODE_RPC_MODULE_QUIT;
|
||||
}
|
||||
|
||||
int32_t code = 0;
|
||||
|
||||
tDebug("ip-white-list update on rpc");
|
||||
SServerObj* svrObj = pTransInst->tcphandle;
|
||||
for (int i = 0; i < svrObj->numOfThreads; i++) {
|
||||
SWorkThrd* pThrd = svrObj->pThreadObj[i];
|
||||
|
||||
SSvrMsg* msg = taosMemoryCalloc(1, sizeof(SSvrMsg));
|
||||
SUpdateIpWhite* pReq = (arg != NULL ? cloneSUpdateIpWhiteReq((SUpdateIpWhite*)arg) : NULL);
|
||||
SSvrMsg* msg = taosMemoryCalloc(1, sizeof(SSvrMsg));
|
||||
if (msg == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
break;
|
||||
}
|
||||
|
||||
SUpdateIpWhite* pReq = NULL;
|
||||
code = cloneSUpdateIpWhiteReq((SUpdateIpWhite*)arg, &pReq);
|
||||
if (code != 0) {
|
||||
taosMemoryFree(msg);
|
||||
break;
|
||||
}
|
||||
|
||||
msg->type = Update;
|
||||
msg->arg = pReq;
|
||||
|
||||
transAsyncSend(pThrd->asyncPool, &msg->q);
|
||||
if ((code = transAsyncSend(pThrd->asyncPool, &msg->q)) != 0) {
|
||||
code = (code == TSDB_CODE_RPC_ASYNC_MODULE_QUIT ? TSDB_CODE_RPC_MODULE_QUIT : code);
|
||||
tFreeSUpdateIpWhiteReq(pReq);
|
||||
taosMemoryFree(pReq);
|
||||
taosMemoryFree(msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
transReleaseExHandle(transGetInstMgt(), (int64_t)thandle);
|
||||
|
||||
if (code != 0) {
|
||||
tError("ip-white-list update failed since %s", tstrerror(code));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
int transGetConnInfo(void* thandle, STransHandleInfo* pConnInfo) { return -1; }
|
||||
|
|
|
@ -55,8 +55,10 @@ TAOS_DEFINE_ERROR(TSDB_CODE_RPC_TIMEOUT, "Conn read timeout")
|
|||
TAOS_DEFINE_ERROR(TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED, "some vnode/qnode/mnode(s) out of service")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_RPC_MAX_SESSIONS, "rpc open too many session")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_RPC_NETWORK_ERROR, "rpc network error")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_RPC_NETWORK_BUSY, "rpc network busy")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_HTTP_MODULE_QUIT, "http-report already quit")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_RPC_NETWORK_BUSY, "rpc network busy")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_HTTP_MODULE_QUIT, "http-report already quit")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_RPC_MODULE_QUIT, "rpc module already quit")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_RPC_ASYNC_MODULE_QUIT, "rpc async module already quit")
|
||||
|
||||
//common & util
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TIME_UNSYNCED, "Client and server's time is not synchronized")
|
||||
|
|
|
@ -189,11 +189,11 @@ run tsim/stream/checkTaskStatus.sim
|
|||
sql insert into t2 values(1648791213001,1,1,3,1.0,1);
|
||||
sql insert into t2 values(1648791213002,2,2,6,3.4,2);
|
||||
sql insert into t2 values(1648791213003,4,9,3,4.8,3);
|
||||
sql insert into t2 values(1648791233003,3,4,3,2.1,4);
|
||||
sql insert into t2 values(1648791233004,3,5,3,3.4,5);
|
||||
sql insert into t2 values(1648791233005,3,6,3,7.6,6);
|
||||
|
||||
#
|
||||
sql insert into t2 values(1648791233003,3,4,3,2.1,4) (1648791233004,3,5,3,3.4,5) (1648791233005,3,6,3,7.6,6);
|
||||
|
||||
sleep 1000
|
||||
|
||||
sql insert into t2 values(1648791223003,20,7,3,10.1,7);
|
||||
|
||||
$loop_count = 0
|
||||
|
|
Loading…
Reference in New Issue