From 8ba8210f646ff1604ab2866bbf6cf26459aa3448 Mon Sep 17 00:00:00 2001 From: xiao-77 Date: Thu, 19 Sep 2024 16:22:23 +0800 Subject: [PATCH 01/18] remove void in wal lruCache and tsdbCache --- source/dnode/vnode/src/tsdb/tsdbCache.c | 319 ++++++++++++++++++++---- source/libs/wal/src/walMeta.c | 139 ++++++++--- source/libs/wal/src/walMgmt.c | 21 +- source/libs/wal/src/walRef.c | 7 +- source/util/src/tlrucache.c | 30 ++- 5 files changed, 426 insertions(+), 90 deletions(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbCache.c b/source/dnode/vnode/src/tsdb/tsdbCache.c index 9cdd4dcdb5..2a954caae6 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCache.c +++ b/source/dnode/vnode/src/tsdb/tsdbCache.c @@ -577,7 +577,10 @@ static void tsdbCacheDeleter(const void *key, size_t klen, void *value, void *ud SLastCol *pLastCol = (SLastCol *)value; if (pLastCol->dirty) { - (void)tsdbCacheFlushDirty(key, klen, pLastCol, ud); + if (tsdbCacheFlushDirty(key, klen, pLastCol, ud) != 0) { + STsdb *pTsdb = (STsdb *)ud; + tsdbError("tsdb/cache: vgId:%d, flush cache %s failed at line %d.", TD_VID(pTsdb->pVnode), __func__, __LINE__); + } } for (uint8_t i = 0; i < pLastCol->rowKey.numOfPKs; ++i) { @@ -719,14 +722,30 @@ static int32_t tsdbCacheDropTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid, rocksdb_writebatch_t *wb = pTsdb->rCache.writebatch; { SLastCol *pLastCol = NULL; - (void)tsdbCacheDeserialize(values_list[0], values_list_sizes[0], &pLastCol); + code = tsdbCacheDeserialize(values_list[0], values_list_sizes[0], &pLastCol); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); + if (pLastCol != NULL) { + taosMemoryFreeClear(pLastCol); + } + goto _exit; + } if (NULL != pLastCol) { rocksdb_writebatch_delete(wb, keys_list[0], klen); } taosMemoryFreeClear(pLastCol); pLastCol = NULL; - (void)tsdbCacheDeserialize(values_list[1], values_list_sizes[1], &pLastCol); + code = tsdbCacheDeserialize(values_list[1], values_list_sizes[1], &pLastCol); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); + if (pLastCol != NULL) { + taosMemoryFreeClear(pLastCol); + } + goto _exit; + } if (NULL != pLastCol) { rocksdb_writebatch_delete(wb, keys_list[1], klen); } @@ -738,7 +757,10 @@ static int32_t tsdbCacheDropTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid, for (int i = 0; i < 2; i++) { LRUHandle *h = taosLRUCacheLookup(pTsdb->lruCache, keys_list[i], klen); if (h) { - (void)taosLRUCacheRelease(pTsdb->lruCache, h, true); + if (taosLRUCacheRelease(pTsdb->lruCache, h, true)) { + tsdbError("vgId:%d, %s release lru cache failed at line %d.", TD_VID(pTsdb->pVnode), __func__, __LINE__); + goto _exit; + } taosLRUCacheErase(pTsdb->lruCache, keys_list[i], klen); } } @@ -765,8 +787,20 @@ int32_t tsdbCacheNewTable(STsdb *pTsdb, tb_uid_t uid, tb_uid_t suid, SSchemaWrap int16_t cid = pSchemaRow->pSchema[i].colId; int8_t col_type = pSchemaRow->pSchema[i].type; - (void)tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, LFLAG_LAST_ROW); - (void)tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, LFLAG_LAST); + code = tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, LFLAG_LAST_ROW); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s new table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); + (void)taosThreadMutexUnlock(&pTsdb->lruMutex); + TAOS_RETURN(code); + } + code = tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, LFLAG_LAST); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s new table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); + (void)taosThreadMutexUnlock(&pTsdb->lruMutex); + TAOS_RETURN(code); + } } } else { STSchema *pTSchema = NULL; @@ -781,8 +815,20 @@ int32_t tsdbCacheNewTable(STsdb *pTsdb, tb_uid_t uid, tb_uid_t suid, SSchemaWrap int16_t cid = pTSchema->columns[i].colId; int8_t col_type = pTSchema->columns[i].type; - (void)tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, LFLAG_LAST_ROW); - (void)tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, LFLAG_LAST); + code = tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, LFLAG_LAST_ROW); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s new table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); + (void)taosThreadMutexUnlock(&pTsdb->lruMutex); + TAOS_RETURN(code); + } + code = tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, LFLAG_LAST); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s new table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); + (void)taosThreadMutexUnlock(&pTsdb->lruMutex); + TAOS_RETURN(code); + } } taosMemoryFree(pTSchema); @@ -798,7 +844,13 @@ int32_t tsdbCacheDropTable(STsdb *pTsdb, tb_uid_t uid, tb_uid_t suid, SSchemaWra (void)taosThreadMutexLock(&pTsdb->lruMutex); - (void)tsdbCacheCommitNoLock(pTsdb); + code = tsdbCacheCommitNoLock(pTsdb); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s commit with no lock failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); + (void)taosThreadMutexUnlock(&pTsdb->lruMutex); + TAOS_RETURN(code); + } if (pSchemaRow != NULL) { bool hasPrimayKey = false; @@ -810,7 +862,13 @@ int32_t tsdbCacheDropTable(STsdb *pTsdb, tb_uid_t uid, tb_uid_t suid, SSchemaWra int16_t cid = pSchemaRow->pSchema[i].colId; int8_t col_type = pSchemaRow->pSchema[i].type; - (void)tsdbCacheDropTableColumn(pTsdb, uid, cid, hasPrimayKey); + code = tsdbCacheDropTableColumn(pTsdb, uid, cid, hasPrimayKey); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s drop table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); + (void)taosThreadMutexUnlock(&pTsdb->lruMutex); + TAOS_RETURN(code); + } } } else { STSchema *pTSchema = NULL; @@ -830,7 +888,13 @@ int32_t tsdbCacheDropTable(STsdb *pTsdb, tb_uid_t uid, tb_uid_t suid, SSchemaWra int16_t cid = pTSchema->columns[i].colId; int8_t col_type = pTSchema->columns[i].type; - (void)tsdbCacheDropTableColumn(pTsdb, uid, cid, hasPrimayKey); + code = tsdbCacheDropTableColumn(pTsdb, uid, cid, hasPrimayKey); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s drop table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); + (void)taosThreadMutexUnlock(&pTsdb->lruMutex); + TAOS_RETURN(code); + } } taosMemoryFree(pTSchema); @@ -848,7 +912,13 @@ int32_t tsdbCacheDropSubTables(STsdb *pTsdb, SArray *uids, tb_uid_t suid) { (void)taosThreadMutexLock(&pTsdb->lruMutex); - (void)tsdbCacheCommitNoLock(pTsdb); + code = tsdbCacheCommitNoLock(pTsdb); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s commit with no lock failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); + (void)taosThreadMutexUnlock(&pTsdb->lruMutex); + TAOS_RETURN(code); + } STSchema *pTSchema = NULL; code = metaGetTbTSchemaEx(pTsdb->pVnode->pMeta, suid, suid, -1, &pTSchema); @@ -871,7 +941,13 @@ int32_t tsdbCacheDropSubTables(STsdb *pTsdb, SArray *uids, tb_uid_t suid) { int16_t cid = pTSchema->columns[i].colId; int8_t col_type = pTSchema->columns[i].type; - (void)tsdbCacheDropTableColumn(pTsdb, uid, cid, hasPrimayKey); + code = tsdbCacheDropTableColumn(pTsdb, uid, cid, hasPrimayKey); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s drop table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); + (void)taosThreadMutexUnlock(&pTsdb->lruMutex); + TAOS_RETURN(code); + } } } @@ -889,12 +965,22 @@ int32_t tsdbCacheNewNTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid, int8_t (void)taosThreadMutexLock(&pTsdb->lruMutex); - (void)tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, 0); - (void)tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, 1); - + code = tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, 0); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s new table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); + (void)taosThreadMutexUnlock(&pTsdb->lruMutex); + TAOS_RETURN(code); + } + code = tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, 1); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s new table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); + (void)taosThreadMutexUnlock(&pTsdb->lruMutex); + TAOS_RETURN(code); + } // rocksMayWrite(pTsdb, true, false, false); (void)taosThreadMutexUnlock(&pTsdb->lruMutex); - //(void)tsdbCacheCommit(pTsdb); TAOS_RETURN(code); } @@ -904,9 +990,21 @@ int32_t tsdbCacheDropNTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid, bool h (void)taosThreadMutexLock(&pTsdb->lruMutex); - (void)tsdbCacheCommitNoLock(pTsdb); + code = tsdbCacheCommitNoLock(pTsdb); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s commit with no lock failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); + (void)taosThreadMutexUnlock(&pTsdb->lruMutex); + TAOS_RETURN(code); + } - (void)tsdbCacheDropTableColumn(pTsdb, uid, cid, hasPrimayKey); + code = tsdbCacheDropTableColumn(pTsdb, uid, cid, hasPrimayKey); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s drop table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); + (void)taosThreadMutexUnlock(&pTsdb->lruMutex); + TAOS_RETURN(code); + } rocksMayWrite(pTsdb, false); @@ -923,14 +1021,24 @@ int32_t tsdbCacheNewSTableColumn(STsdb *pTsdb, SArray *uids, int16_t cid, int8_t for (int i = 0; i < TARRAY_SIZE(uids); ++i) { tb_uid_t uid = ((tb_uid_t *)TARRAY_DATA(uids))[i]; - (void)tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, 0); - (void)tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, 1); + code = tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, 0); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s new table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); + (void)taosThreadMutexUnlock(&pTsdb->lruMutex); + TAOS_RETURN(code); + } + code = tsdbCacheNewTableColumn(pTsdb, uid, cid, col_type, 1); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s new table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); + (void)taosThreadMutexUnlock(&pTsdb->lruMutex); + TAOS_RETURN(code); + } } // rocksMayWrite(pTsdb, true, false, false); (void)taosThreadMutexUnlock(&pTsdb->lruMutex); - //(void)tsdbCacheCommit(pTsdb); - TAOS_RETURN(code); } @@ -939,12 +1047,24 @@ int32_t tsdbCacheDropSTableColumn(STsdb *pTsdb, SArray *uids, int16_t cid, bool (void)taosThreadMutexLock(&pTsdb->lruMutex); - (void)tsdbCacheCommitNoLock(pTsdb); + code = tsdbCacheCommitNoLock(pTsdb); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s commit with no lock failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); + (void)taosThreadMutexUnlock(&pTsdb->lruMutex); + TAOS_RETURN(code); + } for (int i = 0; i < TARRAY_SIZE(uids); ++i) { int64_t uid = ((tb_uid_t *)TARRAY_DATA(uids))[i]; - (void)tsdbCacheDropTableColumn(pTsdb, uid, cid, hasPrimayKey); + code = tsdbCacheDropTableColumn(pTsdb, uid, cid, hasPrimayKey); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s drop table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); + (void)taosThreadMutexUnlock(&pTsdb->lruMutex); + TAOS_RETURN(code); + } } rocksMayWrite(pTsdb, false); @@ -1109,7 +1229,7 @@ static int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SArray } } - (void)taosLRUCacheRelease(pCache, h, false); + code = taosLRUCacheRelease(pCache, h, false); TAOS_CHECK_EXIT(code); } else { if (!remainCols) { @@ -1151,7 +1271,7 @@ static int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SArray keys_list_sizes[i] = ROCKS_KEY_LEN; } - rocksMayWrite(pTsdb, true); // flush writebatch cache + rocksMayWrite(pTsdb, true); // flush writebatch cache code = tsdbCacheGetValuesFromRocks(pTsdb, num_keys, (const char *const *)keys_list, keys_list_sizes, &values_list, &values_list_sizes); @@ -1169,7 +1289,15 @@ static int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SArray SColVal *pColVal = &updCtx->colVal; SLastCol *pLastCol = NULL; - (void)tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol); + code = tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); + if (pLastCol != NULL) { + taosMemoryFreeClear(pLastCol); + } + goto _exit; + } /* if (code) { tsdbError("tsdb/cache: vgId:%d, deserialize failed since %s.", TD_VID(pTsdb->pVnode), tstrerror(code)); @@ -1268,7 +1396,12 @@ int32_t tsdbCacheRowFormatUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, int6 tsdbRowGetKey(&lRow, &tsdbRowKey); STSDBRowIter iter = {0}; - (void)tsdbRowIterOpen(&iter, &lRow, pTSchema); + code = tsdbRowIterOpen(&iter, &lRow, pTSchema); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s tsdbRowIterOpen failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); + TAOS_CHECK_GOTO(code, &lino, _exit); + } int32_t iCol = 0; for (SColVal *pColVal = tsdbRowIterNext(&iter); pColVal && iCol < nCol; pColVal = tsdbRowIterNext(&iter), iCol++) { SLastUpdateCtx updateCtx = {.lflag = LFLAG_LAST_ROW, .tsdbRowKey = tsdbRowKey, .colVal = *pColVal}; @@ -1312,13 +1445,23 @@ int32_t tsdbCacheRowFormatUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, int6 if (!taosArrayPush(ctxArray, &updateCtx)) { TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _exit); } - (void)tSimpleHashIterateRemove(iColHash, &iCol, sizeof(iCol), &pIte, &iter); + code = tSimpleHashIterateRemove(iColHash, &iCol, sizeof(iCol), &pIte, &iter); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s tSimpleHashIterateRemove failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, + __LINE__, tstrerror(code)); + TAOS_CHECK_GOTO(code, &lino, _exit); + } } } } // 3. do update - (void)tsdbCacheUpdate(pTsdb, suid, uid, ctxArray); + code = tsdbCacheUpdate(pTsdb, suid, uid, ctxArray); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s tsdbCacheUpdate failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); + TAOS_CHECK_GOTO(code, &lino, _exit); + } _exit: taosMemoryFreeClear(pTSchema); @@ -1384,7 +1527,12 @@ int32_t tsdbCacheColFormatUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SBlo // 2. prepare last row STSDBRowIter iter = {0}; - (void)tsdbRowIterOpen(&iter, &lRow, pTSchema); + code = tsdbRowIterOpen(&iter, &lRow, pTSchema); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s tsdbRowIterOpen failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); + TAOS_CHECK_GOTO(code, &lino, _exit); + } for (SColVal *pColVal = tsdbRowIterNext(&iter); pColVal; pColVal = tsdbRowIterNext(&iter)) { SLastUpdateCtx updateCtx = {.lflag = LFLAG_LAST_ROW, .tsdbRowKey = tsdbRowKey, .colVal = *pColVal}; if (!taosArrayPush(ctxArray, &updateCtx)) { @@ -1394,7 +1542,12 @@ int32_t tsdbCacheColFormatUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SBlo tsdbRowClose(&iter); // 3. do update - (void)tsdbCacheUpdate(pTsdb, suid, uid, ctxArray); + code = tsdbCacheUpdate(pTsdb, suid, uid, ctxArray); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s tsdbCacheUpdate failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); + TAOS_CHECK_GOTO(code, &lino, _exit); + } _exit: taosMemoryFreeClear(pTSchema); @@ -1604,7 +1757,7 @@ static int32_t tsdbCacheLoadFromRocks(STsdb *pTsdb, tb_uid_t uid, SArray *pLastA keys_list_sizes[i] = ROCKS_KEY_LEN; } - rocksMayWrite(pTsdb, true); // flush writebatch cache + rocksMayWrite(pTsdb, true); // flush writebatch cache code = tsdbCacheGetValuesFromRocks(pTsdb, num_keys, (const char *const *)keys_list, keys_list_sizes, &values_list, &values_list_sizes); @@ -1624,7 +1777,15 @@ static int32_t tsdbCacheLoadFromRocks(STsdb *pTsdb, tb_uid_t uid, SArray *pLastA continue; } - (void)tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol); + code = tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); + if (pLastCol != NULL) { + taosMemoryFreeClear(pLastCol); + } + goto _exit; + } SLastCol *pToFree = pLastCol; SIdxKey *idxKey = &((SIdxKey *)TARRAY_DATA(remainCols))[j]; if (pLastCol && pLastCol->cacheStatus != TSDB_LAST_CACHE_NO_CACHE) { @@ -1757,7 +1918,11 @@ int32_t tsdbCacheGetBatch(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SCache } if (h) { - (void)taosLRUCacheRelease(pCache, h, false); + code = taosLRUCacheRelease(pCache, h, false); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s release lru cache failed at line %d.", TD_VID(pTsdb->pVnode), __func__, __LINE__); + goto _exit; + } } } @@ -1786,7 +1951,11 @@ int32_t tsdbCacheGetBatch(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SCache } if (h) { - (void)taosLRUCacheRelease(pCache, h, false); + code = taosLRUCacheRelease(pCache, h, false); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s release lru cache failed at line %d.", TD_VID(pTsdb->pVnode), __func__, __LINE__); + goto _exit; + } } } @@ -1820,7 +1989,13 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE int numKeys = 0; SArray *remainCols = NULL; - (void)tsdbCacheCommit(pTsdb); + code = tsdbCacheCommit(pTsdb); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s commit failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); + (void)taosThreadMutexUnlock(&pTsdb->lruMutex); + TAOS_RETURN(code); + } (void)taosThreadMutexLock(&pTsdb->lruMutex); @@ -1837,7 +2012,11 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE .cacheStatus = TSDB_LAST_CACHE_NO_CACHE}; code = tsdbCachePutToLRU(pTsdb, &lastKey, &noneCol); } - (void)taosLRUCacheRelease(pTsdb->lruCache, h, false); + code = taosLRUCacheRelease(pTsdb->lruCache, h, false); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s release lru cache failed at line %d.", TD_VID(pTsdb->pVnode), __func__, __LINE__); + goto _exit; + } TAOS_CHECK_EXIT(code); } else { if (!remainCols) { @@ -1871,7 +2050,7 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE code = terrno; goto _exit; } - SIdxKey* idxKey = taosArrayGet(remainCols, i); + SIdxKey *idxKey = taosArrayGet(remainCols, i); ((SLastKey *)key)[0] = idxKey->key; @@ -1879,7 +2058,7 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE keys_list_sizes[i] = klen; } - rocksMayWrite(pTsdb, true); // flush writebatch cache + rocksMayWrite(pTsdb, true); // flush writebatch cache TAOS_CHECK_GOTO(tsdbCacheGetValuesFromRocks(pTsdb, numKeys, (const char *const *)keys_list, keys_list_sizes, &values_list, &values_list_sizes), @@ -1888,8 +2067,16 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE rocksdb_writebatch_t *wb = pTsdb->rCache.writebatch; for (int i = 0; i < numKeys; ++i) { SLastCol *pLastCol = NULL; - (void)tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol); - SIdxKey* idxKey = taosArrayGet(remainCols, i); + code = tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); + if (pLastCol != NULL) { + taosMemoryFreeClear(pLastCol); + } + goto _exit; + } + SIdxKey *idxKey = taosArrayGet(remainCols, i); SLastKey *pLastKey = &idxKey->key; if (NULL != pLastCol && (pLastCol->rowKey.ts <= eKey && pLastCol->rowKey.ts >= sKey)) { SLastCol noCacheCol = {.rowKey.ts = TSKEY_MIN, @@ -2389,7 +2576,12 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow, bool *pIgnoreEarlie state->pr->pCurFileSet = state->pFileSet; - (void)loadDataTomb(state->pr, state->pr->pFileReader); + code = loadDataTomb(state->pr, state->pr->pFileReader); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s load tomb failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); + TAOS_CHECK_GOTO(code, &lino, _err); + } TAOS_CHECK_GOTO(tsdbDataFileReadBrinBlk(state->pr->pFileReader, &state->pr->pBlkArray), &lino, _err); } @@ -2467,7 +2659,12 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow, bool *pIgnoreEarlie if (!state->pLastRow) { if (state->pLastIter) { - (void)lastIterClose(&state->pLastIter); + code = lastIterClose(&state->pLastIter); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s close last iter failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); + TAOS_RETURN(code); + } } clearLastFileSet(state); @@ -2575,7 +2772,12 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow, bool *pIgnoreEarlie if (!state->pLastRow) { if (state->pLastIter) { - (void)lastIterClose(&state->pLastIter); + code = lastIterClose(&state->pLastIter); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s close last iter failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); + TAOS_RETURN(code); + } } *ppRow = &state->row; @@ -2599,7 +2801,12 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow, bool *pIgnoreEarlie } else { // TODO: merge rows and *ppRow = mergedRow SRowMerger *pMerger = &state->rowMerger; - (void)tsdbRowMergerInit(pMerger, state->pTSchema); + code = tsdbRowMergerInit(pMerger, state->pTSchema); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("vgId:%d, %s init row merger failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); + TAOS_RETURN(code); + } TAOS_CHECK_GOTO(tsdbRowMergerAdd(pMerger, &state->row, state->pTSchema), &lino, _err); TAOS_CHECK_GOTO(tsdbRowMergerAdd(pMerger, state->pLastRow, state->pTSchema), &lino, _err); @@ -2765,7 +2972,11 @@ int32_t clearNextRowFromFS(void *iter) { } if (state->pLastIter) { - (void)lastIterClose(&state->pLastIter); + code = lastIterClose(&state->pLastIter); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("%s close last iter failed at line %d since %s", __func__, __LINE__, tstrerror(code)); + TAOS_RETURN(code); + } } if (state->pBlockData) { @@ -2798,7 +3009,11 @@ int32_t clearNextRowFromFS(void *iter) { static void clearLastFileSet(SFSNextRowIter *state) { if (state->pLastIter) { - (void)lastIterClose(&state->pLastIter); + int code = lastIterClose(&state->pLastIter); + if (code != TSDB_CODE_SUCCESS) { + tsdbError("%s close last iter failed at line %d since %s", __func__, __LINE__, tstrerror(code)); + return; + } } if (state->pBlockData) { @@ -3363,7 +3578,11 @@ _err: TAOS_RETURN(code); } -void tsdbCacheRelease(SLRUCache *pCache, LRUHandle *h) { (void)taosLRUCacheRelease(pCache, h, false); } +void tsdbCacheRelease(SLRUCache *pCache, LRUHandle *h) { + if (taosLRUCacheRelease(pCache, h, false)) { + tsdbError("%s release lru cache failed at line %d.", __func__, __LINE__); + } +} void tsdbCacheSetCapacity(SVnode *pVnode, size_t capacity) { taosLRUCacheSetCapacity(pVnode->pTsdb->lruCache, capacity); diff --git a/source/libs/wal/src/walMeta.c b/source/libs/wal/src/walMeta.c index 0dd55aacdb..e813401fbb 100644 --- a/source/libs/wal/src/walMeta.c +++ b/source/libs/wal/src/walMeta.c @@ -57,7 +57,10 @@ static FORCE_INLINE int32_t walScanLogGetLastVer(SWal* pWal, int32_t fileIdx, in walBuildLogName(pWal, pFileInfo->firstVer, fnameStr); int64_t fileSize = 0; - (void)taosStatFile(fnameStr, &fileSize, NULL, NULL); + if (taosStatFile(fnameStr, &fileSize, NULL, NULL) != 0) { + code = terrno; + goto _err; + } TdFilePtr pFile = taosOpenFile(fnameStr, TD_FILE_READ | TD_FILE_WRITE); if (pFile == NULL) { @@ -356,6 +359,7 @@ static int32_t walLogEntriesComplete(const SWal* pWal) { } static int32_t walTrimIdxFile(SWal* pWal, int32_t fileIdx) { + int32_t code = 0; SWalFileInfo* pFileInfo = taosArrayGet(pWal->fileInfoSet, fileIdx); if (!pFileInfo) { TAOS_RETURN(TSDB_CODE_FAILED); @@ -365,7 +369,10 @@ static int32_t walTrimIdxFile(SWal* pWal, int32_t fileIdx) { walBuildIdxName(pWal, pFileInfo->firstVer, fnameStr); int64_t fileSize = 0; - (void)taosStatFile(fnameStr, &fileSize, NULL, NULL); + if (taosStatFile(fnameStr, &fileSize, NULL, NULL) != 0) { + code = terrno; + TAOS_RETURN(code); + } int64_t records = TMAX(0, pFileInfo->lastVer - pFileInfo->firstVer + 1); int64_t lastEndOffset = records * sizeof(SWalIdxEntry); @@ -381,7 +388,10 @@ static int32_t walTrimIdxFile(SWal* pWal, int32_t fileIdx) { wInfo("vgId:%d, trim idx file. file: %s, size: %" PRId64 ", offset: %" PRId64, pWal->cfg.vgId, fnameStr, fileSize, lastEndOffset); - (void)taosFtruncateFile(pFile, lastEndOffset); + code = taosFtruncateFile(pFile, lastEndOffset); + if (code < 0) { + TAOS_RETURN(code); + } (void)taosCloseFile(&pFile); TAOS_RETURN(TSDB_CODE_SUCCESS); @@ -395,8 +405,14 @@ int32_t walCheckAndRepairMeta(SWal* pWal) { regex_t logRegPattern; regex_t idxRegPattern; - (void)regcomp(&logRegPattern, logPattern, REG_EXTENDED); - (void)regcomp(&idxRegPattern, idxPattern, REG_EXTENDED); + if (regcomp(&logRegPattern, logPattern, REG_EXTENDED) != 0) { + wError("failed to compile log pattern, error:%s", tstrerror(terrno)); + return terrno; + } + if (regcomp(&idxRegPattern, idxPattern, REG_EXTENDED) != 0) { + wError("failed to compile idx pattern"); + return terrno; + } TdDirPtr pDir = taosOpenDir(pWal->path); if (pDir == NULL) { @@ -420,14 +436,22 @@ int32_t walCheckAndRepairMeta(SWal* pWal) { if (!taosArrayPush(actualLog, &fileInfo)) { regfree(&logRegPattern); regfree(&idxRegPattern); - (void)taosCloseDir(&pDir); + int32_t ret = taosCloseDir(&pDir); + if (ret != 0) { + wError("failed to close dir, ret:%s", tstrerror(ret)); + return terrno; + } return terrno; } } } - (void)taosCloseDir(&pDir); + int32_t ret = taosCloseDir(&pDir); + if (ret != 0) { + wError("failed to close dir, ret:%s", tstrerror(ret)); + return terrno; + } regfree(&logRegPattern); regfree(&idxRegPattern); @@ -684,7 +708,9 @@ _err: int64_t walGetVerRetention(SWal* pWal, int64_t bytes) { int64_t ver = -1; int64_t totSize = 0; - (void)taosThreadRwlockRdlock(&pWal->mutex); + if (taosThreadRwlockRdlock(&pWal->mutex) != 0) { + wError("vgId:%d failed to lock %p", pWal->cfg.vgId, &pWal->mutex); + } int32_t fileIdx = taosArrayGetSize(pWal->fileInfoSet); while (--fileIdx) { SWalFileInfo* pInfo = taosArrayGet(pWal->fileInfoSet, fileIdx); @@ -694,7 +720,9 @@ int64_t walGetVerRetention(SWal* pWal, int64_t bytes) { } totSize += pInfo->fileSize; } - (void)taosThreadRwlockUnlock(&pWal->mutex); + if (taosThreadRwlockUnlock(&pWal->mutex) != 0) { + wError("vgId:%d failed to lock %p", pWal->cfg.vgId, &pWal->mutex); + } return ver + 1; } @@ -765,21 +793,35 @@ int32_t walMetaSerialize(SWal* pWal, char** serialized) { TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY); } - (void)cJSON_AddItemToObject(pRoot, "meta", pMeta); + if (cJSON_AddItemToObject(pRoot, "meta", pMeta) != 0) { + wError("vgId:%d, failed to add meta to root", pWal->cfg.vgId); + } (void)sprintf(buf, "%" PRId64, pWal->vers.firstVer); - (void)cJSON_AddStringToObject(pMeta, "firstVer", buf); + if (cJSON_AddStringToObject(pMeta, "firstVer", buf) == NULL) { + wError("vgId:%d, failed to add firstVer to meta", pWal->cfg.vgId); + } (void)sprintf(buf, "%" PRId64, pWal->vers.snapshotVer); - (void)cJSON_AddStringToObject(pMeta, "snapshotVer", buf); + if (cJSON_AddStringToObject(pMeta, "snapshotVer", buf) == NULL) { + wError("vgId:%d, failed to add snapshotVer to meta", pWal->cfg.vgId); + } (void)sprintf(buf, "%" PRId64, pWal->vers.commitVer); - (void)cJSON_AddStringToObject(pMeta, "commitVer", buf); + if (cJSON_AddStringToObject(pMeta, "commitVer", buf) == NULL) { + wError("vgId:%d, failed to add commitVer to meta", pWal->cfg.vgId); + } (void)sprintf(buf, "%" PRId64, pWal->vers.lastVer); - (void)cJSON_AddStringToObject(pMeta, "lastVer", buf); + if (cJSON_AddStringToObject(pMeta, "lastVer", buf) == NULL) { + wError("vgId:%d, failed to add lastVer to meta", pWal->cfg.vgId); + } - (void)cJSON_AddItemToObject(pRoot, "files", pFiles); + if (cJSON_AddItemToObject(pRoot, "files", pFiles) != 0) { + wError("vgId:%d, failed to add files to root", pWal->cfg.vgId); + } SWalFileInfo* pData = pWal->fileInfoSet->pData; for (int i = 0; i < sz; i++) { SWalFileInfo* pInfo = &pData[i]; - (void)cJSON_AddItemToArray(pFiles, pField = cJSON_CreateObject()); + if (cJSON_AddItemToArray(pFiles, pField = cJSON_CreateObject()) != 0) { + wError("vgId:%d, failed to add field to files", pWal->cfg.vgId); + } if (pField == NULL) { cJSON_Delete(pRoot); @@ -788,15 +830,25 @@ int32_t walMetaSerialize(SWal* pWal, char** serialized) { // cjson only support int32_t or double // string are used to prohibit the loss of precision (void)sprintf(buf, "%" PRId64, pInfo->firstVer); - (void)cJSON_AddStringToObject(pField, "firstVer", buf); + if (cJSON_AddStringToObject(pField, "firstVer", buf) == NULL) { + wError("vgId:%d, failed to add firstVer to field", pWal->cfg.vgId); + } (void)sprintf(buf, "%" PRId64, pInfo->lastVer); - (void)cJSON_AddStringToObject(pField, "lastVer", buf); + if (cJSON_AddStringToObject(pField, "lastVer", buf) == NULL) { + wError("vgId:%d, failed to add lastVer to field", pWal->cfg.vgId); + } (void)sprintf(buf, "%" PRId64, pInfo->createTs); - (void)cJSON_AddStringToObject(pField, "createTs", buf); + if (cJSON_AddStringToObject(pField, "createTs", buf) == NULL) { + wError("vgId:%d, failed to add createTs to field", pWal->cfg.vgId); + } (void)sprintf(buf, "%" PRId64, pInfo->closeTs); - (void)cJSON_AddStringToObject(pField, "closeTs", buf); + if (cJSON_AddStringToObject(pField, "closeTs", buf) == NULL) { + wError("vgId:%d, failed to add closeTs to field", pWal->cfg.vgId); + } (void)sprintf(buf, "%" PRId64, pInfo->fileSize); - (void)cJSON_AddStringToObject(pField, "fileSize", buf); + if (cJSON_AddStringToObject(pField, "fileSize", buf) == NULL) { + wError("vgId:%d, failed to add fileSize to field", pWal->cfg.vgId); + } } char* pSerialized = cJSON_Print(pRoot); cJSON_Delete(pRoot); @@ -874,7 +926,10 @@ _err: static int walFindCurMetaVer(SWal* pWal) { const char* pattern = "^meta-ver[0-9]+$"; regex_t walMetaRegexPattern; - (void)regcomp(&walMetaRegexPattern, pattern, REG_EXTENDED); + if (regcomp(&walMetaRegexPattern, pattern, REG_EXTENDED) != 0) { + wError("failed to compile wal meta pattern, error %s", tstrerror(terrno)); + return terrno; + } TdDirPtr pDir = taosOpenDir(pWal->path); if (pDir == NULL) { @@ -896,7 +951,10 @@ static int walFindCurMetaVer(SWal* pWal) { } wDebug("vgId:%d, wal find current meta: %s is not meta file", pWal->cfg.vgId, name); } - (void)taosCloseDir(&pDir); + if (taosCloseDir(&pDir) != 0) { + wError("failed to close dir, ret:%s", tstrerror(terrno)); + return terrno; + } regfree(&walMetaRegexPattern); return metaVer; } @@ -979,8 +1037,16 @@ int32_t walSaveMeta(SWal* pWal) { // delete old file if (metaVer > -1) { - (void)walBuildMetaName(pWal, metaVer, fnameStr); - (void)taosRemoveFile(fnameStr); + n = walBuildMetaName(pWal, metaVer, fnameStr); + if (n >= sizeof(fnameStr)) { + TAOS_RETURN(TAOS_SYSTEM_ERROR(errno)); + } + code = taosRemoveFile(fnameStr); + if (code) { + wError("vgId:%d, failed to remove file due to %s. file:%s", pWal->cfg.vgId, strerror(errno), fnameStr); + } else { + wInfo("vgId:%d, remove old meta file: %s", pWal->cfg.vgId, fnameStr); + } } taosMemoryFree(serialized); @@ -994,6 +1060,7 @@ _err: int32_t walLoadMeta(SWal* pWal) { int32_t code = 0; + int n = 0; // find existing meta file int metaVer = walFindCurMetaVer(pWal); if (metaVer == -1) { @@ -1002,12 +1069,23 @@ int32_t walLoadMeta(SWal* pWal) { TAOS_RETURN(TSDB_CODE_FAILED); } char fnameStr[WAL_FILE_LEN]; - (void)walBuildMetaName(pWal, metaVer, fnameStr); + n = walBuildMetaName(pWal, metaVer, fnameStr); + if (n >= sizeof(fnameStr)) { + TAOS_RETURN(TAOS_SYSTEM_ERROR(errno)); + } // read metafile int64_t fileSize = 0; - (void)taosStatFile(fnameStr, &fileSize, NULL, NULL); + if (taosStatFile(fnameStr, &fileSize, NULL, NULL) != 0) { + code = terrno; + TAOS_RETURN(code); + } if (fileSize == 0) { - (void)taosRemoveFile(fnameStr); + code = taosRemoveFile(fnameStr); + if (code) { + wError("vgId:%d, failed to remove file due to %s. file:%s", pWal->cfg.vgId, strerror(errno), fnameStr); + } else { + wInfo("vgId:%d, remove old meta file: %s", pWal->cfg.vgId, fnameStr); + } wDebug("vgId:%d, wal find empty meta ver %d", pWal->cfg.vgId, metaVer); TAOS_RETURN(TSDB_CODE_FAILED); @@ -1046,6 +1124,9 @@ int32_t walRemoveMeta(SWal* pWal) { int metaVer = walFindCurMetaVer(pWal); if (metaVer == -1) return 0; char fnameStr[WAL_FILE_LEN]; - (void)walBuildMetaName(pWal, metaVer, fnameStr); + int n = walBuildMetaName(pWal, metaVer, fnameStr); + if (n >= sizeof(fnameStr)) { + TAOS_RETURN(TAOS_SYSTEM_ERROR(errno)); + } return taosRemoveFile(fnameStr); } diff --git a/source/libs/wal/src/walMgmt.c b/source/libs/wal/src/walMgmt.c index 3bb4b9d747..0f0f9b24bd 100644 --- a/source/libs/wal/src/walMgmt.c +++ b/source/libs/wal/src/walMgmt.c @@ -160,7 +160,10 @@ SWal *walOpen(const char *path, SWalCfg *pCfg) { pWal->writeHead.magic = WAL_MAGIC; // load meta - (void)walLoadMeta(pWal); + if (walLoadMeta(pWal) < 0) { + wError("vgId:%d, failed to load meta since %s", pWal->cfg.vgId, tstrerror(terrno)); + goto _err; + } if (walCheckAndRepairMeta(pWal) < 0) { wError("vgId:%d, cannot open wal since repair meta file failed", pWal->cfg.vgId); @@ -233,7 +236,9 @@ int32_t walPersist(SWal *pWal) { void walClose(SWal *pWal) { TAOS_UNUSED(taosThreadRwlockWrlock(&pWal->mutex)); - (void)walSaveMeta(pWal); + if (walSaveMeta(pWal) < 0) { + wError("vgId:%d, failed to save meta since %s", pWal->cfg.vgId, tstrerror(terrno)); + } TAOS_UNUSED(taosCloseFile(&pWal->pLogFile)); pWal->pLogFile = NULL; (void)taosCloseFile(&pWal->pIdxFile); @@ -257,10 +262,14 @@ void walClose(SWal *pWal) { if (pWal->cfg.level == TAOS_WAL_SKIP) { wInfo("vgId:%d, remove all wals, path:%s", pWal->cfg.vgId, pWal->path); taosRemoveDir(pWal->path); - (void)taosMkDir(pWal->path); + if (taosMkDir(pWal->path) != 0) { + wError("vgId:%d, path:%s, failed to create directory since %s", pWal->cfg.vgId, pWal->path, tstrerror(terrno)); + } } - (void)taosRemoveRef(tsWal.refSetId, pWal->refId); + if (taosRemoveRef(tsWal.refSetId, pWal->refId) < 0) { + wError("vgId:%d, failed to remove ref for Wal since %s", pWal->cfg.vgId, tstrerror(terrno)); + } } static void walFreeObj(void *wal) { @@ -285,7 +294,9 @@ static bool walNeedFsync(SWal *pWal) { static void walUpdateSeq() { taosMsleep(WAL_REFRESH_MS); - (void)atomic_add_fetch_32((volatile int32_t *)&tsWal.seq, 1); + if (atomic_add_fetch_32((volatile int32_t *)&tsWal.seq, 1) < 0) { + wError("failed to update wal seq since %s", strerror(errno)); + } } static void walFsyncAll() { diff --git a/source/libs/wal/src/walRef.c b/source/libs/wal/src/walRef.c index bf24ed89fb..6b8b063b2b 100644 --- a/source/libs/wal/src/walRef.c +++ b/source/libs/wal/src/walRef.c @@ -52,8 +52,11 @@ void walCloseRef(SWal *pWal, int64_t refId) { } else { wDebug("vgId:%d, wal close ref null, refId %" PRId64, pWal->cfg.vgId, refId); } - - (void)taosHashRemove(pWal->pRefHash, &refId, sizeof(int64_t)); + int32_t code = 0; + code = taosHashRemove(pWal->pRefHash, &refId, sizeof(int64_t)); + if (code) { + wError("vgId:%d, wal remove ref failed, refId %" PRId64 ", error:%s", pWal->cfg.vgId, refId, tstrerror(code)); + } } } diff --git a/source/util/src/tlrucache.c b/source/util/src/tlrucache.c index cfbd875890..3ef7bf16d6 100644 --- a/source/util/src/tlrucache.c +++ b/source/util/src/tlrucache.c @@ -14,12 +14,12 @@ */ #define _DEFAULT_SOURCE -#include "tlrucache.h" #include "os.h" #include "taoserror.h" #include "tarray.h" #include "tdef.h" #include "tlog.h" +#include "tlrucache.h" #include "tutil.h" typedef struct SLRUEntry SLRUEntry; @@ -305,7 +305,15 @@ static void taosLRUCacheShardEvictLRU(SLRUCacheShard *shard, size_t charge, SArr SLRUEntry *old = shard->lru.next; taosLRUCacheShardLRURemove(shard, old); - (void)taosLRUEntryTableRemove(&shard->table, old->keyData, old->keyLength, old->hash); + SLRUEntry *e = taosLRUEntryTableRemove(&shard->table, old->keyData, old->keyLength, old->hash); + if (e != NULL) { + TAOS_LRU_ENTRY_SET_IN_CACHE(e, false); + if (!TAOS_LRU_ENTRY_HAS_REFS(e)) { + taosLRUCacheShardLRURemove(shard, e); + + shard->usage -= e->totalCharge; + } + } TAOS_LRU_ENTRY_SET_IN_CACHE(old, false); shard->usage -= old->totalCharge; @@ -529,7 +537,14 @@ static void taosLRUCacheShardEraseUnrefEntries(SLRUCacheShard *shard) { while (shard->lru.next != &shard->lru) { SLRUEntry *old = shard->lru.next; taosLRUCacheShardLRURemove(shard, old); - (void)taosLRUEntryTableRemove(&shard->table, old->keyData, old->keyLength, old->hash); + SLRUEntry *e = taosLRUEntryTableRemove(&shard->table, old->keyData, old->keyLength, old->hash); + if (e != NULL) { + TAOS_LRU_ENTRY_SET_IN_CACHE(e, false); + if (!TAOS_LRU_ENTRY_HAS_REFS(e)) { + taosLRUCacheShardLRURemove(shard, e); + shard->usage -= e->totalCharge; + } + } TAOS_LRU_ENTRY_SET_IN_CACHE(old, false); shard->usage -= old->totalCharge; @@ -574,7 +589,14 @@ static bool taosLRUCacheShardRelease(SLRUCacheShard *shard, LRUHandle *handle, b lastReference = taosLRUEntryUnref(e); if (lastReference && TAOS_LRU_ENTRY_IN_CACHE(e)) { if (shard->usage > shard->capacity || eraseIfLastRef) { - (void)taosLRUEntryTableRemove(&shard->table, e->keyData, e->keyLength, e->hash); + SLRUEntry *e = taosLRUEntryTableRemove(&shard->table, e->keyData, e->keyLength, e->hash); + if (e != NULL) { + TAOS_LRU_ENTRY_SET_IN_CACHE(e, false); + if (!TAOS_LRU_ENTRY_HAS_REFS(e)) { + taosLRUCacheShardLRURemove(shard, e); + shard->usage -= e->totalCharge; + } + } TAOS_LRU_ENTRY_SET_IN_CACHE(e, false); } else { taosLRUCacheShardLRUInsert(shard, e); From f4bad8d511452d77e71d4cd98916af416ac53cbb Mon Sep 17 00:00:00 2001 From: xiao-77 Date: Thu, 19 Sep 2024 17:19:41 +0800 Subject: [PATCH 02/18] fix can not start taosd --- source/libs/wal/src/walMgmt.c | 1 - 1 file changed, 1 deletion(-) diff --git a/source/libs/wal/src/walMgmt.c b/source/libs/wal/src/walMgmt.c index 0f0f9b24bd..9370476496 100644 --- a/source/libs/wal/src/walMgmt.c +++ b/source/libs/wal/src/walMgmt.c @@ -162,7 +162,6 @@ SWal *walOpen(const char *path, SWalCfg *pCfg) { // load meta if (walLoadMeta(pWal) < 0) { wError("vgId:%d, failed to load meta since %s", pWal->cfg.vgId, tstrerror(terrno)); - goto _err; } if (walCheckAndRepairMeta(pWal) < 0) { From 8b763bf7562d678103970be0197e3ceef91d80f1 Mon Sep 17 00:00:00 2001 From: menshibin Date: Thu, 19 Sep 2024 19:41:01 +0800 Subject: [PATCH 03/18] modify python version --- Jenkinsfile2 | 4 ++-- tests/parallel_test/run_case.sh | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile2 b/Jenkinsfile2 index b074a0ee05..5321dd8f10 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -306,9 +306,9 @@ def pre_test_build_win() { cd %WIN_CONNECTOR_ROOT% python.exe -m pip install --upgrade pip python -m pip uninstall taospy -y - python -m pip install taospy==2.7.13 + python -m pip install taospy==2.7.16 python -m pip uninstall taos-ws-py -y - python -m pip install taos-ws-py==0.3.1 + python -m pip install taos-ws-py==0.3.3 xcopy /e/y/i/f %WIN_INTERNAL_ROOT%\\debug\\build\\lib\\taos.dll C:\\Windows\\System32 ''' return 1 diff --git a/tests/parallel_test/run_case.sh b/tests/parallel_test/run_case.sh index ff84d9e66c..fa8fedbdbe 100755 --- a/tests/parallel_test/run_case.sh +++ b/tests/parallel_test/run_case.sh @@ -76,15 +76,15 @@ ulimit -c unlimited md5sum /usr/lib/libtaos.so.1 md5sum /home/TDinternal/debug/build/lib/libtaos.so -#define taospy 2.7.10 +#define taospy 2.7.16 pip3 list|grep taospy pip3 uninstall taospy -y -pip3 install --default-timeout=120 taospy==2.7.15 +pip3 install --default-timeout=120 taospy==2.7.16 #define taos-ws-py 0.3.1 pip3 list|grep taos-ws-py pip3 uninstall taos-ws-py -y -pip3 install --default-timeout=600 taos-ws-py==0.3.1 +pip3 install --default-timeout=600 taos-ws-py==0.3.3 $TIMEOUT_CMD $cmd RET=$? From 389f5ff088db9cc4e16c0250311fa085b2f01da0 Mon Sep 17 00:00:00 2001 From: xiao-77 Date: Thu, 19 Sep 2024 20:56:13 +0800 Subject: [PATCH 04/18] fix core at tsdbCache --- source/dnode/vnode/src/tsdb/tsdbCache.c | 12 +++++----- source/libs/wal/src/walMeta.c | 29 +++++++++++++++---------- source/libs/wal/src/walMgmt.c | 2 +- source/util/src/tlrucache.c | 1 - 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbCache.c b/source/dnode/vnode/src/tsdb/tsdbCache.c index 2a954caae6..4be3d92af7 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCache.c +++ b/source/dnode/vnode/src/tsdb/tsdbCache.c @@ -758,8 +758,7 @@ static int32_t tsdbCacheDropTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid, LRUHandle *h = taosLRUCacheLookup(pTsdb->lruCache, keys_list[i], klen); if (h) { if (taosLRUCacheRelease(pTsdb->lruCache, h, true)) { - tsdbError("vgId:%d, %s release lru cache failed at line %d.", TD_VID(pTsdb->pVnode), __func__, __LINE__); - goto _exit; + tsdbInfo("vgId:%d, %s release lru cache failed at line %d.", TD_VID(pTsdb->pVnode), __func__, __LINE__); } taosLRUCacheErase(pTsdb->lruCache, keys_list[i], klen); } @@ -1229,7 +1228,9 @@ static int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SArray } } - code = taosLRUCacheRelease(pCache, h, false); + if (!taosLRUCacheRelease(pCache, h, false)) { + tsdbInfo("vgId:%d, %s release lru cache failed at line %d", TD_VID(pTsdb->pVnode), __func__, __LINE__); + } TAOS_CHECK_EXIT(code); } else { if (!remainCols) { @@ -1365,7 +1366,8 @@ _exit: taosArrayDestroy(remainCols); if (code) { - tsdbError("tsdb/cache: vgId:%d, update failed at line %d since %s.", TD_VID(pTsdb->pVnode), lino, tstrerror(code)); + tsdbError("tsdb/cache: vgId:%d, update failed at line %d since %s.", TD_VID(pTsdb->pVnode), __LINE__, + tstrerror(code)); } TAOS_RETURN(code); @@ -1457,7 +1459,7 @@ int32_t tsdbCacheRowFormatUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, int6 // 3. do update code = tsdbCacheUpdate(pTsdb, suid, uid, ctxArray); - if (code != TSDB_CODE_SUCCESS) { + if (code < TSDB_CODE_SUCCESS) { tsdbError("vgId:%d, %s tsdbCacheUpdate failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, tstrerror(code)); TAOS_CHECK_GOTO(code, &lino, _exit); diff --git a/source/libs/wal/src/walMeta.c b/source/libs/wal/src/walMeta.c index e813401fbb..0fad72d20a 100644 --- a/source/libs/wal/src/walMeta.c +++ b/source/libs/wal/src/walMeta.c @@ -58,6 +58,7 @@ static FORCE_INLINE int32_t walScanLogGetLastVer(SWal* pWal, int32_t fileIdx, in int64_t fileSize = 0; if (taosStatFile(fnameStr, &fileSize, NULL, NULL) != 0) { + wError("vgId:%d, failed to stat file due to %s. file:%s", pWal->cfg.vgId, strerror(errno), fnameStr); code = terrno; goto _err; } @@ -370,6 +371,7 @@ static int32_t walTrimIdxFile(SWal* pWal, int32_t fileIdx) { int64_t fileSize = 0; if (taosStatFile(fnameStr, &fileSize, NULL, NULL) != 0) { + wError("vgId:%d, failed to stat file due to %s. file:%s", pWal->cfg.vgId, strerror(errno), fnameStr); code = terrno; TAOS_RETURN(code); } @@ -390,6 +392,7 @@ static int32_t walTrimIdxFile(SWal* pWal, int32_t fileIdx) { code = taosFtruncateFile(pFile, lastEndOffset); if (code < 0) { + wError("vgId:%d, failed to truncate file due to %s. file:%s", pWal->cfg.vgId, strerror(errno), fnameStr); TAOS_RETURN(code); } (void)taosCloseFile(&pFile); @@ -794,33 +797,33 @@ int32_t walMetaSerialize(SWal* pWal, char** serialized) { TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY); } if (cJSON_AddItemToObject(pRoot, "meta", pMeta) != 0) { - wError("vgId:%d, failed to add meta to root", pWal->cfg.vgId); + wInfo("vgId:%d, failed to add meta to root", pWal->cfg.vgId); } (void)sprintf(buf, "%" PRId64, pWal->vers.firstVer); if (cJSON_AddStringToObject(pMeta, "firstVer", buf) == NULL) { - wError("vgId:%d, failed to add firstVer to meta", pWal->cfg.vgId); + wInfo("vgId:%d, failed to add firstVer to meta", pWal->cfg.vgId); } (void)sprintf(buf, "%" PRId64, pWal->vers.snapshotVer); if (cJSON_AddStringToObject(pMeta, "snapshotVer", buf) == NULL) { - wError("vgId:%d, failed to add snapshotVer to meta", pWal->cfg.vgId); + wInfo("vgId:%d, failed to add snapshotVer to meta", pWal->cfg.vgId); } (void)sprintf(buf, "%" PRId64, pWal->vers.commitVer); if (cJSON_AddStringToObject(pMeta, "commitVer", buf) == NULL) { - wError("vgId:%d, failed to add commitVer to meta", pWal->cfg.vgId); + wInfo("vgId:%d, failed to add commitVer to meta", pWal->cfg.vgId); } (void)sprintf(buf, "%" PRId64, pWal->vers.lastVer); if (cJSON_AddStringToObject(pMeta, "lastVer", buf) == NULL) { - wError("vgId:%d, failed to add lastVer to meta", pWal->cfg.vgId); + wInfo("vgId:%d, failed to add lastVer to meta", pWal->cfg.vgId); } if (cJSON_AddItemToObject(pRoot, "files", pFiles) != 0) { - wError("vgId:%d, failed to add files to root", pWal->cfg.vgId); + wInfo("vgId:%d, failed to add files to root", pWal->cfg.vgId); } SWalFileInfo* pData = pWal->fileInfoSet->pData; for (int i = 0; i < sz; i++) { SWalFileInfo* pInfo = &pData[i]; if (cJSON_AddItemToArray(pFiles, pField = cJSON_CreateObject()) != 0) { - wError("vgId:%d, failed to add field to files", pWal->cfg.vgId); + wInfo("vgId:%d, failed to add field to files", pWal->cfg.vgId); } if (pField == NULL) { cJSON_Delete(pRoot); @@ -831,23 +834,23 @@ int32_t walMetaSerialize(SWal* pWal, char** serialized) { // string are used to prohibit the loss of precision (void)sprintf(buf, "%" PRId64, pInfo->firstVer); if (cJSON_AddStringToObject(pField, "firstVer", buf) == NULL) { - wError("vgId:%d, failed to add firstVer to field", pWal->cfg.vgId); + wInfo("vgId:%d, failed to add firstVer to field", pWal->cfg.vgId); } (void)sprintf(buf, "%" PRId64, pInfo->lastVer); if (cJSON_AddStringToObject(pField, "lastVer", buf) == NULL) { - wError("vgId:%d, failed to add lastVer to field", pWal->cfg.vgId); + wInfo("vgId:%d, failed to add lastVer to field", pWal->cfg.vgId); } (void)sprintf(buf, "%" PRId64, pInfo->createTs); if (cJSON_AddStringToObject(pField, "createTs", buf) == NULL) { - wError("vgId:%d, failed to add createTs to field", pWal->cfg.vgId); + wInfo("vgId:%d, failed to add createTs to field", pWal->cfg.vgId); } (void)sprintf(buf, "%" PRId64, pInfo->closeTs); if (cJSON_AddStringToObject(pField, "closeTs", buf) == NULL) { - wError("vgId:%d, failed to add closeTs to field", pWal->cfg.vgId); + wInfo("vgId:%d, failed to add closeTs to field", pWal->cfg.vgId); } (void)sprintf(buf, "%" PRId64, pInfo->fileSize); if (cJSON_AddStringToObject(pField, "fileSize", buf) == NULL) { - wError("vgId:%d, failed to add fileSize to field", pWal->cfg.vgId); + wInfo("vgId:%d, failed to add fileSize to field", pWal->cfg.vgId); } } char* pSerialized = cJSON_Print(pRoot); @@ -1053,6 +1056,7 @@ int32_t walSaveMeta(SWal* pWal) { return code; _err: + wError("vgId:%d, %s failed at line %d since %s", pWal->cfg.vgId, __func__, lino, tstrerror(code)); taosCloseFile(&pMetaFile); taosMemoryFree(serialized); return code; @@ -1076,6 +1080,7 @@ int32_t walLoadMeta(SWal* pWal) { // read metafile int64_t fileSize = 0; if (taosStatFile(fnameStr, &fileSize, NULL, NULL) != 0) { + wError("vgId:%d, failed to stat file due to %s. file:%s", pWal->cfg.vgId, strerror(errno), fnameStr); code = terrno; TAOS_RETURN(code); } diff --git a/source/libs/wal/src/walMgmt.c b/source/libs/wal/src/walMgmt.c index 9370476496..81d31f9ecd 100644 --- a/source/libs/wal/src/walMgmt.c +++ b/source/libs/wal/src/walMgmt.c @@ -161,7 +161,7 @@ SWal *walOpen(const char *path, SWalCfg *pCfg) { // load meta if (walLoadMeta(pWal) < 0) { - wError("vgId:%d, failed to load meta since %s", pWal->cfg.vgId, tstrerror(terrno)); + wInfo("vgId:%d, failed to load meta since %s", pWal->cfg.vgId, tstrerror(terrno)); } if (walCheckAndRepairMeta(pWal) < 0) { diff --git a/source/util/src/tlrucache.c b/source/util/src/tlrucache.c index 3ef7bf16d6..0c60dc542c 100644 --- a/source/util/src/tlrucache.c +++ b/source/util/src/tlrucache.c @@ -541,7 +541,6 @@ static void taosLRUCacheShardEraseUnrefEntries(SLRUCacheShard *shard) { if (e != NULL) { TAOS_LRU_ENTRY_SET_IN_CACHE(e, false); if (!TAOS_LRU_ENTRY_HAS_REFS(e)) { - taosLRUCacheShardLRURemove(shard, e); shard->usage -= e->totalCharge; } } From 4717b99cef681cb548113bfb38e0b667e7d21eb6 Mon Sep 17 00:00:00 2001 From: xiao-77 Date: Fri, 20 Sep 2024 10:33:33 +0800 Subject: [PATCH 05/18] fix ci --- source/dnode/vnode/src/tsdb/tsdbCache.c | 40 +++++++------------------ source/util/src/tlrucache.c | 25 ++-------------- 2 files changed, 12 insertions(+), 53 deletions(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbCache.c b/source/dnode/vnode/src/tsdb/tsdbCache.c index 4be3d92af7..0e9fcf39a8 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCache.c +++ b/source/dnode/vnode/src/tsdb/tsdbCache.c @@ -724,12 +724,8 @@ static int32_t tsdbCacheDropTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid, SLastCol *pLastCol = NULL; code = tsdbCacheDeserialize(values_list[0], values_list_sizes[0], &pLastCol); if (code != TSDB_CODE_SUCCESS) { - tsdbError("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, - tstrerror(code)); - if (pLastCol != NULL) { - taosMemoryFreeClear(pLastCol); - } - goto _exit; + tsdbWarn("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); } if (NULL != pLastCol) { rocksdb_writebatch_delete(wb, keys_list[0], klen); @@ -739,12 +735,8 @@ static int32_t tsdbCacheDropTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid, pLastCol = NULL; code = tsdbCacheDeserialize(values_list[1], values_list_sizes[1], &pLastCol); if (code != TSDB_CODE_SUCCESS) { - tsdbError("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, - tstrerror(code)); - if (pLastCol != NULL) { - taosMemoryFreeClear(pLastCol); - } - goto _exit; + tsdbWarn("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); } if (NULL != pLastCol) { rocksdb_writebatch_delete(wb, keys_list[1], klen); @@ -1292,12 +1284,8 @@ static int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SArray SLastCol *pLastCol = NULL; code = tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol); if (code != TSDB_CODE_SUCCESS) { - tsdbError("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, - tstrerror(code)); - if (pLastCol != NULL) { - taosMemoryFreeClear(pLastCol); - } - goto _exit; + tsdbWarn("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); } /* if (code) { @@ -1781,12 +1769,8 @@ static int32_t tsdbCacheLoadFromRocks(STsdb *pTsdb, tb_uid_t uid, SArray *pLastA code = tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol); if (code != TSDB_CODE_SUCCESS) { - tsdbError("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, - tstrerror(code)); - if (pLastCol != NULL) { - taosMemoryFreeClear(pLastCol); - } - goto _exit; + tsdbWarn("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); } SLastCol *pToFree = pLastCol; SIdxKey *idxKey = &((SIdxKey *)TARRAY_DATA(remainCols))[j]; @@ -2071,12 +2055,8 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE SLastCol *pLastCol = NULL; code = tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol); if (code != TSDB_CODE_SUCCESS) { - tsdbError("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, - tstrerror(code)); - if (pLastCol != NULL) { - taosMemoryFreeClear(pLastCol); - } - goto _exit; + tsdbWarn("vgId:%d, %s deserialize failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, + tstrerror(code)); } SIdxKey *idxKey = taosArrayGet(remainCols, i); SLastKey *pLastKey = &idxKey->key; diff --git a/source/util/src/tlrucache.c b/source/util/src/tlrucache.c index 0c60dc542c..1440ac5236 100644 --- a/source/util/src/tlrucache.c +++ b/source/util/src/tlrucache.c @@ -306,14 +306,6 @@ static void taosLRUCacheShardEvictLRU(SLRUCacheShard *shard, size_t charge, SArr taosLRUCacheShardLRURemove(shard, old); SLRUEntry *e = taosLRUEntryTableRemove(&shard->table, old->keyData, old->keyLength, old->hash); - if (e != NULL) { - TAOS_LRU_ENTRY_SET_IN_CACHE(e, false); - if (!TAOS_LRU_ENTRY_HAS_REFS(e)) { - taosLRUCacheShardLRURemove(shard, e); - - shard->usage -= e->totalCharge; - } - } TAOS_LRU_ENTRY_SET_IN_CACHE(old, false); shard->usage -= old->totalCharge; @@ -538,12 +530,6 @@ static void taosLRUCacheShardEraseUnrefEntries(SLRUCacheShard *shard) { SLRUEntry *old = shard->lru.next; taosLRUCacheShardLRURemove(shard, old); SLRUEntry *e = taosLRUEntryTableRemove(&shard->table, old->keyData, old->keyLength, old->hash); - if (e != NULL) { - TAOS_LRU_ENTRY_SET_IN_CACHE(e, false); - if (!TAOS_LRU_ENTRY_HAS_REFS(e)) { - shard->usage -= e->totalCharge; - } - } TAOS_LRU_ENTRY_SET_IN_CACHE(old, false); shard->usage -= old->totalCharge; @@ -588,14 +574,7 @@ static bool taosLRUCacheShardRelease(SLRUCacheShard *shard, LRUHandle *handle, b lastReference = taosLRUEntryUnref(e); if (lastReference && TAOS_LRU_ENTRY_IN_CACHE(e)) { if (shard->usage > shard->capacity || eraseIfLastRef) { - SLRUEntry *e = taosLRUEntryTableRemove(&shard->table, e->keyData, e->keyLength, e->hash); - if (e != NULL) { - TAOS_LRU_ENTRY_SET_IN_CACHE(e, false); - if (!TAOS_LRU_ENTRY_HAS_REFS(e)) { - taosLRUCacheShardLRURemove(shard, e); - shard->usage -= e->totalCharge; - } - } + SLRUEntry *new = taosLRUEntryTableRemove(&shard->table, e->keyData, e->keyLength, e->hash); TAOS_LRU_ENTRY_SET_IN_CACHE(e, false); } else { taosLRUCacheShardLRUInsert(shard, e); @@ -891,4 +870,4 @@ bool taosLRUCacheIsStrictCapacity(SLRUCache *cache) { (void)taosThreadMutexUnlock(&cache->shardedCache.capacityMutex); return strict; -} +} \ No newline at end of file From 2dcac78f71b9d001d49c51e29976392322fcba9a Mon Sep 17 00:00:00 2001 From: xiao-77 Date: Fri, 20 Sep 2024 11:05:58 +0800 Subject: [PATCH 06/18] fix ci scan --- source/libs/wal/src/walMeta.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/libs/wal/src/walMeta.c b/source/libs/wal/src/walMeta.c index 0fad72d20a..8f756e3bec 100644 --- a/source/libs/wal/src/walMeta.c +++ b/source/libs/wal/src/walMeta.c @@ -1057,7 +1057,7 @@ int32_t walSaveMeta(SWal* pWal) { _err: wError("vgId:%d, %s failed at line %d since %s", pWal->cfg.vgId, __func__, lino, tstrerror(code)); - taosCloseFile(&pMetaFile); + (void)taosCloseFile(&pMetaFile); taosMemoryFree(serialized); return code; } From d79db33bab126a7eec0111aa000d0c8060757fa9 Mon Sep 17 00:00:00 2001 From: dmchen Date: Fri, 20 Sep 2024 04:13:08 +0000 Subject: [PATCH 07/18] fix/TD-31891-remove-void-sync1 --- source/libs/sync/src/syncCommit.c | 4 +- source/libs/sync/src/syncMain.c | 281 +++++++++++++++++-------- source/libs/sync/src/syncRaftCfg.c | 2 +- source/libs/sync/src/syncRaftStore.c | 22 +- source/libs/sync/src/syncRequestVote.c | 2 +- 5 files changed, 214 insertions(+), 97 deletions(-) diff --git a/source/libs/sync/src/syncCommit.c b/source/libs/sync/src/syncCommit.c index 5054339e8e..409277e2da 100644 --- a/source/libs/sync/src/syncCommit.c +++ b/source/libs/sync/src/syncCommit.c @@ -86,7 +86,9 @@ int64_t syncNodeCheckCommitIndex(SSyncNode* ths, SyncIndex indexLikely) { if (indexLikely > ths->commitIndex && syncNodeAgreedUpon(ths, indexLikely)) { SyncIndex commitIndex = indexLikely; // TODO add return when error - (void)syncNodeUpdateCommitIndex(ths, commitIndex); + if ((code = syncNodeUpdateCommitIndex(ths, commitIndex)) != 0) { + sError("vgId:%d, failed to update commit index:%" PRId64 ", since %s", ths->vgId, commitIndex, tstrerror(code)); + } sTrace("vgId:%d, agreed upon. role:%d, term:%" PRId64 ", index:%" PRId64 "", ths->vgId, ths->state, raftStoreGetTerm(ths), commitIndex); } diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 4dce54fc1a..71234e589f 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -201,13 +201,13 @@ int32_t syncReconfig(int64_t rid, SSyncCfg* pNewCfg) { if (pSyncNode->state == TAOS_SYNC_STATE_LEADER || pSyncNode->state == TAOS_SYNC_STATE_ASSIGNED_LEADER) { // TODO check return value - (void)syncNodeStopHeartbeatTimer(pSyncNode); + TAOS_CHECK_RETURN(syncNodeStopHeartbeatTimer(pSyncNode)); for (int32_t i = 0; i < TSDB_MAX_REPLICA + TSDB_MAX_LEARNER_REPLICA; ++i) { - (void)syncHbTimerInit(pSyncNode, &pSyncNode->peerHeartbeatTimerArr[i], pSyncNode->replicasId[i]); + TAOS_CHECK_RETURN(syncHbTimerInit(pSyncNode, &pSyncNode->peerHeartbeatTimerArr[i], pSyncNode->replicasId[i])); } - (void)syncNodeStartHeartbeatTimer(pSyncNode); + TAOS_CHECK_RETURN(syncNodeStartHeartbeatTimer(pSyncNode)); // syncNodeReplicate(pSyncNode); } @@ -410,9 +410,8 @@ int32_t syncSendTimeoutRsp(int64_t rid, int64_t seq) { syncNodeRelease(pNode); if (ret == 1) { sInfo("send timeout response, seq:%" PRId64 " handle:%p ahandle:%p", seq, rpcMsg.info.handle, rpcMsg.info.ahandle); - // TODO check return value - (void)rpcSendResponse(&rpcMsg); - return 0; + code = rpcSendResponse(&rpcMsg); + return code; } else { sError("no message handle to send timeout response, seq:%" PRId64, seq); return TSDB_CODE_SYN_INTERNAL_ERROR; @@ -933,7 +932,7 @@ int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak, int64_ int32_t code = syncBuildClientRequest(&rpcMsg, pMsg, seqNum, isWeak, pSyncNode->vgId); if (code != 0) { sError("vgId:%d, failed to propose msg while serialize since %s", pSyncNode->vgId, terrstr()); - (void)syncRespMgrDel(pSyncNode->pSyncRespMgr, seqNum); + code = syncRespMgrDel(pSyncNode->pSyncRespMgr, seqNum); TAOS_RETURN(code); } @@ -941,7 +940,7 @@ int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak, int64_ code = (*pSyncNode->syncEqMsg)(pSyncNode->msgcb, &rpcMsg); if (code != 0) { sWarn("vgId:%d, failed to propose msg while enqueue since %s", pSyncNode->vgId, terrstr()); - (void)syncRespMgrDel(pSyncNode->pSyncRespMgr, seqNum); + TAOS_CHECK_RETURN(syncRespMgrDel(pSyncNode->pSyncRespMgr, seqNum)); } if (seq != NULL) *seq = seqNum; @@ -961,7 +960,7 @@ static int32_t syncHbTimerInit(SSyncNode* pSyncNode, SSyncTimer* pSyncTimer, SRa } static int32_t syncHbTimerStart(SSyncNode* pSyncNode, SSyncTimer* pSyncTimer) { - int32_t ret = 0; + int32_t code = 0; int64_t tsNow = taosGetTimestampMs(); if (syncIsInit()) { SSyncHbTimerData* pData = syncHbTimerDataAcquire(pSyncTimer->hbDataRid); @@ -980,13 +979,13 @@ static int32_t syncHbTimerStart(SSyncNode* pSyncNode, SSyncTimer* pSyncTimer) { sTrace("vgId:%d, start hb timer, rid:%" PRId64 " addr:%" PRId64, pSyncNode->vgId, pData->rid, pData->destId.addr); - (void)taosTmrReset(pSyncTimer->timerCb, pSyncTimer->timerMS / HEARTBEAT_TICK_NUM, (void*)(pData->rid), - syncEnv()->pTimerManager, &pSyncTimer->pTimer); + TAOS_CHECK_RETURN(taosTmrReset(pSyncTimer->timerCb, pSyncTimer->timerMS / HEARTBEAT_TICK_NUM, (void*)(pData->rid), + syncEnv()->pTimerManager, &pSyncTimer->pTimer)); } else { - ret = TSDB_CODE_SYN_INTERNAL_ERROR; + code = TSDB_CODE_SYN_INTERNAL_ERROR; sError("vgId:%d, start ctrl hb timer error, sync env is stop", pSyncNode->vgId); } - return ret; + return code; } static int32_t syncHbTimerStop(SSyncNode* pSyncNode, SSyncTimer* pSyncTimer) { @@ -1308,7 +1307,10 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo, int32_t vnodeVersion) { } // tools - (void)syncRespMgrCreate(pSyncNode, SYNC_RESP_TTL_MS, &pSyncNode->pSyncRespMgr); // TODO: check return value + if ((code = syncRespMgrCreate(pSyncNode, SYNC_RESP_TTL_MS, &pSyncNode->pSyncRespMgr)) != 0) { + sError("vgId:%d, failed to create SyncRespMgr", pSyncNode->vgId); + goto _error; + } if (pSyncNode->pSyncRespMgr == NULL) { sError("vgId:%d, failed to create SyncRespMgr", pSyncNode->vgId); goto _error; @@ -1471,29 +1473,31 @@ int32_t syncNodeStart(SSyncNode* pSyncNode) { #ifdef BUILD_NO_CALL int32_t syncNodeStartStandBy(SSyncNode* pSyncNode) { // state change + int32_t code = 0; pSyncNode->state = TAOS_SYNC_STATE_FOLLOWER; pSyncNode->roleTimeMs = taosGetTimestampMs(); // TODO check return value - (void)syncNodeStopHeartbeatTimer(pSyncNode); + TAOS_CHECK_RETURN(syncNodeStopHeartbeatTimer(pSyncNode)); // reset elect timer, long enough int32_t electMS = TIMER_MAX_MS; - int32_t ret = syncNodeRestartElectTimer(pSyncNode, electMS); - if (ret < 0) { + code = syncNodeRestartElectTimer(pSyncNode, electMS); + if (code < 0) { sError("vgId:%d, failed to restart elect timer since %s", pSyncNode->vgId, terrstr()); return -1; } - ret = syncNodeStartPingTimer(pSyncNode); - if (ret < 0) { + code = syncNodeStartPingTimer(pSyncNode); + if (code < 0) { sError("vgId:%d, failed to start ping timer since %s", pSyncNode->vgId, terrstr()); return -1; } - return ret; + return code; } #endif void syncNodePreClose(SSyncNode* pSyncNode) { + int32_t code = 0; if (pSyncNode == NULL) { sError("failed to pre close sync node since sync node is null"); return; @@ -1508,13 +1512,22 @@ void syncNodePreClose(SSyncNode* pSyncNode) { } // stop elect timer - (void)syncNodeStopElectTimer(pSyncNode); + if ((code = syncNodeStopElectTimer(pSyncNode)) != 0) { + sError("vgId:%d, failed to stop elect timer since %s", pSyncNode->vgId, tstrerror(code)); + return; + } // stop heartbeat timer - (void)syncNodeStopHeartbeatTimer(pSyncNode); + if ((code = syncNodeStopHeartbeatTimer(pSyncNode)) != 0) { + sError("vgId:%d, failed to stop heartbeat timer since %s", pSyncNode->vgId, tstrerror(code)); + return; + } // stop ping timer - (void)syncNodeStopPingTimer(pSyncNode); + if ((code = syncNodeStopPingTimer(pSyncNode)) != 0) { + sError("vgId:%d, failed to stop ping timer since %s", pSyncNode->vgId, tstrerror(code)); + return; + } // clean rsp syncRespCleanRsp(pSyncNode->pSyncRespMgr); @@ -1536,14 +1549,24 @@ void syncNodePostClose(SSyncNode* pSyncNode) { void syncHbTimerDataFree(SSyncHbTimerData* pData) { taosMemoryFree(pData); } void syncNodeClose(SSyncNode* pSyncNode) { + int32_t code = 0; if (pSyncNode == NULL) return; sNInfo(pSyncNode, "sync close, node:%p", pSyncNode); syncRespCleanRsp(pSyncNode->pSyncRespMgr); - (void)syncNodeStopPingTimer(pSyncNode); - (void)syncNodeStopElectTimer(pSyncNode); - (void)syncNodeStopHeartbeatTimer(pSyncNode); + if ((code = syncNodeStopPingTimer(pSyncNode)) != 0) { + sError("vgId:%d, failed to stop ping timer since %s", pSyncNode->vgId, tstrerror(code)); + return; + } + if ((code = syncNodeStopElectTimer(pSyncNode)) != 0) { + sError("vgId:%d, failed to stop elect timer since %s", pSyncNode->vgId, tstrerror(code)); + return; + } + if ((code = syncNodeStopHeartbeatTimer(pSyncNode)) != 0) { + sError("vgId:%d, failed to stop heartbeat timer since %s", pSyncNode->vgId, tstrerror(code)); + return; + } syncNodeLogReplDestroy(pSyncNode); syncRespMgrDestroy(pSyncNode->pSyncRespMgr); @@ -1599,28 +1622,28 @@ ESyncStrategy syncNodeStrategy(SSyncNode* pSyncNode) { return pSyncNode->raftCfg // timer control -------------- int32_t syncNodeStartPingTimer(SSyncNode* pSyncNode) { - int32_t ret = 0; + int32_t code = 0; if (syncIsInit()) { - (void)taosTmrReset(pSyncNode->FpPingTimerCB, pSyncNode->pingTimerMS, (void*)pSyncNode->rid, - syncEnv()->pTimerManager, &pSyncNode->pPingTimer); + TAOS_CHECK_RETURN(taosTmrReset(pSyncNode->FpPingTimerCB, pSyncNode->pingTimerMS, (void*)pSyncNode->rid, + syncEnv()->pTimerManager, &pSyncNode->pPingTimer)); atomic_store_64(&pSyncNode->pingTimerLogicClock, pSyncNode->pingTimerLogicClockUser); } else { sError("vgId:%d, start ping timer error, sync env is stop", pSyncNode->vgId); } - return ret; + return code; } int32_t syncNodeStopPingTimer(SSyncNode* pSyncNode) { - int32_t ret = 0; + int32_t code = 0; (void)atomic_add_fetch_64(&pSyncNode->pingTimerLogicClockUser, 1); // TODO check return value - (void)taosTmrStop(pSyncNode->pPingTimer); + TAOS_CHECK_RETURN(taosTmrStop(pSyncNode->pPingTimer)); pSyncNode->pPingTimer = NULL; - return ret; + return code; } int32_t syncNodeStartElectTimer(SSyncNode* pSyncNode, int32_t ms) { - int32_t ret = 0; + int32_t code = 0; if (syncIsInit()) { pSyncNode->electTimerMS = ms; @@ -1630,22 +1653,22 @@ int32_t syncNodeStartElectTimer(SSyncNode* pSyncNode, int32_t ms) { pSyncNode->electTimerParam.pSyncNode = pSyncNode; pSyncNode->electTimerParam.pData = NULL; - (void)taosTmrReset(pSyncNode->FpElectTimerCB, pSyncNode->electTimerMS, (void*)(pSyncNode->rid), - syncEnv()->pTimerManager, &pSyncNode->pElectTimer); + TAOS_CHECK_RETURN(taosTmrReset(pSyncNode->FpElectTimerCB, pSyncNode->electTimerMS, (void*)(pSyncNode->rid), + syncEnv()->pTimerManager, &pSyncNode->pElectTimer)); } else { sError("vgId:%d, start elect timer error, sync env is stop", pSyncNode->vgId); } - return ret; + return code; } int32_t syncNodeStopElectTimer(SSyncNode* pSyncNode) { - int32_t ret = 0; + int32_t code = 0; (void)atomic_add_fetch_64(&pSyncNode->electTimerLogicClock, 1); // TODO check return value - (void)taosTmrStop(pSyncNode->pElectTimer); + TAOS_CHECK_RETURN(taosTmrStop(pSyncNode->pElectTimer)); pSyncNode->pElectTimer = NULL; - return ret; + return code; } int32_t syncNodeRestartElectTimer(SSyncNode* pSyncNode, int32_t ms) { @@ -1666,7 +1689,10 @@ void syncNodeResetElectTimer(SSyncNode* pSyncNode) { } // TODO check return value - (void)syncNodeRestartElectTimer(pSyncNode, electMS); + if ((code = syncNodeRestartElectTimer(pSyncNode, electMS)) != 0) { + sError("vgId:%d, failed to restart elect timer since %s", pSyncNode->vgId, terrstr()); + return; + }; sNTrace(pSyncNode, "reset elect timer, min:%d, max:%d, ms:%d", pSyncNode->electBaseLine, 2 * pSyncNode->electBaseLine, electMS); @@ -1674,17 +1700,17 @@ void syncNodeResetElectTimer(SSyncNode* pSyncNode) { #ifdef BUILD_NO_CALL static int32_t syncNodeDoStartHeartbeatTimer(SSyncNode* pSyncNode) { - int32_t ret = 0; + int32_t code = 0; if (syncIsInit()) { - (void)taosTmrReset(pSyncNode->FpHeartbeatTimerCB, pSyncNode->heartbeatTimerMS, (void*)pSyncNode->rid, - syncEnv()->pTimerManager, &pSyncNode->pHeartbeatTimer); + TAOS_CHECK_RETURN(taosTmrReset(pSyncNode->FpHeartbeatTimerCB, pSyncNode->heartbeatTimerMS, (void*)pSyncNode->rid, + syncEnv()->pTimerManager, &pSyncNode->pHeartbeatTimer)); atomic_store_64(&pSyncNode->heartbeatTimerLogicClock, pSyncNode->heartbeatTimerLogicClockUser); } else { sError("vgId:%d, start heartbeat timer error, sync env is stop", pSyncNode->vgId); } sNTrace(pSyncNode, "start heartbeat timer, ms:%d", pSyncNode->heartbeatTimerMS); - return ret; + return code; } #endif @@ -1707,12 +1733,12 @@ int32_t syncNodeStartHeartbeatTimer(SSyncNode* pSyncNode) { } int32_t syncNodeStopHeartbeatTimer(SSyncNode* pSyncNode) { - int32_t ret = 0; + int32_t code = 0; #if 0 //TODO check return value - (void)atomic_add_fetch_64(&pSyncNode->heartbeatTimerLogicClockUser, 1); - (void)taosTmrStop(pSyncNode->pHeartbeatTimer); + TAOS_CHECK_RETURN(atomic_add_fetch_64(&pSyncNode->heartbeatTimerLogicClockUser, 1)); + TAOS_CHECK_RETURN(taosTmrStop(pSyncNode->pHeartbeatTimer)); pSyncNode->pHeartbeatTimer = NULL; #endif @@ -1723,14 +1749,15 @@ int32_t syncNodeStopHeartbeatTimer(SSyncNode* pSyncNode) { } } - return ret; + return code; } #ifdef BUILD_NO_CALL int32_t syncNodeRestartHeartbeatTimer(SSyncNode* pSyncNode) { // TODO check return value - (void)syncNodeStopHeartbeatTimer(pSyncNode); - (void)syncNodeStartHeartbeatTimer(pSyncNode); + int32_t code = 0; + TAOS_CHECK_RETURN(syncNodeStopHeartbeatTimer(pSyncNode)); + TAOS_CHECK_RETURN(syncNodeStartHeartbeatTimer(pSyncNode)); return 0; } #endif @@ -1806,6 +1833,7 @@ static bool syncIsConfigChanged(const SSyncCfg* pOldCfg, const SSyncCfg* pNewCfg } int32_t syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncIndex lastConfigChangeIndex) { + int32_t code = 0; SSyncCfg oldConfig = pSyncNode->raftCfg.cfg; if (!syncIsConfigChanged(&oldConfig, pNewConfig)) { sInfo("vgId:1, sync not reconfig since not changed"); @@ -1873,7 +1901,7 @@ int32_t syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncI // init internal pSyncNode->myNodeInfo = pSyncNode->raftCfg.cfg.nodeInfo[pSyncNode->raftCfg.cfg.myIndex]; - (void)syncUtilNodeInfo2RaftId(&pSyncNode->myNodeInfo, pSyncNode->vgId, &pSyncNode->myRaftId); + TAOS_CHECK_RETURN(syncUtilNodeInfo2RaftId(&pSyncNode->myNodeInfo, pSyncNode->vgId, &pSyncNode->myRaftId)); // init peersNum, peers, peersId pSyncNode->peersNum = pSyncNode->raftCfg.cfg.totalReplicaNum - 1; @@ -1886,14 +1914,15 @@ int32_t syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncI } } for (int32_t i = 0; i < pSyncNode->peersNum; ++i) { - (void)syncUtilNodeInfo2RaftId(&pSyncNode->peersNodeInfo[i], pSyncNode->vgId, &pSyncNode->peersId[i]); + TAOS_CHECK_RETURN(syncUtilNodeInfo2RaftId(&pSyncNode->peersNodeInfo[i], pSyncNode->vgId, &pSyncNode->peersId[i])); } // init replicaNum, replicasId pSyncNode->replicaNum = pSyncNode->raftCfg.cfg.replicaNum; pSyncNode->totalReplicaNum = pSyncNode->raftCfg.cfg.totalReplicaNum; for (int32_t i = 0; i < pSyncNode->raftCfg.cfg.totalReplicaNum; ++i) { - (void)syncUtilNodeInfo2RaftId(&pSyncNode->raftCfg.cfg.nodeInfo[i], pSyncNode->vgId, &pSyncNode->replicasId[i]); + TAOS_CHECK_RETURN( + syncUtilNodeInfo2RaftId(&pSyncNode->raftCfg.cfg.nodeInfo[i], pSyncNode->vgId, &pSyncNode->replicasId[i])); } // update quorum first @@ -1939,7 +1968,7 @@ int32_t syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncI // create new for (int32_t i = 0; i < TSDB_MAX_REPLICA + TSDB_MAX_LEARNER_REPLICA; ++i) { if (pSyncNode->senders[i] == NULL) { - (void)snapshotSenderCreate(pSyncNode, i, &pSyncNode->senders[i]); + TAOS_CHECK_RETURN(snapshotSenderCreate(pSyncNode, i, &pSyncNode->senders[i])); if (pSyncNode->senders[i] == NULL) { // will be created later while send snapshot sSError(pSyncNode->senders[i], "snapshot sender create failed while reconfig"); @@ -1961,10 +1990,10 @@ int32_t syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncI } // persist cfg - (void)syncWriteCfgFile(pSyncNode); + TAOS_CHECK_RETURN(syncWriteCfgFile(pSyncNode)); } else { // persist cfg - (void)syncWriteCfgFile(pSyncNode); + TAOS_CHECK_RETURN(syncWriteCfgFile(pSyncNode)); sNInfo(pSyncNode, "do not config change from %d to %d", oldConfig.totalReplicaNum, pNewConfig->totalReplicaNum); } @@ -2015,7 +2044,7 @@ void syncNodeStepDown(SSyncNode* pSyncNode, SyncTerm newTerm) { void syncNodeLeaderChangeRsp(SSyncNode* pSyncNode) { syncRespCleanRsp(pSyncNode->pSyncRespMgr); } void syncNodeBecomeFollower(SSyncNode* pSyncNode, const char* debugStr) { - // maybe clear leader cache + int32_t code = 0; // maybe clear leader cache if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) { pSyncNode->leaderCache = EMPTY_RAFT_ID; } @@ -2025,7 +2054,10 @@ void syncNodeBecomeFollower(SSyncNode* pSyncNode, const char* debugStr) { // state change pSyncNode->state = TAOS_SYNC_STATE_FOLLOWER; pSyncNode->roleTimeMs = taosGetTimestampMs(); - (void)syncNodeStopHeartbeatTimer(pSyncNode); + if ((code = syncNodeStopHeartbeatTimer(pSyncNode)) != 0) { + sError("vgId:%d, failed to stop heartbeat timer since %s", pSyncNode->vgId, tstrerror(code)); + return; + } // trace log sNTrace(pSyncNode, "become follower %s", debugStr); @@ -2042,7 +2074,10 @@ void syncNodeBecomeFollower(SSyncNode* pSyncNode, const char* debugStr) { pSyncNode->minMatchIndex = SYNC_INDEX_INVALID; // reset log buffer - (void)syncLogBufferReset(pSyncNode->pLogBuf, pSyncNode); + if ((code = syncLogBufferReset(pSyncNode->pLogBuf, pSyncNode)) != 0) { + sError("vgId:%d, failed to reset log buffer since %s", pSyncNode->vgId, tstrerror(code)); + return; + } // reset elect timer syncNodeResetElectTimer(pSyncNode); @@ -2069,7 +2104,11 @@ void syncNodeBecomeLearner(SSyncNode* pSyncNode, const char* debugStr) { pSyncNode->minMatchIndex = SYNC_INDEX_INVALID; // reset log buffer - (void)syncLogBufferReset(pSyncNode->pLogBuf, pSyncNode); + int32_t code = 0; + if ((code = syncLogBufferReset(pSyncNode->pLogBuf, pSyncNode)) != 0) { + sError("vgId:%d, failed to reset log buffer since %s", pSyncNode->vgId, tstrerror(code)); + return; + }; } // TLA+ Spec @@ -2091,6 +2130,7 @@ void syncNodeBecomeLearner(SSyncNode* pSyncNode, const char* debugStr) { // /\ UNCHANGED <> // void syncNodeBecomeLeader(SSyncNode* pSyncNode, const char* debugStr) { + int32_t code = 0; pSyncNode->becomeLeaderNum++; pSyncNode->hbrSlowNum = 0; @@ -2122,7 +2162,10 @@ void syncNodeBecomeLeader(SSyncNode* pSyncNode, const char* debugStr) { } // init peer mgr - (void)syncNodePeerStateInit(pSyncNode); + if ((code = syncNodePeerStateInit(pSyncNode)) != 0) { + sError("vgId:%d, failed to init peer state since %s", pSyncNode->vgId, tstrerror(code)); + return; + } #if 0 // update sender private term @@ -2143,13 +2186,22 @@ void syncNodeBecomeLeader(SSyncNode* pSyncNode, const char* debugStr) { } // stop elect timer - (void)syncNodeStopElectTimer(pSyncNode); + if ((code = syncNodeStopElectTimer(pSyncNode)) != 0) { + sError("vgId:%d, failed to stop elect timer since %s", pSyncNode->vgId, tstrerror(code)); + return; + } // start heartbeat timer - (void)syncNodeStartHeartbeatTimer(pSyncNode); + if ((code = syncNodeStartHeartbeatTimer(pSyncNode)) != 0) { + sError("vgId:%d, failed to start heartbeat timer since %s", pSyncNode->vgId, tstrerror(code)); + return; + } // send heartbeat right now - (void)syncNodeHeartbeatPeers(pSyncNode); + if ((code = syncNodeHeartbeatPeers(pSyncNode)) != 0) { + sError("vgId:%d, failed to send heartbeat to peers since %s", pSyncNode->vgId, tstrerror(code)); + return; + } // call back if (pSyncNode->pFsm != NULL && pSyncNode->pFsm->FpBecomeLeaderCb != NULL) { @@ -2160,13 +2212,17 @@ void syncNodeBecomeLeader(SSyncNode* pSyncNode, const char* debugStr) { pSyncNode->minMatchIndex = SYNC_INDEX_INVALID; // reset log buffer - (void)syncLogBufferReset(pSyncNode->pLogBuf, pSyncNode); + if ((code = syncLogBufferReset(pSyncNode->pLogBuf, pSyncNode)) != 0) { + sError("vgId:%d, failed to reset log buffer since %s", pSyncNode->vgId, tstrerror(code)); + return; + } // trace log sNInfo(pSyncNode, "become leader %s", debugStr); } void syncNodeBecomeAssignedLeader(SSyncNode* pSyncNode) { + int32_t code = 0; pSyncNode->becomeAssignedLeaderNum++; pSyncNode->hbrSlowNum = 0; @@ -2198,7 +2254,10 @@ void syncNodeBecomeAssignedLeader(SSyncNode* pSyncNode) { } // init peer mgr - (void)syncNodePeerStateInit(pSyncNode); + if ((code = syncNodePeerStateInit(pSyncNode)) != 0) { + sError("vgId:%d, failed to init peer state since %s", pSyncNode->vgId, tstrerror(code)); + return; + } // close receiver if (snapshotReceiverIsStart(pSyncNode->pNewNodeReceiver)) { @@ -2206,13 +2265,22 @@ void syncNodeBecomeAssignedLeader(SSyncNode* pSyncNode) { } // stop elect timer - (void)syncNodeStopElectTimer(pSyncNode); + if ((code = syncNodeStopElectTimer(pSyncNode)) != 0) { + sError("vgId:%d, failed to stop elect timer since %s", pSyncNode->vgId, tstrerror(code)); + return; + } // start heartbeat timer - (void)syncNodeStartHeartbeatTimer(pSyncNode); + if ((code = syncNodeStartHeartbeatTimer(pSyncNode)) != 0) { + sError("vgId:%d, failed to start heartbeat timer since %s", pSyncNode->vgId, tstrerror(code)); + return; + } // send heartbeat right now - (void)syncNodeHeartbeatPeers(pSyncNode); + if ((code = syncNodeHeartbeatPeers(pSyncNode)) != 0) { + sError("vgId:%d, failed to send heartbeat to peers since %s", pSyncNode->vgId, tstrerror(code)); + return; + } // call back if (pSyncNode->pFsm != NULL && pSyncNode->pFsm->FpBecomeAssignedLeaderCb != NULL) { @@ -2223,7 +2291,10 @@ void syncNodeBecomeAssignedLeader(SSyncNode* pSyncNode) { pSyncNode->minMatchIndex = SYNC_INDEX_INVALID; // reset log buffer - (void)syncLogBufferReset(pSyncNode->pLogBuf, pSyncNode); + if ((code = syncLogBufferReset(pSyncNode->pLogBuf, pSyncNode)) != 0) { + sError("vgId:%d, failed to reset log buffer since %s", pSyncNode->vgId, tstrerror(code)); + return; + } // trace log sNInfo(pSyncNode, "become assigned leader"); @@ -2513,8 +2584,10 @@ static void syncNodeEqPingTimer(void* param, void* tmrId) { } _out: - (void)taosTmrReset(syncNodeEqPingTimer, pNode->pingTimerMS, (void*)pNode->rid, syncEnv()->pTimerManager, - &pNode->pPingTimer); + if ((code = taosTmrReset(syncNodeEqPingTimer, pNode->pingTimerMS, (void*)pNode->rid, syncEnv()->pTimerManager, + &pNode->pPingTimer)) != 0) { + sError("failed to reset ping timer since %s", tstrerror(code)); + }; } syncNodeRelease(pNode); } @@ -2591,8 +2664,9 @@ static void syncNodeEqHeartbeatTimer(void* param, void* tmrId) { } _out: - (void)taosTmrReset(syncNodeEqHeartbeatTimer, pNode->heartbeatTimerMS, (void*)pNode->rid, syncEnv()->pTimerManager, - &pNode->pHeartbeatTimer); + if (taosTmrReset(syncNodeEqHeartbeatTimer, pNode->heartbeatTimerMS, (void*)pNode->rid, syncEnv()->pTimerManager, + &pNode->pHeartbeatTimer) != 0) + return; } else { sTrace("==syncNodeEqHeartbeatTimer== heartbeatTimerLogicClock:%" PRId64 ", heartbeatTimerLogicClockUser:%" PRId64, @@ -2603,6 +2677,7 @@ static void syncNodeEqHeartbeatTimer(void* param, void* tmrId) { #endif static void syncNodeEqPeerHeartbeatTimer(void* param, void* tmrId) { + int32_t code = 0; int64_t hbDataRid = (int64_t)param; int64_t tsNow = taosGetTimestampMs(); @@ -2646,7 +2721,12 @@ static void syncNodeEqPeerHeartbeatTimer(void* param, void* tmrId) { pData->execTime += pSyncTimer->timerMS; SRpcMsg rpcMsg = {0}; - (void)syncBuildHeartbeat(&rpcMsg, pSyncNode->vgId); + if ((code = syncBuildHeartbeat(&rpcMsg, pSyncNode->vgId)) != 0) { + sError("vgId:%d, failed to build heartbeat msg since %s", pSyncNode->vgId, tstrerror(code)); + syncNodeRelease(pSyncNode); + syncHbTimerDataRelease(pData); + return; + } pSyncNode->minMatchIndex = syncMinMatchIndex(pSyncNode); @@ -2668,14 +2748,25 @@ static void syncNodeEqPeerHeartbeatTimer(void* param, void* tmrId) { STraceId* trace = &(rpcMsg.info.traceId); sGTrace("vgId:%d, send sync-heartbeat to dnode:%d", pSyncNode->vgId, DID(&(pSyncMsg->destId))); syncLogSendHeartbeat(pSyncNode, pSyncMsg, false, timerElapsed, pData->execTime); - (void)syncNodeSendHeartbeat(pSyncNode, &pSyncMsg->destId, &rpcMsg); + if ((code = syncNodeSendHeartbeat(pSyncNode, &pSyncMsg->destId, &rpcMsg)) != 0) { + sError("vgId:%d, failed to send heartbeat to dnode:%d since %s", pSyncNode->vgId, DID(&(pSyncMsg->destId)), + tstrerror(code)); + syncNodeRelease(pSyncNode); + syncHbTimerDataRelease(pData); + return; + } } else { } if (syncIsInit()) { // sTrace("vgId:%d, reset peer hb timer", pSyncNode->vgId); - (void)taosTmrReset(syncNodeEqPeerHeartbeatTimer, pSyncTimer->timerMS / HEARTBEAT_TICK_NUM, (void*)hbDataRid, - syncEnv()->pTimerManager, &pSyncTimer->pTimer); + if ((code = taosTmrReset(syncNodeEqPeerHeartbeatTimer, pSyncTimer->timerMS / HEARTBEAT_TICK_NUM, + (void*)hbDataRid, syncEnv()->pTimerManager, &pSyncTimer->pTimer)) != 0) { + sError("vgId:%d, reset peer hb timer error, %s", pSyncNode->vgId, tstrerror(code)); + syncNodeRelease(pSyncNode); + syncHbTimerDataRelease(pData); + return; + } } else { sError("sync env is stop, reset peer hb timer error"); } @@ -2715,6 +2806,7 @@ int32_t syncCacheEntry(SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry, LRUHand void syncBuildConfigFromReq(SAlterVnodeReplicaReq* pReq, SSyncCfg* cfg) { // TODO SAlterVnodeReplicaReq name is proper? cfg->replicaNum = 0; cfg->totalReplicaNum = 0; + int32_t code = 0; for (int i = 0; i < pReq->replica; ++i) { SNodeInfo* pNode = &cfg->nodeInfo[i]; @@ -2722,7 +2814,9 @@ void syncBuildConfigFromReq(SAlterVnodeReplicaReq* pReq, SSyncCfg* cfg) { // TO pNode->nodePort = pReq->replicas[i].port; tstrncpy(pNode->nodeFqdn, pReq->replicas[i].fqdn, sizeof(pNode->nodeFqdn)); pNode->nodeRole = TAOS_SYNC_ROLE_VOTER; - (void)tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort); + if ((code = tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort)) != 0) { + sError("vgId:%d, failed to update dnode info since %s", pReq->vgId, tstrerror(code)); + } sInfo("vgId:%d, replica:%d ep:%s:%u dnode:%d nodeRole:%d", pReq->vgId, i, pNode->nodeFqdn, pNode->nodePort, pNode->nodeId, pNode->nodeRole); cfg->replicaNum++; @@ -2736,7 +2830,9 @@ void syncBuildConfigFromReq(SAlterVnodeReplicaReq* pReq, SSyncCfg* cfg) { // TO pNode->nodePort = pReq->learnerReplicas[cfg->totalReplicaNum].port; pNode->nodeRole = TAOS_SYNC_ROLE_LEARNER; tstrncpy(pNode->nodeFqdn, pReq->learnerReplicas[cfg->totalReplicaNum].fqdn, sizeof(pNode->nodeFqdn)); - (void)tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort); + if ((code = tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort)) != 0) { + sError("vgId:%d, failed to update dnode info, %s", pReq->vgId, tstrerror(code)); + } sInfo("vgId:%d, replica:%d ep:%s:%u dnode:%d nodeRole:%d", pReq->vgId, i, pNode->nodeFqdn, pNode->nodePort, pNode->nodeId, pNode->nodeRole); cfg->totalReplicaNum++; @@ -3287,7 +3383,10 @@ int32_t syncNodeAppend(SSyncNode* ths, SSyncRaftEntry* pEntry) { // append to log buffer if ((code = syncLogBufferAppend(ths->pLogBuf, ths, pEntry)) < 0) { sError("vgId:%d, failed to enqueue sync log buffer, index:%" PRId64, ths->vgId, pEntry->index); - (void)syncFsmExecute(ths, ths->pFsm, ths->state, raftStoreGetTerm(ths), pEntry, terrno, false); + int32_t ret = 0; + if ((ret = syncFsmExecute(ths, ths->pFsm, ths->state, raftStoreGetTerm(ths), pEntry, terrno, false)) != 0) { + sError("vgId:%d, failed to execute fsm, since %s", ths->vgId, tstrerror(ret)); + } syncEntryDestroy(pEntry); pEntry = NULL; goto _out; @@ -3305,7 +3404,7 @@ _out:; ths->pLogBuf->matchIndex, ths->pLogBuf->endIndex); if (code == 0 && ths->state == TAOS_SYNC_STATE_ASSIGNED_LEADER) { - (void)syncNodeUpdateAssignedCommitIndex(ths, matchIndex); + TAOS_CHECK_RETURN(syncNodeUpdateAssignedCommitIndex(ths, matchIndex)); if (ths->fsmState != SYNC_FSM_STATE_INCOMPLETE && syncLogBufferCommit(ths->pLogBuf, ths, ths->assignedCommitIndex) < 0) { @@ -3320,7 +3419,7 @@ _out:; } // single replica - (void)syncNodeUpdateCommitIndex(ths, matchIndex); + TAOS_CHECK_RETURN(syncNodeUpdateCommitIndex(ths, matchIndex)); if (ths->fsmState != SYNC_FSM_STATE_INCOMPLETE && (code = syncLogBufferCommit(ths->pLogBuf, ths, ths->commitIndex)) < 0) { @@ -3442,7 +3541,7 @@ int32_t syncNodeOnHeartbeat(SSyncNode* ths, const SRpcMsg* pRpcMsg) { } SRpcMsg rpcMsg = {0}; - (void)syncBuildHeartbeatReply(&rpcMsg, ths->vgId); + TAOS_CHECK_RETURN(syncBuildHeartbeatReply(&rpcMsg, ths->vgId)); SyncTerm currentTerm = raftStoreGetTerm(ths); SyncHeartbeatReply* pMsgReply = rpcMsg.pCont; @@ -3470,7 +3569,7 @@ int32_t syncNodeOnHeartbeat(SSyncNode* ths, const SRpcMsg* pRpcMsg) { if (ths->state == TAOS_SYNC_STATE_FOLLOWER || ths->state == TAOS_SYNC_STATE_LEARNER) { SRpcMsg rpcMsgLocalCmd = {0}; - (void)syncBuildLocalCmd(&rpcMsgLocalCmd, ths->vgId); + TAOS_CHECK_RETURN(syncBuildLocalCmd(&rpcMsgLocalCmd, ths->vgId)); SyncLocalCmd* pSyncMsg = rpcMsgLocalCmd.pCont; pSyncMsg->cmd = @@ -3494,7 +3593,7 @@ int32_t syncNodeOnHeartbeat(SSyncNode* ths, const SRpcMsg* pRpcMsg) { if (pMsg->term >= currentTerm && (ths->state == TAOS_SYNC_STATE_LEADER || ths->state == TAOS_SYNC_STATE_ASSIGNED_LEADER)) { SRpcMsg rpcMsgLocalCmd = {0}; - (void)syncBuildLocalCmd(&rpcMsgLocalCmd, ths->vgId); + TAOS_CHECK_RETURN(syncBuildLocalCmd(&rpcMsgLocalCmd, ths->vgId)); SyncLocalCmd* pSyncMsg = rpcMsgLocalCmd.pCont; pSyncMsg->cmd = SYNC_LOCAL_CMD_STEP_DOWN; @@ -3577,7 +3676,7 @@ int32_t syncNodeOnLocalCmd(SSyncNode* ths, const SRpcMsg* pRpcMsg) { return TSDB_CODE_SYN_INTERNAL_ERROR; } if (pMsg->currentTerm == matchTerm) { - (void)syncNodeUpdateCommitIndex(ths, pMsg->commitIndex); + TAOS_CHECK_RETURN(syncNodeUpdateCommitIndex(ths, pMsg->commitIndex)); } if (ths->fsmState != SYNC_FSM_STATE_INCOMPLETE && syncLogBufferCommit(ths->pLogBuf, ths, ths->commitIndex) < 0) { sError("vgId:%d, failed to commit raft log since %s. commit index:%" PRId64 "", ths->vgId, terrstr(), @@ -3644,7 +3743,11 @@ int32_t syncNodeOnClientRequest(SSyncNode* ths, SRpcMsg* pMsg, SyncIndex* pRetIn if (code > 0) { SRpcMsg rsp = {.code = pMsg->code, .info = pMsg->info}; - (void)syncRespMgrGetAndDel(ths->pSyncRespMgr, pEntry->seqNum, &rsp.info); + if ((code = syncRespMgrGetAndDel(ths->pSyncRespMgr, pEntry->seqNum, &rsp.info)) != 0) { + syncEntryDestroy(pEntry); + pEntry = NULL; + TAOS_RETURN(code); + } if (rsp.info.handle != NULL) { tmsgSendRsp(&rsp); } diff --git a/source/libs/sync/src/syncRaftCfg.c b/source/libs/sync/src/syncRaftCfg.c index e8ed73b089..338a56b17f 100644 --- a/source/libs/sync/src/syncRaftCfg.c +++ b/source/libs/sync/src/syncRaftCfg.c @@ -163,7 +163,7 @@ int32_t syncWriteCfgFile(SSyncNode *pNode) { TAOS_CHECK_EXIT(TAOS_SYSTEM_ERROR(errno)); } - (void)taosCloseFile(&pFile); + TAOS_CHECK_EXIT(taosCloseFile(&pFile)); TAOS_CHECK_EXIT(taosRenameFile(file, realfile)); sInfo("vgId:%d, succeed to write sync cfg file:%s, len:%d, lastConfigIndex:%" PRId64 ", changeVersion:%d", diff --git a/source/libs/sync/src/syncRaftStore.c b/source/libs/sync/src/syncRaftStore.c index 3bb40286bc..717c26dbed 100644 --- a/source/libs/sync/src/syncRaftStore.c +++ b/source/libs/sync/src/syncRaftStore.c @@ -134,7 +134,7 @@ int32_t raftStoreWriteFile(SSyncNode *pNode) { if (taosFsyncFile(pFile) < 0) TAOS_CHECK_GOTO(terrno, &lino, _OVER); - (void)taosCloseFile(&pFile); + TAOS_CHECK_GOTO(taosCloseFile(&pFile), &lino, _OVER); if (taosRenameFile(file, realfile) != 0) TAOS_CHECK_GOTO(terrno, &lino, _OVER); code = 0; @@ -168,21 +168,30 @@ bool raftStoreHasVoted(SSyncNode *pNode) { void raftStoreVote(SSyncNode *pNode, SRaftId *pRaftId) { (void)taosThreadMutexLock(&pNode->raftStore.mutex); pNode->raftStore.voteFor = *pRaftId; - (void)raftStoreWriteFile(pNode); + int32_t code = 0; + if ((code = raftStoreWriteFile(pNode)) != 0) { + sError("vgId:%d, failed to write raft store file since %s", pNode->vgId, tstrerror(code)); + } (void)taosThreadMutexUnlock(&pNode->raftStore.mutex); } void raftStoreClearVote(SSyncNode *pNode) { (void)taosThreadMutexLock(&pNode->raftStore.mutex); pNode->raftStore.voteFor = EMPTY_RAFT_ID; - (void)raftStoreWriteFile(pNode); + int32_t code = 0; + if ((code = raftStoreWriteFile(pNode)) != 0) { + sError("vgId:%d, failed to write raft store file since %s", pNode->vgId, tstrerror(code)); + } (void)taosThreadMutexUnlock(&pNode->raftStore.mutex); } void raftStoreNextTerm(SSyncNode *pNode) { (void)taosThreadMutexLock(&pNode->raftStore.mutex); pNode->raftStore.currentTerm++; - (void)raftStoreWriteFile(pNode); + int32_t code = 0; + if ((code = raftStoreWriteFile(pNode)) != 0) { + sError("vgId:%d, failed to write raft store file since %s", pNode->vgId, tstrerror(code)); + } (void)taosThreadMutexUnlock(&pNode->raftStore.mutex); } @@ -190,7 +199,10 @@ void raftStoreSetTerm(SSyncNode *pNode, SyncTerm term) { (void)taosThreadMutexLock(&pNode->raftStore.mutex); if (pNode->raftStore.currentTerm < term) { pNode->raftStore.currentTerm = term; - (void)raftStoreWriteFile(pNode); + int32_t code = 0; + if ((code = raftStoreWriteFile(pNode)) != 0) { + sError("vgId:%d, failed to write raft store file since %s", pNode->vgId, tstrerror(code)); + } } (void)taosThreadMutexUnlock(&pNode->raftStore.mutex); } diff --git a/source/libs/sync/src/syncRequestVote.c b/source/libs/sync/src/syncRequestVote.c index c8e81b13df..fe5b3eb7ad 100644 --- a/source/libs/sync/src/syncRequestVote.c +++ b/source/libs/sync/src/syncRequestVote.c @@ -137,7 +137,7 @@ int32_t syncNodeOnRequestVote(SSyncNode* ths, const SRpcMsg* pRpcMsg) { // trace log syncLogRecvRequestVote(ths, pMsg, pReply->voteGranted, "", "proceed"); syncLogSendRequestVoteReply(ths, pReply, ""); - (void)syncNodeSendMsgById(&pReply->destId, ths, &rpcMsg); + TAOS_CHECK_RETURN(syncNodeSendMsgById(&pReply->destId, ths, &rpcMsg)); if (resetElect) syncNodeResetElectTimer(ths); From 84b7eae93ccc64adc443e7e2c0f445927ab8e26e Mon Sep 17 00:00:00 2001 From: dmchen Date: Fri, 20 Sep 2024 07:08:57 +0000 Subject: [PATCH 08/18] fix/TD-31891-remove-void-sync1-fix-case --- source/libs/sync/src/syncAppendEntries.c | 3 ++- source/libs/sync/src/syncCommit.c | 9 +++------ source/libs/sync/src/syncMain.c | 6 ++++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/source/libs/sync/src/syncAppendEntries.c b/source/libs/sync/src/syncAppendEntries.c index 51a0679889..a6bd01a092 100644 --- a/source/libs/sync/src/syncAppendEntries.c +++ b/source/libs/sync/src/syncAppendEntries.c @@ -175,7 +175,8 @@ _SEND_RESPONSE: if (accepted && matched) { pReply->success = true; // update commit index only after matching - (void)syncNodeUpdateCommitIndex(ths, TMIN(pMsg->commitIndex, pReply->lastSendIndex)); + SyncIndex returnIndex = syncNodeUpdateCommitIndex(ths, TMIN(pMsg->commitIndex, pReply->lastSendIndex)); + sTrace("vgId:%d, update commit return index %" PRId64 "", ths->vgId, returnIndex); } // ack, i.e. send response diff --git a/source/libs/sync/src/syncCommit.c b/source/libs/sync/src/syncCommit.c index 409277e2da..b3560f9283 100644 --- a/source/libs/sync/src/syncCommit.c +++ b/source/libs/sync/src/syncCommit.c @@ -85,12 +85,9 @@ int64_t syncNodeCheckCommitIndex(SSyncNode* ths, SyncIndex indexLikely) { int32_t code = 0; if (indexLikely > ths->commitIndex && syncNodeAgreedUpon(ths, indexLikely)) { SyncIndex commitIndex = indexLikely; - // TODO add return when error - if ((code = syncNodeUpdateCommitIndex(ths, commitIndex)) != 0) { - sError("vgId:%d, failed to update commit index:%" PRId64 ", since %s", ths->vgId, commitIndex, tstrerror(code)); - } - sTrace("vgId:%d, agreed upon. role:%d, term:%" PRId64 ", index:%" PRId64 "", ths->vgId, ths->state, - raftStoreGetTerm(ths), commitIndex); + SyncIndex returnIndex = syncNodeUpdateCommitIndex(ths, commitIndex); + sTrace("vgId:%d, agreed upon. role:%d, term:%" PRId64 ", index:%" PRId64 ", return:%" PRId64, ths->vgId, ths->state, + raftStoreGetTerm(ths), commitIndex, returnIndex); } return ths->commitIndex; } diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 71234e589f..faa080a653 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -3419,7 +3419,8 @@ _out:; } // single replica - TAOS_CHECK_RETURN(syncNodeUpdateCommitIndex(ths, matchIndex)); + SyncIndex returnIndex = syncNodeUpdateCommitIndex(ths, matchIndex); + sTrace("vgId:%d, update commit return index %" PRId64 "", ths->vgId, returnIndex); if (ths->fsmState != SYNC_FSM_STATE_INCOMPLETE && (code = syncLogBufferCommit(ths->pLogBuf, ths, ths->commitIndex)) < 0) { @@ -3676,7 +3677,8 @@ int32_t syncNodeOnLocalCmd(SSyncNode* ths, const SRpcMsg* pRpcMsg) { return TSDB_CODE_SYN_INTERNAL_ERROR; } if (pMsg->currentTerm == matchTerm) { - TAOS_CHECK_RETURN(syncNodeUpdateCommitIndex(ths, pMsg->commitIndex)); + SyncIndex returnIndex = syncNodeUpdateCommitIndex(ths, pMsg->commitIndex); + sTrace("vgId:%d, update commit return index %" PRId64 "", ths->vgId, returnIndex); } if (ths->fsmState != SYNC_FSM_STATE_INCOMPLETE && syncLogBufferCommit(ths->pLogBuf, ths, ths->commitIndex) < 0) { sError("vgId:%d, failed to commit raft log since %s. commit index:%" PRId64 "", ths->vgId, terrstr(), From 1a031d7dcd3052805b5b2dc70145fcffaaa253a1 Mon Sep 17 00:00:00 2001 From: dmchen Date: Fri, 20 Sep 2024 08:32:20 +0000 Subject: [PATCH 09/18] fix/TD-31891-remove-void-sync1-fix-case --- source/libs/sync/src/syncMain.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index faa080a653..caa4a84ca0 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -991,8 +991,10 @@ static int32_t syncHbTimerStart(SSyncNode* pSyncNode, SSyncTimer* pSyncTimer) { static int32_t syncHbTimerStop(SSyncNode* pSyncNode, SSyncTimer* pSyncTimer) { int32_t ret = 0; (void)atomic_add_fetch_64(&pSyncTimer->logicClock, 1); - if (!taosTmrStop(pSyncTimer->pTimer)) { - return TSDB_CODE_SYN_INTERNAL_ERROR; + if (taosTmrStop(pSyncTimer->pTimer) == false) { + sError("vgId:%d, failed to stop hb timer, return false", pSyncNode->vgId); + } else { + sError("vgId:%d, stop hb timer, return true", pSyncNode->vgId); } pSyncTimer->pTimer = NULL; syncHbTimerDataRemove(pSyncTimer->hbDataRid); From cc2d861e71f64d86398ced7fe1b1494d803230e7 Mon Sep 17 00:00:00 2001 From: dmchen Date: Fri, 20 Sep 2024 08:38:30 +0000 Subject: [PATCH 10/18] fix/TD-31891-remove-void-sync1-fix-case --- source/libs/sync/src/syncMain.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index caa4a84ca0..84f8c4964b 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -991,11 +991,8 @@ static int32_t syncHbTimerStart(SSyncNode* pSyncNode, SSyncTimer* pSyncTimer) { static int32_t syncHbTimerStop(SSyncNode* pSyncNode, SSyncTimer* pSyncTimer) { int32_t ret = 0; (void)atomic_add_fetch_64(&pSyncTimer->logicClock, 1); - if (taosTmrStop(pSyncTimer->pTimer) == false) { - sError("vgId:%d, failed to stop hb timer, return false", pSyncNode->vgId); - } else { - sError("vgId:%d, stop hb timer, return true", pSyncNode->vgId); - } + bool stop = taosTmrStop(pSyncTimer->pTimer); + sDebug("vgId:%d, stop hb timer stop:%d", pSyncNode->vgId, stop); pSyncTimer->pTimer = NULL; syncHbTimerDataRemove(pSyncTimer->hbDataRid); pSyncTimer->hbDataRid = -1; @@ -1638,8 +1635,8 @@ int32_t syncNodeStartPingTimer(SSyncNode* pSyncNode) { int32_t syncNodeStopPingTimer(SSyncNode* pSyncNode) { int32_t code = 0; (void)atomic_add_fetch_64(&pSyncNode->pingTimerLogicClockUser, 1); - // TODO check return value - TAOS_CHECK_RETURN(taosTmrStop(pSyncNode->pPingTimer)); + bool stop = taosTmrStop(pSyncNode->pPingTimer); + sDebug("vgId:%d, stop ping timer, stop:%d", pSyncNode->vgId, stop); pSyncNode->pPingTimer = NULL; return code; } @@ -1666,8 +1663,8 @@ int32_t syncNodeStartElectTimer(SSyncNode* pSyncNode, int32_t ms) { int32_t syncNodeStopElectTimer(SSyncNode* pSyncNode) { int32_t code = 0; (void)atomic_add_fetch_64(&pSyncNode->electTimerLogicClock, 1); - // TODO check return value - TAOS_CHECK_RETURN(taosTmrStop(pSyncNode->pElectTimer)); + bool stop = taosTmrStop(pSyncNode->pElectTimer); + sDebug("vgId:%d, stop elect timer, stop:%d", pSyncNode->vgId, stop); pSyncNode->pElectTimer = NULL; return code; @@ -1738,9 +1735,9 @@ int32_t syncNodeStopHeartbeatTimer(SSyncNode* pSyncNode) { int32_t code = 0; #if 0 - //TODO check return value TAOS_CHECK_RETURN(atomic_add_fetch_64(&pSyncNode->heartbeatTimerLogicClockUser, 1)); - TAOS_CHECK_RETURN(taosTmrStop(pSyncNode->pHeartbeatTimer)); + bool stop = taosTmrStop(pSyncNode->pHeartbeatTimer); + sDebug("vgId:%d, stop heartbeat timer, stop:%d", pSyncNode->vgId, stop); pSyncNode->pHeartbeatTimer = NULL; #endif From 7db555c788f8969cf8309e589e2379db81409702 Mon Sep 17 00:00:00 2001 From: xiao-77 Date: Fri, 20 Sep 2024 17:36:34 +0800 Subject: [PATCH 11/18] fix crash at ci --- source/dnode/vnode/src/tsdb/tsdbCache.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbCache.c b/source/dnode/vnode/src/tsdb/tsdbCache.c index bd69d55aa2..b4c4d4d054 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCache.c +++ b/source/dnode/vnode/src/tsdb/tsdbCache.c @@ -1998,10 +1998,8 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE .cacheStatus = TSDB_LAST_CACHE_NO_CACHE}; code = tsdbCachePutToLRU(pTsdb, &lastKey, &noneCol); } - code = taosLRUCacheRelease(pTsdb->lruCache, h, false); - if (code != TSDB_CODE_SUCCESS) { + if (taosLRUCacheRelease(pTsdb->lruCache, h, false) != TSDB_CODE_SUCCESS) { tsdbError("vgId:%d, %s release lru cache failed at line %d.", TD_VID(pTsdb->pVnode), __func__, __LINE__); - goto _exit; } TAOS_CHECK_EXIT(code); } else { From 1306667d14d5453914ff5a77381a8f882bf387f9 Mon Sep 17 00:00:00 2001 From: dmchen Date: Mon, 23 Sep 2024 01:36:49 +0000 Subject: [PATCH 12/18] fix/TD-31891-remove-void-sync1-fix-case --- source/dnode/mnode/impl/src/mndSync.c | 8 +++----- source/libs/sync/src/syncMain.c | 16 ++++++---------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndSync.c b/source/dnode/mnode/impl/src/mndSync.c index e73cc1b5db..50b8b3e275 100644 --- a/source/dnode/mnode/impl/src/mndSync.c +++ b/source/dnode/mnode/impl/src/mndSync.c @@ -497,11 +497,9 @@ int32_t mndInitSync(SMnode *pMnode) { pNode->nodePort = pMgmt->replicas[i].port; tstrncpy(pNode->nodeFqdn, pMgmt->replicas[i].fqdn, sizeof(pNode->nodeFqdn)); pNode->nodeRole = pMgmt->nodeRoles[i]; - if (tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort) != true) { - mError("failed to open sync, tmsgUpdateDnodeInfo is false"); - } - mInfo("vgId:1, index:%d ep:%s:%u dnode:%d cluster:%" PRId64, i, pNode->nodeFqdn, pNode->nodePort, pNode->nodeId, - pNode->clusterId); + bool update = tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort); + mInfo("vgId:1, index:%d ep:%s:%u dnode:%d cluster:%" PRId64 ", update:%d", i, pNode->nodeFqdn, pNode->nodePort, + pNode->nodeId, pNode->clusterId, update); } int32_t code = 0; diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 84f8c4964b..db7f182b11 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -2813,11 +2813,9 @@ void syncBuildConfigFromReq(SAlterVnodeReplicaReq* pReq, SSyncCfg* cfg) { // TO pNode->nodePort = pReq->replicas[i].port; tstrncpy(pNode->nodeFqdn, pReq->replicas[i].fqdn, sizeof(pNode->nodeFqdn)); pNode->nodeRole = TAOS_SYNC_ROLE_VOTER; - if ((code = tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort)) != 0) { - sError("vgId:%d, failed to update dnode info since %s", pReq->vgId, tstrerror(code)); - } - sInfo("vgId:%d, replica:%d ep:%s:%u dnode:%d nodeRole:%d", pReq->vgId, i, pNode->nodeFqdn, pNode->nodePort, - pNode->nodeId, pNode->nodeRole); + bool update = tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort); + sInfo("vgId:%d, replica:%d ep:%s:%u dnode:%d nodeRole:%d, update:%d", pReq->vgId, i, pNode->nodeFqdn, + pNode->nodePort, pNode->nodeId, pNode->nodeRole, update); cfg->replicaNum++; } if (pReq->selfIndex != -1) { @@ -2829,11 +2827,9 @@ void syncBuildConfigFromReq(SAlterVnodeReplicaReq* pReq, SSyncCfg* cfg) { // TO pNode->nodePort = pReq->learnerReplicas[cfg->totalReplicaNum].port; pNode->nodeRole = TAOS_SYNC_ROLE_LEARNER; tstrncpy(pNode->nodeFqdn, pReq->learnerReplicas[cfg->totalReplicaNum].fqdn, sizeof(pNode->nodeFqdn)); - if ((code = tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort)) != 0) { - sError("vgId:%d, failed to update dnode info, %s", pReq->vgId, tstrerror(code)); - } - sInfo("vgId:%d, replica:%d ep:%s:%u dnode:%d nodeRole:%d", pReq->vgId, i, pNode->nodeFqdn, pNode->nodePort, - pNode->nodeId, pNode->nodeRole); + bool update = tmsgUpdateDnodeInfo(&pNode->nodeId, &pNode->clusterId, pNode->nodeFqdn, &pNode->nodePort); + sInfo("vgId:%d, replica:%d ep:%s:%u dnode:%d nodeRole:%d, update:%d", pReq->vgId, i, pNode->nodeFqdn, + pNode->nodePort, pNode->nodeId, pNode->nodeRole, update); cfg->totalReplicaNum++; } cfg->totalReplicaNum += pReq->replica; From 15272802772dae0997671cfd0152735cef4cf774 Mon Sep 17 00:00:00 2001 From: dmchen Date: Mon, 23 Sep 2024 05:15:12 +0000 Subject: [PATCH 13/18] fix/TD-31891-remove-void-sync1-fix-case --- source/libs/sync/src/syncMain.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index db7f182b11..41b403c559 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -1139,8 +1139,8 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo, int32_t vnodeVersion) { pSyncNode->replicaNum = pSyncNode->raftCfg.cfg.replicaNum; pSyncNode->totalReplicaNum = pSyncNode->raftCfg.cfg.totalReplicaNum; for (int32_t i = 0; i < pSyncNode->raftCfg.cfg.totalReplicaNum; ++i) { - if (!syncUtilNodeInfo2RaftId(&pSyncNode->raftCfg.cfg.nodeInfo[i], pSyncNode->vgId, &pSyncNode->replicasId[i])) { - terrno = TSDB_CODE_SYN_INTERNAL_ERROR; + if (syncUtilNodeInfo2RaftId(&pSyncNode->raftCfg.cfg.nodeInfo[i], pSyncNode->vgId, &pSyncNode->replicasId[i]) == + false) { sError("vgId:%d, failed to determine raft member id, replica:%d", pSyncNode->vgId, i); goto _error; } @@ -1900,7 +1900,7 @@ int32_t syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncI // init internal pSyncNode->myNodeInfo = pSyncNode->raftCfg.cfg.nodeInfo[pSyncNode->raftCfg.cfg.myIndex]; - TAOS_CHECK_RETURN(syncUtilNodeInfo2RaftId(&pSyncNode->myNodeInfo, pSyncNode->vgId, &pSyncNode->myRaftId)); + if (syncUtilNodeInfo2RaftId(&pSyncNode->myNodeInfo, pSyncNode->vgId, &pSyncNode->myRaftId) == false) return terrno; // init peersNum, peers, peersId pSyncNode->peersNum = pSyncNode->raftCfg.cfg.totalReplicaNum - 1; @@ -1913,15 +1913,17 @@ int32_t syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncI } } for (int32_t i = 0; i < pSyncNode->peersNum; ++i) { - TAOS_CHECK_RETURN(syncUtilNodeInfo2RaftId(&pSyncNode->peersNodeInfo[i], pSyncNode->vgId, &pSyncNode->peersId[i])); + if (syncUtilNodeInfo2RaftId(&pSyncNode->peersNodeInfo[i], pSyncNode->vgId, &pSyncNode->peersId[i]) == false) + return terrno; } // init replicaNum, replicasId pSyncNode->replicaNum = pSyncNode->raftCfg.cfg.replicaNum; pSyncNode->totalReplicaNum = pSyncNode->raftCfg.cfg.totalReplicaNum; for (int32_t i = 0; i < pSyncNode->raftCfg.cfg.totalReplicaNum; ++i) { - TAOS_CHECK_RETURN( - syncUtilNodeInfo2RaftId(&pSyncNode->raftCfg.cfg.nodeInfo[i], pSyncNode->vgId, &pSyncNode->replicasId[i])); + if (syncUtilNodeInfo2RaftId(&pSyncNode->raftCfg.cfg.nodeInfo[i], pSyncNode->vgId, &pSyncNode->replicasId[i]) == + false) + return terrno; } // update quorum first @@ -2940,9 +2942,9 @@ int32_t syncNodeRebuildPeerAndCfg(SSyncNode* ths, SSyncCfg* cfg) { syncUtilNodeInfo2EpSet(&ths->peersNodeInfo[i], &ths->peersEpset[i]); - if (!syncUtilNodeInfo2RaftId(&ths->peersNodeInfo[i], ths->vgId, &ths->peersId[i])) { + if (syncUtilNodeInfo2RaftId(&ths->peersNodeInfo[i], ths->vgId, &ths->peersId[i]) == false) { sError("vgId:%d, failed to determine raft member id, peer:%d", ths->vgId, i); - return -1; + return terrno; } i++; @@ -3010,8 +3012,7 @@ int32_t syncNodeRebuildAndCopyIfExist(SSyncNode* ths, int32_t oldtotalReplicaNum ths->replicaNum = ths->raftCfg.cfg.replicaNum; ths->totalReplicaNum = ths->raftCfg.cfg.totalReplicaNum; for (int32_t i = 0; i < ths->raftCfg.cfg.totalReplicaNum; ++i) { - if (!syncUtilNodeInfo2RaftId(&ths->raftCfg.cfg.nodeInfo[i], ths->vgId, &ths->replicasId[i])) - return TSDB_CODE_SYN_INTERNAL_ERROR; + if (syncUtilNodeInfo2RaftId(&ths->raftCfg.cfg.nodeInfo[i], ths->vgId, &ths->replicasId[i]) == false) return terrno; } // 2.rebuild MatchIndex, remove deleted one From 9e8518e772f5d3392a44fc1aa6d623e7da4bfd31 Mon Sep 17 00:00:00 2001 From: xiao-77 Date: Mon, 23 Sep 2024 14:11:19 +0800 Subject: [PATCH 14/18] fix add mem free before retuen --- source/dnode/vnode/src/tsdb/tsdbCache.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/dnode/vnode/src/tsdb/tsdbCache.c b/source/dnode/vnode/src/tsdb/tsdbCache.c index b4c4d4d054..78f53a3adb 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCache.c +++ b/source/dnode/vnode/src/tsdb/tsdbCache.c @@ -936,6 +936,7 @@ int32_t tsdbCacheDropSubTables(STsdb *pTsdb, SArray *uids, tb_uid_t suid) { if (code != TSDB_CODE_SUCCESS) { tsdbError("vgId:%d, %s drop table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, tstrerror(code)); + taosMemoryFree(pTSchema); (void)taosThreadMutexUnlock(&pTsdb->lruMutex); TAOS_RETURN(code); } From 3e013d28bc0ff3ac35b68723f17d7c44590d3acc Mon Sep 17 00:00:00 2001 From: dmchen Date: Mon, 23 Sep 2024 10:30:36 +0000 Subject: [PATCH 15/18] fix/TD-31891-remove-void-sync1-fix-case --- source/libs/sync/src/syncMain.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 01e0628138..a9c756ec2b 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -2749,12 +2749,10 @@ static void syncNodeEqPeerHeartbeatTimer(void* param, void* tmrId) { STraceId* trace = &(rpcMsg.info.traceId); sGTrace("vgId:%d, send sync-heartbeat to dnode:%d", pSyncNode->vgId, DID(&(pSyncMsg->destId))); syncLogSendHeartbeat(pSyncNode, pSyncMsg, false, timerElapsed, pData->execTime); - if ((code = syncNodeSendHeartbeat(pSyncNode, &pSyncMsg->destId, &rpcMsg)) != 0) { + int ret = 0; + if ((ret = syncNodeSendHeartbeat(pSyncNode, &pSyncMsg->destId, &rpcMsg)) != 0) { sError("vgId:%d, failed to send heartbeat to dnode:%d since %s", pSyncNode->vgId, DID(&(pSyncMsg->destId)), - tstrerror(code)); - syncNodeRelease(pSyncNode); - syncHbTimerDataRelease(pData); - return; + tstrerror(ret)); } } else { } From aacf000d1c88f61a29adaa323687c178dcdd9b56 Mon Sep 17 00:00:00 2001 From: dmchen Date: Mon, 23 Sep 2024 10:38:07 +0000 Subject: [PATCH 16/18] fix/TD-31891-remove-void-sync1-fix-case --- source/libs/sync/src/syncMain.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index a9c756ec2b..1a90eb8ab0 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -2749,10 +2749,9 @@ static void syncNodeEqPeerHeartbeatTimer(void* param, void* tmrId) { STraceId* trace = &(rpcMsg.info.traceId); sGTrace("vgId:%d, send sync-heartbeat to dnode:%d", pSyncNode->vgId, DID(&(pSyncMsg->destId))); syncLogSendHeartbeat(pSyncNode, pSyncMsg, false, timerElapsed, pData->execTime); - int ret = 0; - if ((ret = syncNodeSendHeartbeat(pSyncNode, &pSyncMsg->destId, &rpcMsg)) != 0) { - sError("vgId:%d, failed to send heartbeat to dnode:%d since %s", pSyncNode->vgId, DID(&(pSyncMsg->destId)), - tstrerror(ret)); + int ret = syncNodeSendHeartbeat(pSyncNode, &pSyncMsg->destId, &rpcMsg); + if (ret != 0) { + sError("vgId:%d, failed to send heartbeat since %s", pSyncNode->vgId, tstrerror(ret)); } } else { } From b0822d8cc231194f45fb628b63162f56ceb7a04e Mon Sep 17 00:00:00 2001 From: dmchen Date: Mon, 23 Sep 2024 10:40:46 +0000 Subject: [PATCH 17/18] fix/TD-31891-remove-void-sync1-fix-case --- source/libs/sync/src/syncReplication.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/libs/sync/src/syncReplication.c b/source/libs/sync/src/syncReplication.c index 0cda5d1ea9..247b5624c3 100644 --- a/source/libs/sync/src/syncReplication.c +++ b/source/libs/sync/src/syncReplication.c @@ -118,8 +118,9 @@ int32_t syncNodeHeartbeatPeers(SSyncNode* pSyncNode) { STraceId* trace = &(rpcMsg.info.traceId); sGTrace("vgId:%d, send sync-heartbeat to dnode:%d", pSyncNode->vgId, DID(&(pSyncMsg->destId))); syncLogSendHeartbeat(pSyncNode, pSyncMsg, true, 0, 0); - if (syncNodeSendHeartbeat(pSyncNode, &pSyncMsg->destId, &rpcMsg) != 0) { - sError("vgId:%d, failed to send sync-heartbeat to dnode:%d", pSyncNode->vgId, DID(&(pSyncMsg->destId))); + int32_t ret = syncNodeSendHeartbeat(pSyncNode, &pSyncMsg->destId, &rpcMsg); + if (ret != 0) { + sError("vgId:%d, failed to send sync-heartbeat since %s", pSyncNode->vgId, tstrerror(ret)); } } From 6bc8972c8c6a0007c0b38afe11169655abf8e025 Mon Sep 17 00:00:00 2001 From: xiao-77 Date: Mon, 23 Sep 2024 19:56:25 +0800 Subject: [PATCH 18/18] fix ci snapshot.py --- source/dnode/vnode/src/tsdb/tsdbCache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbCache.c b/source/dnode/vnode/src/tsdb/tsdbCache.c index 78f53a3adb..482b194a1f 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCache.c +++ b/source/dnode/vnode/src/tsdb/tsdbCache.c @@ -936,8 +936,8 @@ int32_t tsdbCacheDropSubTables(STsdb *pTsdb, SArray *uids, tb_uid_t suid) { if (code != TSDB_CODE_SUCCESS) { tsdbError("vgId:%d, %s drop table column failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__, tstrerror(code)); - taosMemoryFree(pTSchema); (void)taosThreadMutexUnlock(&pTsdb->lruMutex); + taosMemoryFree(pTSchema); TAOS_RETURN(code); } }