diff --git a/source/libs/catalog/src/catalog.c b/source/libs/catalog/src/catalog.c index a1dc2e9a58d41654ed8e0142a2e1741c3778a61d..8f621545c9b3800f7260fe29a58861cb7655acb2 100644 --- a/source/libs/catalog/src/catalog.c +++ b/source/libs/catalog/src/catalog.c @@ -570,7 +570,7 @@ int32_t catalogInit(SCatalogCfg* cfg) { CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT); } - atomic_store_8((int8_t*)&gCtgMgmt.exit, false); + memset(&gCtgMgmt, 0, sizeof(gCtgMgmt)); if (cfg) { memcpy(&gCtgMgmt.cfg, cfg, sizeof(*cfg)); diff --git a/source/libs/catalog/src/ctgCache.c b/source/libs/catalog/src/ctgCache.c index 1a7a0057badf5bfaa0356fe844bb9e8ebd89b052..ca562aee3e912b9fb4ed1633e8beed32da091e5d 100644 --- a/source/libs/catalog/src/ctgCache.c +++ b/source/libs/catalog/src/ctgCache.c @@ -72,7 +72,10 @@ void ctgRUnlockVgInfo(SCtgDBCache *dbCache) { CTG_UNLOCK(CTG_READ, &dbCache->vgC void ctgWUnlockVgInfo(SCtgDBCache *dbCache) { CTG_UNLOCK(CTG_WRITE, &dbCache->vgCache.vgLock); } -void ctgReleaseDBCache(SCatalog *pCtg, SCtgDBCache *dbCache) { CTG_UNLOCK(CTG_READ, &dbCache->dbLock); } +void ctgReleaseDBCache(SCatalog *pCtg, SCtgDBCache *dbCache) { + CTG_UNLOCK(CTG_READ, &dbCache->dbLock); + taosHashRelease(pCtg->dbCache, dbCache); +} int32_t ctgAcquireDBCacheImpl(SCatalog *pCtg, const char *dbFName, SCtgDBCache **pCache, bool acquire) { char *p = strchr(dbFName, '.'); @@ -80,7 +83,14 @@ int32_t ctgAcquireDBCacheImpl(SCatalog *pCtg, const char *dbFName, SCtgDBCache * dbFName = p + 1; } - SCtgDBCache *dbCache = (SCtgDBCache *)taosHashGet(pCtg->dbCache, dbFName, strlen(dbFName)); + SCtgDBCache *dbCache = NULL; + + if (acquire) { + dbCache = (SCtgDBCache *)taosHashAcquire(pCtg->dbCache, dbFName, strlen(dbFName)); + } else { + dbCache = (SCtgDBCache *)taosHashGet(pCtg->dbCache, dbFName, strlen(dbFName)); + } + if (NULL == dbCache) { *pCache = NULL; ctgDebug("db not in cache, dbFName:%s", dbFName); @@ -1356,7 +1366,6 @@ int32_t ctgWriteTbMetaToCache(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFNam SCtgTbCache *pCache = taosHashGet(dbCache->tbCache, tbName, strlen(tbName)); STableMeta *orig = (pCache ? pCache->pMeta : NULL); int8_t origType = 0; - uint64_t origSuid = 0; if (orig) { origType = orig->tableType; @@ -1375,8 +1384,6 @@ int32_t ctgWriteTbMetaToCache(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFNam CTG_CACHE_STAT_DEC(numOfStb, 1); ctgDebug("stb removed from stbCache, dbFName:%s, stb:%s, suid:0x%" PRIx64, dbFName, tbName, orig->suid); } - - origSuid = orig->suid; } } @@ -1408,8 +1415,7 @@ int32_t ctgWriteTbMetaToCache(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFNam return TSDB_CODE_SUCCESS; } - if (origSuid != meta->suid && - taosHashPut(dbCache->stbCache, &meta->suid, sizeof(meta->suid), tbName, strlen(tbName) + 1) != 0) { + if (taosHashPut(dbCache->stbCache, &meta->suid, sizeof(meta->suid), tbName, strlen(tbName) + 1) != 0) { ctgError("taosHashPut to stable cache failed, suid:0x%" PRIx64, meta->suid); CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } diff --git a/source/libs/catalog/test/CMakeLists.txt b/source/libs/catalog/test/CMakeLists.txt index b2e1c3b4ca5f3e169920acc8236e717db1e5766c..b8d50b9c636cf1125cb291f7c05bddb2c37e9fa1 100644 --- a/source/libs/catalog/test/CMakeLists.txt +++ b/source/libs/catalog/test/CMakeLists.txt @@ -18,8 +18,8 @@ IF(NOT TD_DARWIN) PRIVATE "${TD_SOURCE_DIR}/source/libs/catalog/inc" ) - # add_test( - # NAME catalogTest - # COMMAND catalogTest - # ) + #add_test( + # NAME catalogTest + # COMMAND catalogTest + #) ENDIF() diff --git a/source/libs/catalog/test/catalogTests.cpp b/source/libs/catalog/test/catalogTests.cpp index 065c6234f69fba49e01156326ca20d4540db0595..cbfe342c8ae5697d92e092a861b955875969fe94 100644 --- a/source/libs/catalog/test/catalogTests.cpp +++ b/source/libs/catalog/test/catalogTests.cpp @@ -142,6 +142,7 @@ void ctgTestInitLogFile() { ctgdEnableDebug("api"); ctgdEnableDebug("meta"); ctgdEnableDebug("cache"); + ctgdEnableDebug("lock"); if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) { printf("failed to open log file in directory:%s\n", tsLogDir); @@ -254,8 +255,8 @@ void ctgTestBuildSTableMetaRsp(STableMetaRsp *rspMsg) { rspMsg->tableType = TSDB_SUPER_TABLE; rspMsg->sversion = ctgTestSVersion + 1; rspMsg->tversion = ctgTestTVersion + 1; - rspMsg->suid = ctgTestSuid + 1; - rspMsg->tuid = ctgTestSuid + 1; + rspMsg->suid = ctgTestSuid; + rspMsg->tuid = ctgTestSuid; rspMsg->vgId = 1; rspMsg->pSchemas = (SSchema *)taosMemoryCalloc(rspMsg->numOfTags + rspMsg->numOfColumns, sizeof(SSchema)); @@ -423,7 +424,7 @@ void ctgTestRspSTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg metaRsp.sversion = ctgTestSVersion; metaRsp.tversion = ctgTestTVersion; metaRsp.suid = ctgTestSuid; - metaRsp.tuid = ctgTestSuid++; + metaRsp.tuid = ctgTestSuid+1; metaRsp.vgId = 0; metaRsp.pSchemas = (SSchema *)taosMemoryMalloc((metaRsp.numOfTags + metaRsp.numOfColumns) * sizeof(SSchema)); @@ -773,13 +774,15 @@ void ctgTestSetRspDbVgroupsAndMultiSuperMeta() { void *ctgTestGetDbVgroupThread(void *param) { struct SCatalog *pCtg = (struct SCatalog *)param; int32_t code = 0; - SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; + SRequestConnInfo connInfo = {0}; + SRequestConnInfo *mockPointer = (SRequestConnInfo *)&connInfo; SArray *vgList = NULL; int32_t n = 0; while (!ctgTestStop) { code = catalogGetDBVgList(pCtg, mockPointer, ctgTestDbname, &vgList); if (code) { + printf("code:%x\n", code); assert(0); } @@ -863,7 +866,7 @@ void *ctgTestGetCtableMetaThread(void *param) { while (!ctgTestStop) { code = ctgReadTbMetaFromCache(pCtg, &ctx, &tbMeta); - if (code || !inCache) { + if (code || NULL == tbMeta) { assert(0); } @@ -917,12 +920,12 @@ void *ctgTestSetCtableMetaThread(void *param) { return NULL; } -#if 1 TEST(tableMeta, normalTable) { struct SCatalog *pCtg = NULL; - SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; SVgroupInfo vgInfo = {0}; + SRequestConnInfo connInfo = {0}; + SRequestConnInfo *mockPointer = (SRequestConnInfo *)&connInfo; ctgTestInitLogFile(); @@ -1028,7 +1031,8 @@ TEST(tableMeta, normalTable) { TEST(tableMeta, childTableCase) { struct SCatalog *pCtg = NULL; - SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; + SRequestConnInfo connInfo = {0}; + SRequestConnInfo *mockPointer = (SRequestConnInfo *)&connInfo; SVgroupInfo vgInfo = {0}; ctgTestInitLogFile(); @@ -1136,7 +1140,8 @@ TEST(tableMeta, childTableCase) { TEST(tableMeta, superTableCase) { struct SCatalog *pCtg = NULL; - SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; + SRequestConnInfo connInfo = {0}; + SRequestConnInfo *mockPointer = (SRequestConnInfo *)&connInfo; SVgroupInfo vgInfo = {0}; ctgTestSetRspDbVgroupsAndSuperMeta(); @@ -1161,8 +1166,8 @@ TEST(tableMeta, superTableCase) { ASSERT_EQ(tableMeta->tableType, TSDB_SUPER_TABLE); ASSERT_EQ(tableMeta->sversion, ctgTestSVersion); ASSERT_EQ(tableMeta->tversion, ctgTestTVersion); - ASSERT_EQ(tableMeta->uid, ctgTestSuid - 1); - ASSERT_EQ(tableMeta->suid, ctgTestSuid - 1); + ASSERT_EQ(tableMeta->uid, ctgTestSuid); + ASSERT_EQ(tableMeta->suid, ctgTestSuid); ASSERT_EQ(tableMeta->tableInfo.numOfColumns, ctgTestColNum); ASSERT_EQ(tableMeta->tableInfo.numOfTags, ctgTestTagNum); ASSERT_EQ(tableMeta->tableInfo.precision, 1); @@ -1257,7 +1262,8 @@ TEST(tableMeta, superTableCase) { TEST(tableMeta, rmStbMeta) { struct SCatalog *pCtg = NULL; - SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; + SRequestConnInfo connInfo = {0}; + SRequestConnInfo *mockPointer = (SRequestConnInfo *)&connInfo; SVgroupInfo vgInfo = {0}; ctgTestInitLogFile(); @@ -1284,8 +1290,8 @@ TEST(tableMeta, rmStbMeta) { ASSERT_EQ(tableMeta->tableType, TSDB_SUPER_TABLE); ASSERT_EQ(tableMeta->sversion, ctgTestSVersion); ASSERT_EQ(tableMeta->tversion, ctgTestTVersion); - ASSERT_EQ(tableMeta->uid, ctgTestSuid - 1); - ASSERT_EQ(tableMeta->suid, ctgTestSuid - 1); + ASSERT_EQ(tableMeta->uid, ctgTestSuid); + ASSERT_EQ(tableMeta->suid, ctgTestSuid); ASSERT_EQ(tableMeta->tableInfo.numOfColumns, ctgTestColNum); ASSERT_EQ(tableMeta->tableInfo.numOfTags, ctgTestTagNum); ASSERT_EQ(tableMeta->tableInfo.precision, 1); @@ -1300,7 +1306,7 @@ TEST(tableMeta, rmStbMeta) { } } - code = catalogRemoveStbMeta(pCtg, "1.db1", ctgTestDbId, ctgTestSTablename, ctgTestSuid - 1); + code = catalogRemoveStbMeta(pCtg, "1.db1", ctgTestDbId, ctgTestSTablename, ctgTestSuid); ASSERT_EQ(code, 0); while (true) { @@ -1325,7 +1331,8 @@ TEST(tableMeta, rmStbMeta) { TEST(tableMeta, updateStbMeta) { struct SCatalog *pCtg = NULL; - SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; + SRequestConnInfo connInfo = {0}; + SRequestConnInfo *mockPointer = (SRequestConnInfo *)&connInfo; SVgroupInfo vgInfo = {0}; ctgTestInitLogFile(); @@ -1352,8 +1359,8 @@ TEST(tableMeta, updateStbMeta) { ASSERT_EQ(tableMeta->tableType, TSDB_SUPER_TABLE); ASSERT_EQ(tableMeta->sversion, ctgTestSVersion); ASSERT_EQ(tableMeta->tversion, ctgTestTVersion); - ASSERT_EQ(tableMeta->uid, ctgTestSuid - 1); - ASSERT_EQ(tableMeta->suid, ctgTestSuid - 1); + ASSERT_EQ(tableMeta->uid, ctgTestSuid); + ASSERT_EQ(tableMeta->suid, ctgTestSuid); ASSERT_EQ(tableMeta->tableInfo.numOfColumns, ctgTestColNum); ASSERT_EQ(tableMeta->tableInfo.numOfTags, ctgTestTagNum); ASSERT_EQ(tableMeta->tableInfo.precision, 1); @@ -1399,8 +1406,8 @@ TEST(tableMeta, updateStbMeta) { ASSERT_EQ(tableMeta->tableType, TSDB_SUPER_TABLE); ASSERT_EQ(tableMeta->sversion, ctgTestSVersion + 1); ASSERT_EQ(tableMeta->tversion, ctgTestTVersion + 1); - ASSERT_EQ(tableMeta->uid, ctgTestSuid + 1); - ASSERT_EQ(tableMeta->suid, ctgTestSuid + 1); + ASSERT_EQ(tableMeta->uid, ctgTestSuid); + ASSERT_EQ(tableMeta->suid, ctgTestSuid); ASSERT_EQ(tableMeta->tableInfo.numOfColumns, ctgTestColNum); ASSERT_EQ(tableMeta->tableInfo.numOfTags, ctgTestTagNum); ASSERT_EQ(tableMeta->tableInfo.precision, 1 + 1); @@ -1414,7 +1421,8 @@ TEST(tableMeta, updateStbMeta) { TEST(refreshGetMeta, normal2normal) { struct SCatalog *pCtg = NULL; - SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; + SRequestConnInfo connInfo = {0}; + SRequestConnInfo *mockPointer = (SRequestConnInfo *)&connInfo; SVgroupInfo vgInfo = {0}; SArray *vgList = NULL; @@ -1493,7 +1501,8 @@ TEST(refreshGetMeta, normal2normal) { TEST(refreshGetMeta, normal2notexist) { struct SCatalog *pCtg = NULL; - SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; + SRequestConnInfo connInfo = {0}; + SRequestConnInfo *mockPointer = (SRequestConnInfo *)&connInfo; SVgroupInfo vgInfo = {0}; SArray *vgList = NULL; @@ -1563,7 +1572,8 @@ TEST(refreshGetMeta, normal2notexist) { TEST(refreshGetMeta, normal2child) { struct SCatalog *pCtg = NULL; - SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; + SRequestConnInfo connInfo = {0}; + SRequestConnInfo *mockPointer = (SRequestConnInfo *)&connInfo; SVgroupInfo vgInfo = {0}; SArray *vgList = NULL; @@ -1644,9 +1654,11 @@ TEST(refreshGetMeta, normal2child) { ctgTestCurrentSTableName = NULL; } + TEST(refreshGetMeta, stable2child) { struct SCatalog *pCtg = NULL; - SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; + SRequestConnInfo connInfo = {0}; + SRequestConnInfo *mockPointer = (SRequestConnInfo *)&connInfo; SVgroupInfo vgInfo = {0}; SArray *vgList = NULL; @@ -1699,8 +1711,8 @@ TEST(refreshGetMeta, stable2child) { ASSERT_EQ(tableMeta->tableType, TSDB_SUPER_TABLE); ASSERT_EQ(tableMeta->sversion, ctgTestSVersion); ASSERT_EQ(tableMeta->tversion, ctgTestTVersion); - ASSERT_EQ(tableMeta->uid, ctgTestSuid - 1); - ASSERT_EQ(tableMeta->suid, ctgTestSuid - 1); + ASSERT_EQ(tableMeta->uid, ctgTestSuid); + ASSERT_EQ(tableMeta->suid, ctgTestSuid); ASSERT_EQ(tableMeta->tableInfo.numOfColumns, ctgTestColNum); ASSERT_EQ(tableMeta->tableInfo.numOfTags, ctgTestTagNum); ASSERT_EQ(tableMeta->tableInfo.precision, 1); @@ -1732,7 +1744,8 @@ TEST(refreshGetMeta, stable2child) { TEST(refreshGetMeta, stable2stable) { struct SCatalog *pCtg = NULL; - SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; + SRequestConnInfo connInfo = {0}; + SRequestConnInfo *mockPointer = (SRequestConnInfo *)&connInfo; SVgroupInfo vgInfo = {0}; SArray *vgList = NULL; @@ -1784,8 +1797,8 @@ TEST(refreshGetMeta, stable2stable) { ASSERT_EQ(tableMeta->tableType, TSDB_SUPER_TABLE); ASSERT_EQ(tableMeta->sversion, ctgTestSVersion); ASSERT_EQ(tableMeta->tversion, ctgTestTVersion); - ASSERT_EQ(tableMeta->uid, ctgTestSuid - 1); - ASSERT_EQ(tableMeta->suid, ctgTestSuid - 1); + ASSERT_EQ(tableMeta->uid, ctgTestSuid); + ASSERT_EQ(tableMeta->suid, ctgTestSuid); ASSERT_EQ(tableMeta->tableInfo.numOfColumns, ctgTestColNum); ASSERT_EQ(tableMeta->tableInfo.numOfTags, ctgTestTagNum); ASSERT_EQ(tableMeta->tableInfo.precision, 1); @@ -1802,8 +1815,8 @@ TEST(refreshGetMeta, stable2stable) { ASSERT_EQ(tableMeta->tableType, TSDB_SUPER_TABLE); ASSERT_EQ(tableMeta->sversion, ctgTestSVersion); ASSERT_EQ(tableMeta->tversion, ctgTestTVersion); - ASSERT_EQ(tableMeta->uid, ctgTestSuid - 1); - ASSERT_EQ(tableMeta->suid, ctgTestSuid - 1); + ASSERT_EQ(tableMeta->uid, ctgTestSuid); + ASSERT_EQ(tableMeta->suid, ctgTestSuid); ASSERT_EQ(tableMeta->tableInfo.numOfColumns, ctgTestColNum); ASSERT_EQ(tableMeta->tableInfo.numOfTags, ctgTestTagNum); ASSERT_EQ(tableMeta->tableInfo.precision, 1); @@ -1818,7 +1831,8 @@ TEST(refreshGetMeta, stable2stable) { TEST(refreshGetMeta, child2stable) { struct SCatalog *pCtg = NULL; - SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; + SRequestConnInfo connInfo = {0}; + SRequestConnInfo *mockPointer = (SRequestConnInfo *)&connInfo; SVgroupInfo vgInfo = {0}; SArray *vgList = NULL; @@ -1888,8 +1902,8 @@ TEST(refreshGetMeta, child2stable) { ASSERT_EQ(tableMeta->tableType, TSDB_SUPER_TABLE); ASSERT_EQ(tableMeta->sversion, ctgTestSVersion); ASSERT_EQ(tableMeta->tversion, ctgTestTVersion); - ASSERT_EQ(tableMeta->uid, ctgTestSuid - 1); - ASSERT_EQ(tableMeta->suid, ctgTestSuid - 1); + ASSERT_EQ(tableMeta->uid, ctgTestSuid); + ASSERT_EQ(tableMeta->suid, ctgTestSuid); ASSERT_EQ(tableMeta->tableInfo.numOfColumns, ctgTestColNum); ASSERT_EQ(tableMeta->tableInfo.numOfTags, ctgTestTagNum); ASSERT_EQ(tableMeta->tableInfo.precision, 1); @@ -1904,7 +1918,8 @@ TEST(refreshGetMeta, child2stable) { TEST(tableDistVgroup, normalTable) { struct SCatalog *pCtg = NULL; - SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; + SRequestConnInfo connInfo = {0}; + SRequestConnInfo *mockPointer = (SRequestConnInfo *)&connInfo; SVgroupInfo *vgInfo = NULL; SArray *vgList = NULL; @@ -1933,11 +1948,7 @@ TEST(tableDistVgroup, normalTable) { strcpy(n.tname, ctgTestTablename); code = catalogGetTableDistVgInfo(pCtg, mockPointer, &n, &vgList); - ASSERT_EQ(code, 0); - ASSERT_EQ(taosArrayGetSize((const SArray *)vgList), 1); - vgInfo = (SVgroupInfo *)taosArrayGet(vgList, 0); - ASSERT_EQ(vgInfo->vgId, 8); - ASSERT_EQ(vgInfo->epSet.numOfEps, 3); + ASSERT_TRUE(code != 0); catalogDestroy(); memset(&gCtgMgmt, 0, sizeof(gCtgMgmt)); @@ -1945,7 +1956,8 @@ TEST(tableDistVgroup, normalTable) { TEST(tableDistVgroup, childTableCase) { struct SCatalog *pCtg = NULL; - SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; + SRequestConnInfo connInfo = {0}; + SRequestConnInfo *mockPointer = (SRequestConnInfo *)&connInfo; SVgroupInfo *vgInfo = NULL; SArray *vgList = NULL; @@ -1975,11 +1987,7 @@ TEST(tableDistVgroup, childTableCase) { strcpy(n.tname, ctgTestCTablename); code = catalogGetTableDistVgInfo(pCtg, mockPointer, &n, &vgList); - ASSERT_EQ(code, 0); - ASSERT_EQ(taosArrayGetSize((const SArray *)vgList), 1); - vgInfo = (SVgroupInfo *)taosArrayGet(vgList, 0); - ASSERT_EQ(vgInfo->vgId, 9); - ASSERT_EQ(vgInfo->epSet.numOfEps, 4); + ASSERT_TRUE(code != 0); catalogDestroy(); memset(&gCtgMgmt, 0, sizeof(gCtgMgmt)); @@ -1987,7 +1995,8 @@ TEST(tableDistVgroup, childTableCase) { TEST(tableDistVgroup, superTableCase) { struct SCatalog *pCtg = NULL; - SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; + SRequestConnInfo connInfo = {0}; + SRequestConnInfo *mockPointer = (SRequestConnInfo *)&connInfo; SVgroupInfo *vgInfo = NULL; SArray *vgList = NULL; @@ -2034,7 +2043,8 @@ TEST(tableDistVgroup, superTableCase) { TEST(dbVgroup, getSetDbVgroupCase) { struct SCatalog *pCtg = NULL; - SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; + SRequestConnInfo connInfo = {0}; + SRequestConnInfo *mockPointer = (SRequestConnInfo *)&connInfo; SVgroupInfo vgInfo = {0}; SVgroupInfo *pvgInfo = NULL; SDBVgInfo *dbVgroup = NULL; @@ -2082,12 +2092,7 @@ TEST(dbVgroup, getSetDbVgroupCase) { ASSERT_EQ(vgInfo.epSet.numOfEps, 3); code = catalogGetTableDistVgInfo(pCtg, mockPointer, &n, &vgList); - ASSERT_EQ(code, 0); - ASSERT_EQ(taosArrayGetSize((const SArray *)vgList), 1); - pvgInfo = (SVgroupInfo *)taosArrayGet(vgList, 0); - ASSERT_EQ(pvgInfo->vgId, 8); - ASSERT_EQ(pvgInfo->epSet.numOfEps, 3); - taosArrayDestroy(vgList); + ASSERT_TRUE(code != 0); ctgTestBuildDBVgroup(&dbVgroup); code = catalogUpdateDBVgInfo(pCtg, ctgTestDbname, ctgTestDbId, dbVgroup); @@ -2109,12 +2114,7 @@ TEST(dbVgroup, getSetDbVgroupCase) { ASSERT_EQ(vgInfo.epSet.numOfEps, 2); code = catalogGetTableDistVgInfo(pCtg, mockPointer, &n, &vgList); - ASSERT_EQ(code, 0); - ASSERT_EQ(taosArrayGetSize((const SArray *)vgList), 1); - pvgInfo = (SVgroupInfo *)taosArrayGet(vgList, 0); - ASSERT_EQ(pvgInfo->vgId, 8); - ASSERT_EQ(pvgInfo->epSet.numOfEps, 3); - taosArrayDestroy(vgList); + ASSERT_TRUE(code != 0); catalogDestroy(); memset(&gCtgMgmt, 0, sizeof(gCtgMgmt)); @@ -2122,7 +2122,8 @@ TEST(dbVgroup, getSetDbVgroupCase) { TEST(multiThread, getSetRmSameDbVgroup) { struct SCatalog *pCtg = NULL; - SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; + SRequestConnInfo connInfo = {0}; + SRequestConnInfo *mockPointer = (SRequestConnInfo *)&connInfo; SVgroupInfo vgInfo = {0}; SVgroupInfo *pvgInfo = NULL; SDBVgInfo dbVgroup = {0}; @@ -2174,7 +2175,8 @@ TEST(multiThread, getSetRmSameDbVgroup) { TEST(multiThread, getSetRmDiffDbVgroup) { struct SCatalog *pCtg = NULL; - SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; + SRequestConnInfo connInfo = {0}; + SRequestConnInfo *mockPointer = (SRequestConnInfo *)&connInfo; SVgroupInfo vgInfo = {0}; SVgroupInfo *pvgInfo = NULL; SDBVgInfo dbVgroup = {0}; @@ -2226,7 +2228,8 @@ TEST(multiThread, getSetRmDiffDbVgroup) { TEST(multiThread, ctableMeta) { struct SCatalog *pCtg = NULL; - SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; + SRequestConnInfo connInfo = {0}; + SRequestConnInfo *mockPointer = (SRequestConnInfo *)&connInfo; SVgroupInfo vgInfo = {0}; SVgroupInfo *pvgInfo = NULL; SDBVgInfo dbVgroup = {0}; @@ -2277,7 +2280,8 @@ TEST(multiThread, ctableMeta) { TEST(rentTest, allRent) { struct SCatalog *pCtg = NULL; - SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; + SRequestConnInfo connInfo = {0}; + SRequestConnInfo *mockPointer = (SRequestConnInfo *)&connInfo; SVgroupInfo vgInfo = {0}; SVgroupInfo *pvgInfo = NULL; SDBVgInfo dbVgroup = {0}; @@ -2352,7 +2356,6 @@ TEST(rentTest, allRent) { memset(&gCtgMgmt, 0, sizeof(gCtgMgmt)); } -#endif int main(int argc, char **argv) { testing::InitGoogleTest(&argc, argv); diff --git a/source/libs/scheduler/inc/schInt.h b/source/libs/scheduler/inc/schInt.h index 1a88992840cd649d2538f66e19d86a96df34c594..6884824ba9eef29075a7f258dbe17913c91b669c 100644 --- a/source/libs/scheduler/inc/schInt.h +++ b/source/libs/scheduler/inc/schInt.h @@ -57,8 +57,8 @@ typedef enum { #define SCHEDULE_DEFAULT_POLICY SCH_LOAD_SEQ #define SCHEDULE_DEFAULT_MAX_NODE_NUM 20 -#define SCH_DEFAULT_TASK_TIMEOUT_USEC 10000000 -#define SCH_MAX_TASK_TIMEOUT_USEC 60000000 +#define SCH_DEFAULT_TASK_TIMEOUT_USEC 60000000 +#define SCH_MAX_TASK_TIMEOUT_USEC 300000000 #define SCH_DEFAULT_MAX_RETRY_NUM 6 #define SCH_MIN_AYSNC_EXEC_NUM 3 diff --git a/source/libs/scheduler/src/schRemote.c b/source/libs/scheduler/src/schRemote.c index c26ae4e646298bd5cd83847f71ca59e39f22fcee..d1d0680e651f6f1c5d1d745df2a4272bb7da839b 100644 --- a/source/libs/scheduler/src/schRemote.c +++ b/source/libs/scheduler/src/schRemote.c @@ -145,8 +145,10 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t execId, SDa int32_t msgType = pMsg->msgType; bool dropExecNode = (msgType == TDMT_SCH_LINK_BROKEN || SCH_NETWORK_ERR(rspCode)); - SCH_ERR_JRET(schUpdateTaskHandle(pJob, pTask, dropExecNode, pMsg->handle, execId)); - + if (SCH_IS_QUERY_JOB(pJob)) { + SCH_ERR_JRET(schUpdateTaskHandle(pJob, pTask, dropExecNode, pMsg->handle, execId)); + } + SCH_ERR_JRET(schValidateRspMsgType(pJob, pTask, msgType)); int32_t reqType = IsReq(pMsg) ? pMsg->msgType : (pMsg->msgType - 1); diff --git a/source/libs/scheduler/src/schTask.c b/source/libs/scheduler/src/schTask.c index b585373b0ad4e80e14a85c91689ba437059ce5bf..de6063fbbc06cc60bf2528a4e18f67e0a4dda67d 100644 --- a/source/libs/scheduler/src/schTask.c +++ b/source/libs/scheduler/src/schTask.c @@ -127,6 +127,7 @@ int32_t schDropTaskExecNode(SSchJob *pJob, SSchTask *pTask, void *handle, int32_ if (taosHashRemove(pTask->execNodes, &execId, sizeof(execId))) { SCH_TASK_DLOG("execId %d already not in execNodeList", execId); + SCH_ERR_RET(TSDB_CODE_SCH_IGNORE_ERROR); } else { SCH_TASK_DLOG("execId %d removed from execNodeList", execId); } diff --git a/source/util/src/thash.c b/source/util/src/thash.c index eb20024ff95dac0831bfa31733cdaa95df885a60..c3d4668e1146226d8420d43ae624547c7f35bd37 100644 --- a/source/util/src/thash.c +++ b/source/util/src/thash.c @@ -798,7 +798,7 @@ static void *taosHashReleaseNode(SHashObj *pHashObj, void *p, int *slot) { } void *taosHashIterate(SHashObj *pHashObj, void *p) { - if (pHashObj == NULL) return NULL; + if (pHashObj == NULL || pHashObj->size == 0) return NULL; int slot = 0; char *data = NULL;