From 30f8c9c79e3b3f88c64cc59ca13a5fc71fa649c7 Mon Sep 17 00:00:00 2001 From: kailixu Date: Tue, 11 Jul 2023 18:08:48 +0800 Subject: [PATCH] chore: more check --- include/common/tdatablock.h | 2 +- source/common/src/tdatablock.c | 40 ++++++++++++++------------ source/dnode/vnode/src/sma/smaRollup.c | 2 +- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/include/common/tdatablock.h b/include/common/tdatablock.h index a045ae2bd4..129078ee23 100644 --- a/include/common/tdatablock.h +++ b/include/common/tdatablock.h @@ -244,7 +244,7 @@ const char* blockDecode(SSDataBlock* pBlock, const char* pData); char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** dumpBuf); int32_t buildSubmitReqFromDataBlock(SSubmitReq2** pReq, const SSDataBlock* pDataBlocks, const STSchema* pTSchema, int64_t uid, int32_t vgId, - tb_uid_t suid, int64_t blkVer, const char* tag); + tb_uid_t suid, int64_t blkVer, int8_t level, const char* tag); char* buildCtbNameByGroupId(const char* stbName, uint64_t groupId); int32_t buildCtbNameByGroupIdImpl(const char* stbName, uint64_t groupId, char* pBuf); diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 0331f4bf9b..c631b14816 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -1876,27 +1876,28 @@ static SHashObj* dupCheck = NULL; static int8_t dupInit = 0; int32_t buildSubmitReqFromDataBlock(SSubmitReq2** ppReq, const SSDataBlock* pDataBlock, const STSchema* pTSchema, - int64_t uid, int32_t vgId, tb_uid_t suid, int64_t blkVer, const char* tag) { + int64_t uid, int32_t vgId, tb_uid_t suid, int64_t blkVer, int8_t level, + const char* tag) { SSubmitReq2* pReq = *ppReq; SArray* pVals = NULL; int32_t numOfBlks = 0; int32_t sz = 1; - if (!dupCheck) { - if (0 == atomic_val_compare_exchange_8(&dupInit, 0, 1)) { - dupCheck = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK); - if (!dupCheck) ASSERT(0); - } else { - int32_t cnt = 0; - while (!dupCheck) { - ++cnt; - if (cnt > 1000) { - sched_yield(); - cnt = 0; - } - } - } - } + // if (!dupCheck) { + // if (0 == atomic_val_compare_exchange_8(&dupInit, 0, 1)) { + // dupCheck = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK); + // if (!dupCheck) ASSERT(0); + // } else { + // int32_t cnt = 0; + // while (!dupCheck) { + // ++cnt; + // if (cnt > 1000) { + // sched_yield(); + // cnt = 0; + // } + // } + // } + // } terrno = TSDB_CODE_SUCCESS; @@ -1911,7 +1912,7 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq2** ppReq, const SSDataBlock* pDat } } - char dupKey[50]; + char dupKey[70]; for (int32_t i = 0; i < sz; ++i) { int32_t colNum = taosArrayGetSize(pDataBlock->pDataBlock); @@ -1957,10 +1958,11 @@ 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, 50, "%d:%" PRIi64 ":%" PRIi64, vgId, *(TSKEY*)var, blkVer); + snprintf(dupKey, 70, "%" PRIi8 ":%d:%" PRIi64 ":%" PRIi64 ":%" PRIi64, level, vgId, uid, *(TSKEY*)var, + blkVer); uInfo("%s:%d key:ver: %s, tags: %s", __func__, __LINE__, dupKey, tag); int32_t dupKeyLen = strlen(dupKey); - assert(dupKeyLen < 50); + assert(dupKeyLen < 70); 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 ca62426be8..a94ddf7111 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -621,7 +621,7 @@ static int32_t tdRSmaExecAndSubmitResult(SSma *pSma, qTaskInfo_t taskInfo, SRSma // TODO: the schema update should be handled later(TD-17965) if (buildSubmitReqFromDataBlock(&pReq, output, pTSchema, output->info.id.groupId, SMA_VID(pSma), suid, - output->info.version, tag) < 0) { + output->info.version, pItem->level, tag) < 0) { code = terrno ? terrno : TSDB_CODE_RSMA_RESULT; TSDB_CHECK_CODE(code, lino, _exit); } -- GitLab