From 7c85f7701d5db6ebc551baa5541019731f8183c2 Mon Sep 17 00:00:00 2001 From: kailixu Date: Tue, 11 Jul 2023 16:32:29 +0800 Subject: [PATCH] chore: more check --- source/common/src/tdatablock.c | 6 +++--- source/dnode/vnode/src/sma/smaRollup.c | 12 +++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 2da48d727b..0331f4bf9b 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -1911,7 +1911,7 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq2** ppReq, const SSDataBlock* pDat } } - char dupKey[40]; + char dupKey[50]; for (int32_t i = 0; i < sz; ++i) { int32_t colNum = taosArrayGetSize(pDataBlock->pDataBlock); @@ -1957,10 +1957,10 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq2** ppReq, const SSDataBlock* pDat ASSERT(PRIMARYKEY_TIMESTAMP_COL_ID == pCol->colId); SColVal cv = COL_VAL_VALUE(pCol->colId, pCol->type, (SValue){.val = *(TSKEY*)var}); taosArrayPush(pVals, &cv); - snprintf(dupKey, 40, "%" PRIi64 ":%" PRIi64, *(TSKEY*)var, blkVer); + snprintf(dupKey, 50, "%d:%" PRIi64 ":%" PRIi64, vgId, *(TSKEY*)var, blkVer); uInfo("%s:%d key:ver: %s, tags: %s", __func__, __LINE__, dupKey, tag); int32_t dupKeyLen = strlen(dupKey); - assert(dupKeyLen < 40); + assert(dupKeyLen < 50); void* hashKey = NULL; if ((hashKey = taosHashGet(dupCheck, &dupKey, dupKeyLen + 1))) { ASSERT(0); diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index b53304933f..ca62426be8 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -858,9 +858,10 @@ static int32_t tdExecuteRSmaAsync(SSma *pSma, int64_t version, const void *pMsg, } if (inputType == STREAM_INPUT__DATA_SUBMIT) { + char dupKey[40]; if (!dupVerCheck) { if (0 == atomic_val_compare_exchange_8(&dupVerInit, 0, 1)) { - dupVerCheck = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK); + dupVerCheck = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK); if (!dupVerCheck) ASSERT(0); } else { int32_t cnt = 0; @@ -873,14 +874,19 @@ static int32_t tdExecuteRSmaAsync(SSma *pSma, int64_t version, const void *pMsg, } } } + + snprintf(dupKey, 40, "%d:%" PRIi64 ":%" PRIi64, SMA_VID(pSma), version); + int32_t dupKeyLen = strlen(dupKey); + assert(dupKeyLen < 40); void *hashKey = NULL; - if ((hashKey = taosHashGet(dupVerCheck, &version, sizeof(version)))) { + if ((hashKey = taosHashGet(dupVerCheck, &dupKey, dupKeyLen + 1))) { ASSERT(0); } else { - if (taosHashPut(dupVerCheck, &version, sizeof(version), NULL, 0) != 0) { + if (taosHashPut(dupVerCheck, &dupKey, dupKeyLen + 1, NULL, 0) != 0) { ASSERT(0); } } + if (tdExecuteRSmaImplAsync(pSma, version, pMsg, len, inputType, pRSmaInfo, suid) < 0) { tdReleaseRSmaInfo(pSma, pRSmaInfo); return TSDB_CODE_FAILED; -- GitLab