Merge pull request #17131 from taosdata/fix/TD-19254-D
fix: coverity scan for sma
This commit is contained in:
commit
4ca305fd7a
|
@ -872,7 +872,7 @@ SArray *metaGetSmaIdsByTable(SMeta *pMeta, tb_uid_t uid) {
|
||||||
|
|
||||||
pSmaIdxKey = (SSmaIdxKey *)pCur->pKey;
|
pSmaIdxKey = (SSmaIdxKey *)pCur->pKey;
|
||||||
|
|
||||||
if (taosArrayPush(pUids, &pSmaIdxKey->smaUid) < 0) {
|
if (!taosArrayPush(pUids, &pSmaIdxKey->smaUid)) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
metaCloseSmaCursor(pCur);
|
metaCloseSmaCursor(pCur);
|
||||||
taosArrayDestroy(pUids);
|
taosArrayDestroy(pUids);
|
||||||
|
@ -915,7 +915,7 @@ SArray *metaGetSmaTbUids(SMeta *pMeta) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosArrayPush(pUids, &uid) < 0) {
|
if (!taosArrayPush(pUids, &uid)) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
metaCloseSmaCursor(pCur);
|
metaCloseSmaCursor(pCur);
|
||||||
taosArrayDestroy(pUids);
|
taosArrayDestroy(pUids);
|
||||||
|
|
|
@ -213,7 +213,7 @@ static int32_t tdUpdateQTaskInfoFiles(SSma *pSma, SRSmaStat *pStat) {
|
||||||
tdRSmaQTaskInfoGetFullName(TD_VID(pVnode), committed, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFullName);
|
tdRSmaQTaskInfoGetFullName(TD_VID(pVnode), committed, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFullName);
|
||||||
if (taosCheckExistFile(qTaskInfoFullName)) {
|
if (taosCheckExistFile(qTaskInfoFullName)) {
|
||||||
SQTaskFile qFile = {.nRef = 1, .padding = 0, .version = committed, .size = 0};
|
SQTaskFile qFile = {.nRef = 1, .padding = 0, .version = committed, .size = 0};
|
||||||
if (taosArrayPush(pFS->aQTaskInf, &qFile) < 0) {
|
if (!taosArrayPush(pFS->aQTaskInf, &qFile)) {
|
||||||
taosWUnLockLatch(RSMA_FS_LOCK(pStat));
|
taosWUnLockLatch(RSMA_FS_LOCK(pStat));
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
|
|
|
@ -386,7 +386,7 @@ int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
smaError("vgId:%d, undefined smaType:%", SMA_VID(pSma), smaType);
|
smaError("vgId:%d, undefined smaType:%" PRIi8, SMA_VID(pSma), smaType);
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ int32_t tdRSmaFSOpen(SSma *pSma, int64_t version) {
|
||||||
if ((terrno = tdRSmaFSUpsertQTaskFile(RSMA_FS(pStat), &qTaskFile)) < 0) {
|
if ((terrno = tdRSmaFSUpsertQTaskFile(RSMA_FS(pStat), &qTaskFile)) < 0) {
|
||||||
goto _end;
|
goto _end;
|
||||||
}
|
}
|
||||||
smaInfo("vgId:%d, open fs, version:%" PRIi64 ", ref:%" PRIi64, TD_VID(pVnode), qTaskFile.version, qTaskFile.nRef);
|
smaInfo("vgId:%d, open fs, version:%" PRIi64 ", ref:%d", TD_VID(pVnode), qTaskFile.version, qTaskFile.nRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
_end:
|
_end:
|
||||||
|
|
|
@ -196,7 +196,8 @@ static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids,
|
||||||
|
|
||||||
if (!suid || !tbUids) {
|
if (!suid || !tbUids) {
|
||||||
terrno = TSDB_CODE_INVALID_PTR;
|
terrno = TSDB_CODE_INVALID_PTR;
|
||||||
smaError("vgId:%d, failed to get rsma info for uid:%" PRIi64 " since %s", SMA_VID(pSma), *suid, terrstr());
|
smaError("vgId:%d, failed to get rsma info for uid:%" PRIi64 " since %s", SMA_VID(pSma), suid ? *suid : -1,
|
||||||
|
terrstr());
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -566,6 +567,7 @@ static int32_t tdUidStorePut(STbUidStore *pStore, tb_uid_t suid, tb_uid_t *uid)
|
||||||
}
|
}
|
||||||
if (!taosArrayPush(pUidArray, uid)) {
|
if (!taosArrayPush(pUidArray, uid)) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
taosArrayDestroy(pUidArray);
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
if (taosHashPut(pStore->uidHash, &suid, sizeof(suid), &pUidArray, sizeof(pUidArray)) < 0) {
|
if (taosHashPut(pStore->uidHash, &suid, sizeof(suid), &pUidArray, sizeof(pUidArray)) < 0) {
|
||||||
|
@ -1678,13 +1680,13 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
|
||||||
SRSmaInfoItem *pItem = NULL;
|
SRSmaInfoItem *pItem = NULL;
|
||||||
|
|
||||||
if (!(pRSmaRef = taosHashGet(smaMgmt.refHash, ¶m, POINTER_BYTES))) {
|
if (!(pRSmaRef = taosHashGet(smaMgmt.refHash, ¶m, POINTER_BYTES))) {
|
||||||
smaDebug("rsma fetch task not start since rsma info item:%p not exist in refHash:%p, rsetId:%" PRIi64, param,
|
smaDebug("rsma fetch task not start since rsma info item:%p not exist in refHash:%p, rsetId:%d", param,
|
||||||
*(int64_t *)¶m, smaMgmt.refHash, smaMgmt.rsetId);
|
smaMgmt.refHash, smaMgmt.rsetId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(pStat = (SRSmaStat *)tdAcquireSmaRef(smaMgmt.rsetId, pRSmaRef->refId))) {
|
if (!(pStat = (SRSmaStat *)tdAcquireSmaRef(smaMgmt.rsetId, pRSmaRef->refId))) {
|
||||||
smaDebug("rsma fetch task not start since rsma stat already destroyed, rsetId:%" PRIi64 " refId:%d)",
|
smaDebug("rsma fetch task not start since rsma stat already destroyed, rsetId:%d refId:%" PRIi64 ")",
|
||||||
smaMgmt.rsetId, pRSmaRef->refId); // pRSmaRef freed in taosHashRemove
|
smaMgmt.rsetId, pRSmaRef->refId); // pRSmaRef freed in taosHashRemove
|
||||||
taosHashRemove(smaMgmt.refHash, ¶m, POINTER_BYTES);
|
taosHashRemove(smaMgmt.refHash, ¶m, POINTER_BYTES);
|
||||||
return;
|
return;
|
||||||
|
@ -1693,7 +1695,7 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
|
||||||
pSma = pStat->pSma;
|
pSma = pStat->pSma;
|
||||||
|
|
||||||
if (!(pRSmaInfo = tdAcquireRSmaInfoBySuid(pSma, pRSmaRef->suid))) {
|
if (!(pRSmaInfo = tdAcquireRSmaInfoBySuid(pSma, pRSmaRef->suid))) {
|
||||||
smaDebug("rsma fetch task not start since rsma info not exist, rsetId:%" PRIi64 " refId:%d)", smaMgmt.rsetId,
|
smaDebug("rsma fetch task not start since rsma info not exist, rsetId:%d refId:%" PRIi64 ")", smaMgmt.rsetId,
|
||||||
pRSmaRef->refId); // pRSmaRef freed in taosHashRemove
|
pRSmaRef->refId); // pRSmaRef freed in taosHashRemove
|
||||||
tdReleaseSmaRef(smaMgmt.rsetId, pRSmaRef->refId);
|
tdReleaseSmaRef(smaMgmt.rsetId, pRSmaRef->refId);
|
||||||
taosHashRemove(smaMgmt.refHash, ¶m, POINTER_BYTES);
|
taosHashRemove(smaMgmt.refHash, ¶m, POINTER_BYTES);
|
||||||
|
@ -1701,7 +1703,7 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RSMA_INFO_IS_DEL(pRSmaInfo)) {
|
if (RSMA_INFO_IS_DEL(pRSmaInfo)) {
|
||||||
smaDebug("rsma fetch task not start since rsma info already deleted, rsetId:%" PRIi64 " refId:%d)", smaMgmt.rsetId,
|
smaDebug("rsma fetch task not start since rsma info already deleted, rsetId:%d refId:%" PRIi64 ")", smaMgmt.rsetId,
|
||||||
pRSmaRef->refId); // pRSmaRef freed in taosHashRemove
|
pRSmaRef->refId); // pRSmaRef freed in taosHashRemove
|
||||||
tdReleaseRSmaInfo(pSma, pRSmaInfo);
|
tdReleaseRSmaInfo(pSma, pRSmaInfo);
|
||||||
tdReleaseSmaRef(smaMgmt.rsetId, pRSmaRef->refId);
|
tdReleaseSmaRef(smaMgmt.rsetId, pRSmaRef->refId);
|
||||||
|
@ -1717,7 +1719,7 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
|
||||||
case TASK_TRIGGER_STAT_PAUSED:
|
case TASK_TRIGGER_STAT_PAUSED:
|
||||||
case TASK_TRIGGER_STAT_CANCELLED: {
|
case TASK_TRIGGER_STAT_CANCELLED: {
|
||||||
smaDebug("vgId:%d, rsma fetch task not start for level %" PRIi8 " since stat is %" PRIi8
|
smaDebug("vgId:%d, rsma fetch task not start for level %" PRIi8 " since stat is %" PRIi8
|
||||||
", rsetId rsetId:%" PRIi64 " refId:%d",
|
", rsetId:%d refId:%" PRIi64,
|
||||||
SMA_VID(pSma), pItem->level, rsmaTriggerStat, smaMgmt.rsetId, pRSmaRef->refId);
|
SMA_VID(pSma), pItem->level, rsmaTriggerStat, smaMgmt.rsetId, pRSmaRef->refId);
|
||||||
if (rsmaTriggerStat == TASK_TRIGGER_STAT_PAUSED) {
|
if (rsmaTriggerStat == TASK_TRIGGER_STAT_PAUSED) {
|
||||||
taosTmrReset(tdRSmaFetchTrigger, RSMA_FETCH_INTERVAL, pItem, smaMgmt.tmrHandle, &pItem->tmrId);
|
taosTmrReset(tdRSmaFetchTrigger, RSMA_FETCH_INTERVAL, pItem, smaMgmt.tmrHandle, &pItem->tmrId);
|
||||||
|
@ -1845,7 +1847,7 @@ static int32_t tdRSmaBatchExec(SSma *pSma, SRSmaInfo *pInfo, STaosQall *qall, SA
|
||||||
void *msg = NULL;
|
void *msg = NULL;
|
||||||
taosGetQitem(qall, (void **)&msg);
|
taosGetQitem(qall, (void **)&msg);
|
||||||
if (msg) {
|
if (msg) {
|
||||||
if (taosArrayPush(pSubmitArr, &msg) < 0) {
|
if (!taosArrayPush(pSubmitArr, &msg)) {
|
||||||
tdFreeRSmaSubmitItems(pSubmitArr);
|
tdFreeRSmaSubmitItems(pSubmitArr);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,8 @@ int32_t rsmaSnapReaderOpen(SSma* pSma, int64_t sver, int64_t ever, SRSmaSnapRead
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
_err:
|
_err:
|
||||||
|
if (pReader) rsmaSnapReaderClose(&pReader);
|
||||||
|
*ppReader = NULL;
|
||||||
smaError("vgId:%d, vnode snapshot rsma reader open failed since %s", TD_VID(pVnode), tstrerror(code));
|
smaError("vgId:%d, vnode snapshot rsma reader open failed since %s", TD_VID(pVnode), tstrerror(code));
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
@ -101,8 +103,8 @@ static int32_t rsmaQTaskInfSnapReaderOpen(SRSmaSnapReader* pReader, int64_t vers
|
||||||
|
|
||||||
if (!taosCheckExistFile(qTaskInfoFullName)) {
|
if (!taosCheckExistFile(qTaskInfoFullName)) {
|
||||||
tdRSmaFSUnRef(pSma, pStat, version);
|
tdRSmaFSUnRef(pSma, pStat, version);
|
||||||
smaInfo("vgId:%d, vnode snapshot rsma reader for qtaskinfo version %" PRIi64 " not need as %s not exists",
|
smaInfo("vgId:%d, vnode snapshot rsma reader for qtaskinfo version %" PRIi64 " not need as %s not exist",
|
||||||
TD_VID(pVnode), qTaskInfoFullName);
|
TD_VID(pVnode), version, qTaskInfoFullName);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,6 +338,7 @@ int32_t rsmaSnapWriterOpen(SSma* pSma, int64_t sver, int64_t ever, SRSmaSnapWrit
|
||||||
tdRSmaQTaskInfoGetFullName(TD_VID(pVnode), 0, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFullName);
|
tdRSmaQTaskInfoGetFullName(TD_VID(pVnode), 0, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFullName);
|
||||||
TdFilePtr qTaskF = taosCreateFile(qTaskInfoFullName, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
|
TdFilePtr qTaskF = taosCreateFile(qTaskInfoFullName, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
|
||||||
if (!qTaskF) {
|
if (!qTaskF) {
|
||||||
|
taosMemoryFree(qWriter);
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
smaError("vgId:%d, rsma snapshot writer open %s failed since %s", TD_VID(pSma->pVnode), qTaskInfoFullName,
|
smaError("vgId:%d, rsma snapshot writer open %s failed since %s", TD_VID(pSma->pVnode), qTaskInfoFullName,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
|
@ -356,6 +359,7 @@ int32_t rsmaSnapWriterOpen(SSma* pSma, int64_t sver, int64_t ever, SRSmaSnapWrit
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
smaError("vgId:%d, rsma snapshot writer open failed since %s", TD_VID(pSma->pVnode), tstrerror(code));
|
smaError("vgId:%d, rsma snapshot writer open failed since %s", TD_VID(pSma->pVnode), tstrerror(code));
|
||||||
|
if (pWriter) rsmaSnapWriterClose(&pWriter, 0);
|
||||||
*ppWriter = NULL;
|
*ppWriter = NULL;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -449,11 +453,11 @@ static int32_t rsmaSnapWriteQTaskInfo(SRSmaSnapWriter* pWriter, uint8_t* pData,
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
smaInfo("vgId:%d, vnode snapshot rsma write qtaskinfo %s succeed", SMA_VID(pWriter->pSma), qWriter->fname);
|
||||||
} else {
|
} else {
|
||||||
smaInfo("vgId:%d, vnode snapshot rsma write qtaskinfo is not needed", SMA_VID(pWriter->pSma));
|
smaInfo("vgId:%d, vnode snapshot rsma write qtaskinfo is not needed", SMA_VID(pWriter->pSma));
|
||||||
}
|
}
|
||||||
|
|
||||||
smaInfo("vgId:%d, vnode snapshot rsma write qtaskinfo %s succeed", SMA_VID(pWriter->pSma), qWriter->fname);
|
|
||||||
_exit:
|
_exit:
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
|
|
|
@ -290,19 +290,19 @@ int32_t tdRemoveTFile(STFile *pTFile) {
|
||||||
void *tdAcquireSmaRef(int32_t rsetId, int64_t refId) {
|
void *tdAcquireSmaRef(int32_t rsetId, int64_t refId) {
|
||||||
void *pResult = taosAcquireRef(rsetId, refId);
|
void *pResult = taosAcquireRef(rsetId, refId);
|
||||||
if (!pResult) {
|
if (!pResult) {
|
||||||
smaWarn("rsma acquire ref for rsetId:%" PRIi64 " refId:%d failed since %s", rsetId, refId, terrstr());
|
smaWarn("rsma acquire ref for rsetId:%d refId:%" PRIi64 " failed since %s", rsetId, refId, terrstr());
|
||||||
} else {
|
} else {
|
||||||
smaDebug("rsma acquire ref for rsetId:%" PRIi64 " refId:%d success", rsetId, refId);
|
smaDebug("rsma acquire ref for rsetId:%d refId:%" PRIi64 " success", rsetId, refId);
|
||||||
}
|
}
|
||||||
return pResult;
|
return pResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tdReleaseSmaRef(int32_t rsetId, int64_t refId) {
|
int32_t tdReleaseSmaRef(int32_t rsetId, int64_t refId) {
|
||||||
if (taosReleaseRef(rsetId, refId) < 0) {
|
if (taosReleaseRef(rsetId, refId) < 0) {
|
||||||
smaWarn("rsma release ref for rsetId:%" PRIi64 " refId:%d failed since %s", rsetId, refId, terrstr());
|
smaWarn("rsma release ref for rsetId:%d refId:%" PRIi64 " failed since %s", rsetId, refId, terrstr());
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
smaDebug("rsma release ref for rsetId:%" PRIi64 " refId:%d success", rsetId, refId);
|
smaDebug("rsma release ref for rsetId:%d refId:%" PRIi64 " success", rsetId, refId);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
|
@ -29,7 +29,7 @@ SStreamState* streamStateOpen(char* path, SStreamTask* pTask, bool specPath) {
|
||||||
if (!specPath) {
|
if (!specPath) {
|
||||||
sprintf(statePath, "%s/%d", path, pTask->taskId);
|
sprintf(statePath, "%s/%d", path, pTask->taskId);
|
||||||
} else {
|
} else {
|
||||||
memcpy(statePath, path, 300);
|
strncpy(statePath, path, 300);
|
||||||
}
|
}
|
||||||
if (tdbOpen(statePath, 4096, 256, &pState->db) < 0) {
|
if (tdbOpen(statePath, 4096, 256, &pState->db) < 0) {
|
||||||
goto _err;
|
goto _err;
|
||||||
|
|
Loading…
Reference in New Issue