From 54562e2426231c00d2c7a1cc0187c945ecd3a461 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Sun, 4 Sep 2022 15:51:40 +0800 Subject: [PATCH] enh: rsma fs restore procedure optimization --- source/dnode/vnode/src/sma/smaFS.c | 11 +++++++++-- source/dnode/vnode/src/sma/smaRollup.c | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/source/dnode/vnode/src/sma/smaFS.c b/source/dnode/vnode/src/sma/smaFS.c index acb529bb9e..4387db553e 100644 --- a/source/dnode/vnode/src/sma/smaFS.c +++ b/source/dnode/vnode/src/sma/smaFS.c @@ -33,6 +33,8 @@ int32_t tdRSmaFSOpen(SSma *pSma, int64_t version) { SSmaEnv *pEnv = SMA_RSMA_ENV(pSma); SRSmaStat *pStat = NULL; SArray *output = NULL; + + terrno = TSDB_CODE_SUCCESS; if (!pEnv) { return TSDB_CODE_SUCCESS; @@ -62,7 +64,7 @@ _end: } taosArrayDestroy(output); - if (terrno != 0) { + if (terrno != TSDB_CODE_SUCCESS) { smaError("vgId:%d, open rsma fs failed since %s", TD_VID(pVnode), terrstr()); return TSDB_CODE_FAILED; } @@ -138,6 +140,11 @@ static int32_t tdFetchQTaskInfoFiles(SSma *pSma, int64_t version, SArray **outpu tdGetVndDirName(TD_VID(pVnode), tfsGetPrimaryPath(pVnode->pTfs), VNODE_RSMA_DIR, true, dir); + if (!taosCheckExistFile(dir)) { + smaDebug("vgId:%d, fetch qtask files, no need as dir %s not exist", TD_VID(pVnode), dir); + return TSDB_CODE_SUCCESS; + } + // Resource allocation and init if ((code = regcomp(®ex, pattern, REG_EXTENDED)) != 0) { terrno = TSDB_CODE_RSMA_REGEX_MATCH; @@ -150,7 +157,7 @@ static int32_t tdFetchQTaskInfoFiles(SSma *pSma, int64_t version, SArray **outpu if (!(pDir = taosOpenDir(dir))) { regfree(®ex); terrno = TAOS_SYSTEM_ERROR(errno); - smaDebug("vgId:%d, fetch qtask files, open dir %s failed since %s", TD_VID(pVnode), dir, terrstr()); + smaError("vgId:%d, fetch qtask files, open dir %s failed since %s", TD_VID(pVnode), dir, terrstr()); return TSDB_CODE_FAILED; } diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index 8fcc371153..6732403846 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -1635,7 +1635,7 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) { atomic_val_compare_exchange_8(&pItem->triggerStat, TASK_TRIGGER_STAT_ACTIVE, TASK_TRIGGER_STAT_INACTIVE); switch (fetchTriggerStat) { case TASK_TRIGGER_STAT_ACTIVE: { - smaInfo("vgId:%d, rsma fetch task planned for level:%" PRIi8 " suid:%" PRIi64 " since stat is active", + smaDebug("vgId:%d, rsma fetch task planned for level:%" PRIi8 " suid:%" PRIi64 " since stat is active", SMA_VID(pSma), pItem->level, pRSmaInfo->suid); // async process pItem->fetchLevel = pItem->level; @@ -1704,7 +1704,7 @@ static int32_t tdRSmaFetchAllResult(SSma *pSma, SRSmaInfo *pInfo) { SMA_VID(pSma), pInfo->suid, i, pItem->nSkipped, pItem->maxDelay); } else if (((curMs - pInfo->lastRecv) < RSMA_FETCH_ACTIVE_MAX)) { ++pItem->nSkipped; - smaInfo("vgId:%d, suid:%" PRIi64 " level:%" PRIi8 " curMs:%" PRIi64 " lastRecv:%" PRIi64 ", fetch skipped ", + smaDebug("vgId:%d, suid:%" PRIi64 " level:%" PRIi8 " curMs:%" PRIi64 " lastRecv:%" PRIi64 ", fetch skipped ", SMA_VID(pSma), pInfo->suid, i, curMs, pInfo->lastRecv); continue; } else { -- GitLab