diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index 99e171dde1785f7aab55ab0f97b28f248744545d..ca9bc17e0104039a834325a63b69228b004c5a0d 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -1352,7 +1352,7 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) { } if (!(pStat = (SRSmaStat *)tdAcquireSmaRef(smaMgmt.rsetId, pRSmaRef->refId))) { - smaDebug("rsma fetch task not start since rsma stat already destroyed, rsetId:%d refId:%" PRIi64 ")", + smaWarn("rsma fetch task not start since rsma stat already destroyed, rsetId:%d refId:%" PRIi64 ")", smaMgmt.rsetId, pRSmaRef->refId); // pRSmaRef freed in taosHashRemove taosHashRemove(smaMgmt.refHash, ¶m, POINTER_BYTES); return; diff --git a/source/dnode/vnode/src/sma/smaTimeRange.c b/source/dnode/vnode/src/sma/smaTimeRange.c index 5058a7fc76e16c85881a2f7fad30ca8109888263..3dab6bc620da969e0f4d3d029acc9a5972d35e0b 100644 --- a/source/dnode/vnode/src/sma/smaTimeRange.c +++ b/source/dnode/vnode/src/sma/smaTimeRange.c @@ -29,7 +29,7 @@ int32_t tdProcessTSmaInsert(SSma *pSma, int64_t indexUid, const char *msg) { int32_t code = TSDB_CODE_SUCCESS; if ((code = tdProcessTSmaInsertImpl(pSma, indexUid, msg)) < 0) { - smaWarn("vgId:%d, insert tsma data failed since %s", SMA_VID(pSma), tstrerror(terrno)); + smaError("vgId:%d, insert tsma data failed since %s", SMA_VID(pSma), tstrerror(terrno)); } return code; @@ -194,6 +194,7 @@ int32_t smaBlockToSubmit(SVnode *pVnode, const SArray *pBlocks, const STSchema * } if (!(pCreateTbReq = taosMemoryCalloc(1, sizeof(SVCreateStbReq)))) { + terrno = TSDB_CODE_OUT_OF_MEMORY; goto _end; }; @@ -339,7 +340,7 @@ _end: if (terrno != 0) { rpcFreeCont(pBuf); taosArrayDestroy(pDeleteReq->deleteReqs); - return TSDB_CODE_FAILED; + return terrno; } if (ppData) *ppData = pBuf; if (pLen) *pLen = len; @@ -354,23 +355,18 @@ _end: * @return int32_t */ static int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg) { + int32_t code = 0; + int32_t lino = 0; const SArray *pDataBlocks = (const SArray *)msg; - // TODO: destroy SSDataBlocks(msg) - if (!pDataBlocks) { - terrno = TSDB_CODE_TSMA_INVALID_PTR; - smaWarn("vgId:%d, insert tsma data failed since pDataBlocks is NULL", SMA_VID(pSma)); - return TSDB_CODE_FAILED; - } if (taosArrayGetSize(pDataBlocks) <= 0) { - terrno = TSDB_CODE_TSMA_INVALID_PARA; - smaWarn("vgId:%d, insert tsma data failed since pDataBlocks is empty", SMA_VID(pSma)); - return TSDB_CODE_FAILED; + code = TSDB_CODE_TSMA_INVALID_PARA; + TSDB_CHECK_CODE(code, lino, _exit); } if (tdCheckAndInitSmaEnv(pSma, TSDB_SMA_TYPE_TIME_RANGE) != 0) { - terrno = TSDB_CODE_TSMA_INIT_FAILED; - return TSDB_CODE_FAILED; + code = TSDB_CODE_TSMA_INIT_FAILED; + TSDB_CHECK_CODE(code, lino, _exit); } SSmaEnv *pEnv = SMA_TSMA_ENV(pSma); @@ -378,57 +374,43 @@ static int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char STSmaStat *pTsmaStat = NULL; if (!pEnv || !(pStat = SMA_ENV_STAT(pEnv))) { - terrno = TSDB_CODE_TSMA_INVALID_ENV; - return TSDB_CODE_FAILED; + code = TSDB_CODE_TSMA_INVALID_ENV; + TSDB_CHECK_CODE(code, lino, _exit); } pTsmaStat = SMA_STAT_TSMA(pStat); if (!pTsmaStat->pTSma) { + terrno = 0; STSma *pTSma = metaGetSmaInfoByIndex(SMA_META(pSma), indexUid); if (!pTSma) { - smaError("vgId:%d, failed to get STSma while tsma insert for smaIndex %" PRIi64 " since %s", SMA_VID(pSma), - indexUid, tstrerror(terrno)); - goto _err; + code = terrno ? code : TSDB_CODE_TSMA_INVALID_PTR; + TSDB_CHECK_CODE(code, lino, _exit); } pTsmaStat->pTSma = pTSma; pTsmaStat->pTSchema = metaGetTbTSchema(SMA_META(pSma), pTSma->dstTbUid, -1, 1); if (!pTsmaStat->pTSchema) { - smaError("vgId:%d, failed to get STSchema while tsma insert for smaIndex %" PRIi64 " since %s", SMA_VID(pSma), - indexUid, tstrerror(terrno)); - goto _err; + code = terrno ? code : TSDB_CODE_TSMA_INVALID_PTR; + TSDB_CHECK_CODE(code, lino, _exit); } } - if (pTsmaStat->pTSma->indexUid != indexUid) { - terrno = TSDB_CODE_APP_ERROR; - smaError("vgId:%d, tsma insert for smaIndex %" PRIi64 "(!=%" PRIi64 ") failed since %s", SMA_VID(pSma), indexUid, - pTsmaStat->pTSma->indexUid, tstrerror(terrno)); - goto _err; + if (ASSERTS(pTsmaStat->pTSma->indexUid == indexUid, "indexUid:%" PRIi64 " != %" PRIi64, pTsmaStat->pTSma->indexUid, + indexUid)) { + code = TSDB_CODE_APP_ERROR; + TSDB_CHECK_CODE(code, lino, _exit); } SBatchDeleteReq deleteReq = {0}; void *pSubmitReq = NULL; int32_t contLen = 0; - if (smaBlockToSubmit(pSma->pVnode, (const SArray *)msg, pTsmaStat->pTSchema, &pTsmaStat->pTSma->schemaTag, true, - pTsmaStat->pTSma->dstTbUid, pTsmaStat->pTSma->dstTbName, &deleteReq, &pSubmitReq, - &contLen) < 0) { - smaError("vgId:%d, failed to gen submit msg while tsma insert for smaIndex %" PRIi64 " since %s", SMA_VID(pSma), - indexUid, tstrerror(terrno)); - goto _err; - } + code = smaBlockToSubmit(pSma->pVnode, (const SArray *)msg, pTsmaStat->pTSchema, &pTsmaStat->pTSma->schemaTag, true, + pTsmaStat->pTSma->dstTbUid, pTsmaStat->pTSma->dstTbName, &deleteReq, &pSubmitReq, &contLen); + TSDB_CHECK_CODE(code, lino, _exit); // TODO deleteReq taosArrayDestroy(deleteReq.deleteReqs); -#if 0 - if (!strncasecmp("td.tsma.rst.tb", pTsmaStat->pTSma->dstTbName, 14)) { - terrno = TSDB_CODE_APP_ERROR; - smaError("vgId:%d, tsma insert for smaIndex %" PRIi64 " failed since %s, %s", SMA_VID(pSma), indexUid, - pTsmaStat->pTSma->indexUid, tstrerror(terrno), pTsmaStat->pTSma->dstTbName); - goto _err; - } -#endif SRpcMsg submitReqMsg = { .msgType = TDMT_VND_SUBMIT, @@ -436,13 +418,13 @@ static int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char .contLen = contLen, }; - if (tmsgPutToQueue(&pSma->pVnode->msgCb, WRITE_QUEUE, &submitReqMsg) < 0) { - smaError("vgId:%d, failed to put SubmitReq msg while tsma insert for smaIndex %" PRIi64 " since %s", SMA_VID(pSma), - indexUid, tstrerror(terrno)); - goto _err; - } + code = tmsgPutToQueue(&pSma->pVnode->msgCb, WRITE_QUEUE, &submitReqMsg); + TSDB_CHECK_CODE(code, lino, _exit); - return TSDB_CODE_SUCCESS; -_err: - return TSDB_CODE_FAILED; +_exit: + if (code) { + smaError("vgId:%d, %s failed at line %d since %s, smaIndex:%PRIi64", SMA_VID(pSma), __func__, lino, tstrerror(code), + indexUid); + } + return code; } diff --git a/source/dnode/vnode/src/sma/smaUtil.c b/source/dnode/vnode/src/sma/smaUtil.c index 7c538280e52ed127ff2815623a2afa00c126de7f..16efdd1ec1a9b15714c0621601a843c8c0c434e5 100644 --- a/source/dnode/vnode/src/sma/smaUtil.c +++ b/source/dnode/vnode/src/sma/smaUtil.c @@ -17,20 +17,24 @@ #define TD_QTASKINFO_FNAME_PREFIX "main.tdb" +#if 0 void tdRSmaQTaskInfoGetFileName(int32_t vgId, int64_t suid, int8_t level, int64_t version, char *outputName) { tdRSmaGetFileName(vgId, NULL, VNODE_RSMA_DIR, TD_QTASKINFO_FNAME_PREFIX, suid, level, version, outputName); } +#endif void tdRSmaQTaskInfoGetFullName(int32_t vgId, int64_t suid, int8_t level, int64_t version, const char *path, char *outputName) { tdRSmaGetFileName(vgId, path, VNODE_RSMA_DIR, TD_QTASKINFO_FNAME_PREFIX, suid, level, version, outputName); } +#if 0 void tdRSmaQTaskInfoGetFullPath(int32_t vgId, int8_t level, const char *path, char *outputName) { tdRSmaGetDirName(vgId, path, VNODE_RSMA_DIR, true, outputName); int32_t rsmaLen = strlen(outputName); snprintf(outputName + rsmaLen, TSDB_FILENAME_LEN - rsmaLen, "%" PRIi8, level); } +#endif void tdRSmaQTaskInfoGetFullPathEx(int32_t vgId, tb_uid_t suid, int8_t level, const char *path, char *outputName) { tdRSmaGetDirName(vgId, path, VNODE_RSMA_DIR, true, outputName); @@ -60,6 +64,7 @@ void tdRSmaGetFileName(int32_t vgId, const char *pdname, const char *dname, cons } } } else { +#if 0 if (version >= 0) { if (pdname) { snprintf(outputName, TSDB_FILENAME_LEN, "%s%svnode%svnode%d%s%s%sv%d%s%" PRIi64, pdname, TD_DIRSEP, TD_DIRSEP, @@ -77,6 +82,7 @@ void tdRSmaGetFileName(int32_t vgId, const char *pdname, const char *dname, cons TD_DIRSEP, vgId, fname); } } +#endif } } @@ -90,31 +96,24 @@ void tdRSmaGetDirName(int32_t vgId, const char *pdname, const char *dname, bool dname); } } else { +#if 0 if (endWithSep) { snprintf(outputName, TSDB_FILENAME_LEN, "vnode%svnode%d%s%s%s", TD_DIRSEP, vgId, TD_DIRSEP, dname, TD_DIRSEP); } else { snprintf(outputName, TSDB_FILENAME_LEN, "vnode%svnode%d%s%s", TD_DIRSEP, vgId, TD_DIRSEP, dname); } +#endif } } // smaXXXUtil ================ -void *tdAcquireSmaRef(int32_t rsetId, int64_t refId) { - void *pResult = taosAcquireRef(rsetId, refId); - if (!pResult) { - smaWarn("rsma acquire ref for rsetId:%d refId:%" PRIi64 " failed since %s", rsetId, refId, terrstr()); - } else { - smaTrace("rsma acquire ref for rsetId:%d refId:%" PRIi64 " success", rsetId, refId); - } - return pResult; -} +void *tdAcquireSmaRef(int32_t rsetId, int64_t refId) { return taosAcquireRef(rsetId, refId); } int32_t tdReleaseSmaRef(int32_t rsetId, int64_t refId) { if (taosReleaseRef(rsetId, refId) < 0) { smaWarn("rsma release ref for rsetId:%d refId:%" PRIi64 " failed since %s", rsetId, refId, terrstr()); return TSDB_CODE_FAILED; } - smaTrace("rsma release ref for rsetId:%d refId:%" PRIi64 " success", rsetId, refId); return TSDB_CODE_SUCCESS; } \ No newline at end of file