fix core at tsdbCache
This commit is contained in:
parent
f4bad8d511
commit
389f5ff088
|
@ -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);
|
LRUHandle *h = taosLRUCacheLookup(pTsdb->lruCache, keys_list[i], klen);
|
||||||
if (h) {
|
if (h) {
|
||||||
if (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__);
|
tsdbInfo("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);
|
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);
|
TAOS_CHECK_EXIT(code);
|
||||||
} else {
|
} else {
|
||||||
if (!remainCols) {
|
if (!remainCols) {
|
||||||
|
@ -1365,7 +1366,8 @@ _exit:
|
||||||
taosArrayDestroy(remainCols);
|
taosArrayDestroy(remainCols);
|
||||||
|
|
||||||
if (code) {
|
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);
|
TAOS_RETURN(code);
|
||||||
|
@ -1457,7 +1459,7 @@ int32_t tsdbCacheRowFormatUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, int6
|
||||||
|
|
||||||
// 3. do update
|
// 3. do update
|
||||||
code = tsdbCacheUpdate(pTsdb, suid, uid, ctxArray);
|
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__,
|
tsdbError("vgId:%d, %s tsdbCacheUpdate failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, __LINE__,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
TAOS_CHECK_GOTO(code, &lino, _exit);
|
TAOS_CHECK_GOTO(code, &lino, _exit);
|
||||||
|
|
|
@ -58,6 +58,7 @@ static FORCE_INLINE int32_t walScanLogGetLastVer(SWal* pWal, int32_t fileIdx, in
|
||||||
|
|
||||||
int64_t fileSize = 0;
|
int64_t fileSize = 0;
|
||||||
if (taosStatFile(fnameStr, &fileSize, NULL, NULL) != 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;
|
code = terrno;
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
@ -370,6 +371,7 @@ static int32_t walTrimIdxFile(SWal* pWal, int32_t fileIdx) {
|
||||||
|
|
||||||
int64_t fileSize = 0;
|
int64_t fileSize = 0;
|
||||||
if (taosStatFile(fnameStr, &fileSize, NULL, NULL) != 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;
|
code = terrno;
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
@ -390,6 +392,7 @@ static int32_t walTrimIdxFile(SWal* pWal, int32_t fileIdx) {
|
||||||
|
|
||||||
code = taosFtruncateFile(pFile, lastEndOffset);
|
code = taosFtruncateFile(pFile, lastEndOffset);
|
||||||
if (code < 0) {
|
if (code < 0) {
|
||||||
|
wError("vgId:%d, failed to truncate file due to %s. file:%s", pWal->cfg.vgId, strerror(errno), fnameStr);
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
(void)taosCloseFile(&pFile);
|
(void)taosCloseFile(&pFile);
|
||||||
|
@ -794,33 +797,33 @@ int32_t walMetaSerialize(SWal* pWal, char** serialized) {
|
||||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
if (cJSON_AddItemToObject(pRoot, "meta", pMeta) != 0) {
|
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);
|
(void)sprintf(buf, "%" PRId64, pWal->vers.firstVer);
|
||||||
if (cJSON_AddStringToObject(pMeta, "firstVer", buf) == NULL) {
|
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);
|
(void)sprintf(buf, "%" PRId64, pWal->vers.snapshotVer);
|
||||||
if (cJSON_AddStringToObject(pMeta, "snapshotVer", buf) == NULL) {
|
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);
|
(void)sprintf(buf, "%" PRId64, pWal->vers.commitVer);
|
||||||
if (cJSON_AddStringToObject(pMeta, "commitVer", buf) == NULL) {
|
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);
|
(void)sprintf(buf, "%" PRId64, pWal->vers.lastVer);
|
||||||
if (cJSON_AddStringToObject(pMeta, "lastVer", buf) == NULL) {
|
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) {
|
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;
|
SWalFileInfo* pData = pWal->fileInfoSet->pData;
|
||||||
for (int i = 0; i < sz; i++) {
|
for (int i = 0; i < sz; i++) {
|
||||||
SWalFileInfo* pInfo = &pData[i];
|
SWalFileInfo* pInfo = &pData[i];
|
||||||
if (cJSON_AddItemToArray(pFiles, pField = cJSON_CreateObject()) != 0) {
|
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) {
|
if (pField == NULL) {
|
||||||
cJSON_Delete(pRoot);
|
cJSON_Delete(pRoot);
|
||||||
|
@ -831,23 +834,23 @@ int32_t walMetaSerialize(SWal* pWal, char** serialized) {
|
||||||
// string are used to prohibit the loss of precision
|
// string are used to prohibit the loss of precision
|
||||||
(void)sprintf(buf, "%" PRId64, pInfo->firstVer);
|
(void)sprintf(buf, "%" PRId64, pInfo->firstVer);
|
||||||
if (cJSON_AddStringToObject(pField, "firstVer", buf) == NULL) {
|
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);
|
(void)sprintf(buf, "%" PRId64, pInfo->lastVer);
|
||||||
if (cJSON_AddStringToObject(pField, "lastVer", buf) == NULL) {
|
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);
|
(void)sprintf(buf, "%" PRId64, pInfo->createTs);
|
||||||
if (cJSON_AddStringToObject(pField, "createTs", buf) == NULL) {
|
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);
|
(void)sprintf(buf, "%" PRId64, pInfo->closeTs);
|
||||||
if (cJSON_AddStringToObject(pField, "closeTs", buf) == NULL) {
|
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);
|
(void)sprintf(buf, "%" PRId64, pInfo->fileSize);
|
||||||
if (cJSON_AddStringToObject(pField, "fileSize", buf) == NULL) {
|
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);
|
char* pSerialized = cJSON_Print(pRoot);
|
||||||
|
@ -1053,6 +1056,7 @@ int32_t walSaveMeta(SWal* pWal) {
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
|
wError("vgId:%d, %s failed at line %d since %s", pWal->cfg.vgId, __func__, lino, tstrerror(code));
|
||||||
taosCloseFile(&pMetaFile);
|
taosCloseFile(&pMetaFile);
|
||||||
taosMemoryFree(serialized);
|
taosMemoryFree(serialized);
|
||||||
return code;
|
return code;
|
||||||
|
@ -1076,6 +1080,7 @@ int32_t walLoadMeta(SWal* pWal) {
|
||||||
// read metafile
|
// read metafile
|
||||||
int64_t fileSize = 0;
|
int64_t fileSize = 0;
|
||||||
if (taosStatFile(fnameStr, &fileSize, NULL, NULL) != 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;
|
code = terrno;
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,7 +161,7 @@ SWal *walOpen(const char *path, SWalCfg *pCfg) {
|
||||||
|
|
||||||
// load meta
|
// load meta
|
||||||
if (walLoadMeta(pWal) < 0) {
|
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) {
|
if (walCheckAndRepairMeta(pWal) < 0) {
|
||||||
|
|
|
@ -541,7 +541,6 @@ static void taosLRUCacheShardEraseUnrefEntries(SLRUCacheShard *shard) {
|
||||||
if (e != NULL) {
|
if (e != NULL) {
|
||||||
TAOS_LRU_ENTRY_SET_IN_CACHE(e, false);
|
TAOS_LRU_ENTRY_SET_IN_CACHE(e, false);
|
||||||
if (!TAOS_LRU_ENTRY_HAS_REFS(e)) {
|
if (!TAOS_LRU_ENTRY_HAS_REFS(e)) {
|
||||||
taosLRUCacheShardLRURemove(shard, e);
|
|
||||||
shard->usage -= e->totalCharge;
|
shard->usage -= e->totalCharge;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue