From a1a3f8328357cb7ddaf1372392c48350beaec828 Mon Sep 17 00:00:00 2001 From: xiao-77 Date: Wed, 12 Feb 2025 09:55:36 +0800 Subject: [PATCH] Add unapplied to show vnodes. --- source/common/src/systable.c | 1 + source/dnode/mnode/impl/src/mndVgroup.c | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/source/common/src/systable.c b/source/common/src/systable.c index dbab7d892e..0a9ca8f884 100644 --- a/source/common/src/systable.c +++ b/source/common/src/systable.c @@ -372,6 +372,7 @@ static const SSysDbTableSchema vnodesSchema[] = { {.name = "start_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = true}, {.name = "restored", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL, .sysInfo = true}, {.name = "restored_finish", .bytes = TSDB_SYNC_RESOTRE_lEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, + {.name = "unapplied", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true}, }; static const SSysDbTableSchema userUserPrivilegesSchema[] = { diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index f4f3866dc7..1f295af62f 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -1345,11 +1345,11 @@ static int32_t mndRetrieveVnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB return code; } + int64_t unappliedCount = pGid->syncCommitIndex - pGid->syncAppliedIndex; pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); char restoreStr[20] = {0}; if (!pGid->syncRestore) { - calculateRstoreFinishTime(pGid->appliedRate, pGid->syncCommitIndex - pGid->syncAppliedIndex, restoreStr, - sizeof(restoreStr)); + calculateRstoreFinishTime(pGid->appliedRate, unappliedCount, restoreStr, sizeof(restoreStr)); } STR_TO_VARSTR(buf, restoreStr); colDataSetVal(pColInfo, numOfRows, (const char *)&buf, false); @@ -1358,6 +1358,13 @@ static int32_t mndRetrieveVnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB return code; } + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + code = colDataSetVal(pColInfo, numOfRows, (const char *)&unappliedCount, false); + if (code != 0) { + mError("vgId:%d, failed to set syncRestore, since %s", pVgroup->vgId, tstrerror(code)); + return code; + } + numOfRows++; sdbRelease(pSdb, pDnode); }