fix/TD-32703-add-wal-log

This commit is contained in:
dmchen 2024-10-31 08:03:29 +00:00
parent ba9c796c9d
commit 0a4cdb4c47
2 changed files with 21 additions and 13 deletions

View File

@ -741,7 +741,7 @@ int32_t vmProcessAlterVnodeReplicaReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
int32_t vgId = alterReq.vgId; int32_t vgId = alterReq.vgId;
dInfo( dInfo(
"vgId:%d,vnode management handle msgType:%s, start to alter vnode replica:%d selfIndex:%d leanerReplica:%d " "vgId:%d, vnode management handle msgType:%s, start to alter vnode replica:%d selfIndex:%d leanerReplica:%d "
"learnerSelfIndex:%d strict:%d changeVersion:%d", "learnerSelfIndex:%d strict:%d changeVersion:%d",
vgId, TMSG_INFO(pMsg->msgType), alterReq.replica, alterReq.selfIndex, alterReq.learnerReplica, vgId, TMSG_INFO(pMsg->msgType), alterReq.replica, alterReq.selfIndex, alterReq.learnerReplica,
alterReq.learnerSelfIndex, alterReq.strict, alterReq.changeVersion); alterReq.learnerSelfIndex, alterReq.strict, alterReq.changeVersion);

View File

@ -411,14 +411,14 @@ static int32_t walTrimIdxFile(SWal* pWal, int32_t fileIdx) {
TAOS_RETURN(TSDB_CODE_SUCCESS); TAOS_RETURN(TSDB_CODE_SUCCESS);
} }
void printFileSet(SArray* fileSet) { static void printFileSet(int32_t vgId, SArray* fileSet, const char* str) {
int32_t sz = taosArrayGetSize(fileSet); int32_t sz = taosArrayGetSize(fileSet);
for (int32_t i = 0; i < sz; i++) { for (int32_t i = 0; i < sz; i++) {
SWalFileInfo* pFileInfo = taosArrayGet(fileSet, i); SWalFileInfo* pFileInfo = taosArrayGet(fileSet, i);
wInfo("firstVer:%" PRId64 ", lastVer:%" PRId64 ", fileSize:%" PRId64 ", syncedOffset:%" PRId64 ", createTs:%" PRId64 wInfo("vgId:%d, %s-%d, firstVer:%" PRId64 ", lastVer:%" PRId64 ", fileSize:%" PRId64 ", syncedOffset:%" PRId64
", closeTs:%" PRId64, ", createTs:%" PRId64 ", closeTs:%" PRId64,
pFileInfo->firstVer, pFileInfo->lastVer, pFileInfo->fileSize, pFileInfo->syncedOffset, pFileInfo->createTs, vgId, str, i, pFileInfo->firstVer, pFileInfo->lastVer, pFileInfo->fileSize, pFileInfo->syncedOffset,
pFileInfo->closeTs); pFileInfo->createTs, pFileInfo->closeTs);
} }
} }
@ -430,6 +430,9 @@ int32_t walCheckAndRepairMeta(SWal* pWal) {
regex_t logRegPattern; regex_t logRegPattern;
regex_t idxRegPattern; regex_t idxRegPattern;
wInfo("vgId:%d, begin to repair meta, wal path:%s, firstVer:%" PRId64 ", lastVer:%" PRId64 ", snapshotVer:%" PRId64,
pWal->cfg.vgId, pWal->path, pWal->vers.firstVer, pWal->vers.lastVer, pWal->vers.snapshotVer);
if (regcomp(&logRegPattern, logPattern, REG_EXTENDED) != 0) { if (regcomp(&logRegPattern, logPattern, REG_EXTENDED) != 0) {
wError("failed to compile log pattern, error:%s", tstrerror(terrno)); wError("failed to compile log pattern, error:%s", tstrerror(terrno));
return terrno; return terrno;
@ -482,9 +485,9 @@ int32_t walCheckAndRepairMeta(SWal* pWal) {
taosArraySort(actualLog, compareWalFileInfo); taosArraySort(actualLog, compareWalFileInfo);
wInfo("vgId:%d, wal path:%s, actual log file num:%d", pWal->cfg.vgId, pWal->path, wInfo("vgId:%d, actual log file, wal path:%s, num:%d", pWal->cfg.vgId, pWal->path,
(int32_t)taosArrayGetSize(actualLog)); (int32_t)taosArrayGetSize(actualLog));
printFileSet(actualLog); printFileSet(pWal->cfg.vgId, actualLog, "actual log file");
int metaFileNum = taosArrayGetSize(pWal->fileInfoSet); int metaFileNum = taosArrayGetSize(pWal->fileInfoSet);
int actualFileNum = taosArrayGetSize(actualLog); int actualFileNum = taosArrayGetSize(actualLog);
@ -500,9 +503,9 @@ int32_t walCheckAndRepairMeta(SWal* pWal) {
TAOS_RETURN(code); TAOS_RETURN(code);
} }
wInfo("vgId:%d, wal path:%s, meta log file num:%d", pWal->cfg.vgId, pWal->path, wInfo("vgId:%d, log file in meta, wal path:%s, num:%d", pWal->cfg.vgId, pWal->path,
(int32_t)taosArrayGetSize(pWal->fileInfoSet)); (int32_t)taosArrayGetSize(pWal->fileInfoSet));
printFileSet(pWal->fileInfoSet); printFileSet(pWal->cfg.vgId, pWal->fileInfoSet, "log file in meta");
int32_t sz = taosArrayGetSize(pWal->fileInfoSet); int32_t sz = taosArrayGetSize(pWal->fileInfoSet);
@ -563,7 +566,9 @@ int32_t walCheckAndRepairMeta(SWal* pWal) {
// repair ts of files // repair ts of files
TAOS_CHECK_RETURN(walRepairLogFileTs(pWal, &updateMeta)); TAOS_CHECK_RETURN(walRepairLogFileTs(pWal, &updateMeta));
printFileSet(pWal->fileInfoSet); wInfo("vgId:%d, log file after repair, wal path:%s, num:%d", pWal->cfg.vgId, pWal->path,
(int32_t)taosArrayGetSize(pWal->fileInfoSet));
printFileSet(pWal->cfg.vgId, pWal->fileInfoSet, "file after repair");
// update meta file // update meta file
if (updateMeta) { if (updateMeta) {
TAOS_CHECK_RETURN(walSaveMeta(pWal)); TAOS_CHECK_RETURN(walSaveMeta(pWal));
@ -571,6 +576,9 @@ int32_t walCheckAndRepairMeta(SWal* pWal) {
TAOS_CHECK_RETURN(walLogEntriesComplete(pWal)); TAOS_CHECK_RETURN(walLogEntriesComplete(pWal));
wInfo("vgId:%d, success to repair meta, wal path:%s, firstVer:%" PRId64 ", lastVer:%" PRId64 ", snapshotVer:%" PRId64,
pWal->cfg.vgId, pWal->path, pWal->vers.firstVer, pWal->vers.lastVer, pWal->vers.snapshotVer);
return code; return code;
} }
@ -1157,9 +1165,9 @@ int32_t walLoadMeta(SWal* pWal) {
(void)taosCloseFile(&pFile); (void)taosCloseFile(&pFile);
taosMemoryFree(buf); taosMemoryFree(buf);
wInfo("vgId:%d, load meta file: %s, firstVer:%" PRId64 ", lastVer:%" PRId64 ", fileInfoSet size:%d", pWal->cfg.vgId, wInfo("vgId:%d, meta file loaded: %s, firstVer:%" PRId64 ", lastVer:%" PRId64 ", fileInfoSet size:%d", pWal->cfg.vgId,
fnameStr, pWal->vers.firstVer, pWal->vers.lastVer, (int32_t)taosArrayGetSize(pWal->fileInfoSet)); fnameStr, pWal->vers.firstVer, pWal->vers.lastVer, (int32_t)taosArrayGetSize(pWal->fileInfoSet));
printFileSet(pWal->fileInfoSet); printFileSet(pWal->cfg.vgId, pWal->fileInfoSet, "file in meta");
TAOS_RETURN(code); TAOS_RETURN(code);
} }