From 27e9b11889ae7ce15437ce9941ba1c330d652d41 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Thu, 27 May 2021 03:41:28 +0800 Subject: [PATCH] [TD-3178] add compact-status in vgroup --- src/inc/taosmsg.h | 2 +- src/mnode/inc/mnodeDef.h | 1 + src/mnode/src/mnodeVgroup.c | 14 +++++++++++++- src/vnode/src/vnodeMgmt.c | 1 + 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index a4cee6d394..f5ce25cce0 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -539,7 +539,7 @@ typedef struct { uint8_t status; uint8_t role; uint8_t replica; - uint8_t reserved; + uint8_t compact; } SVnodeLoad; typedef struct { diff --git a/src/mnode/inc/mnodeDef.h b/src/mnode/inc/mnodeDef.h index e052f34a33..f170f58b53 100644 --- a/src/mnode/inc/mnodeDef.h +++ b/src/mnode/inc/mnodeDef.h @@ -145,6 +145,7 @@ typedef struct SVgObj { int8_t reserved0[4]; SVnodeGid vnodeGid[TSDB_MAX_REPLICA]; int32_t vgCfgVersion; + int8_t compact; int8_t reserved1[8]; int8_t updateEnd[4]; int32_t refCount; diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index b422934521..7113813746 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -354,6 +354,7 @@ void mnodeUpdateVgroupStatus(SVgObj *pVgroup, SDnodeObj *pDnode, SVnodeLoad *pVl pVgroup->pDb->dbCfgVersion, pVgroup->vgCfgVersion, pVgroup->numOfVnodes); mnodeSendAlterVgroupMsg(pVgroup); } + pVgroup->compact = pVload->compact; } static int32_t mnodeAllocVgroupIdPool(SVgObj *pInputVgroup) { @@ -721,6 +722,13 @@ static int32_t mnodeGetVgroupMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *p cols++; } + pShow->bytes[cols] = 4; + pSchema[cols].type = TSDB_DATA_TYPE_INT; + strcpy(pSchema[cols].name, "compacting"); + pSchema[cols].bytes = htons(pShow->bytes[cols]); + cols++; + + pMeta->numOfColumns = htons(cols); pShow->numOfColumns = cols; @@ -824,7 +832,11 @@ static int32_t mnodeRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, v STR_WITH_MAXSIZE_TO_VARSTR(pWrite, role, pShow->bytes[cols]); cols++; } - + + pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; + *(int8_t *)pWrite = pVgroup->compact; + cols++; + mnodeDecVgroupRef(pVgroup); numOfRows++; } diff --git a/src/vnode/src/vnodeMgmt.c b/src/vnode/src/vnodeMgmt.c index 32f9532138..aabc1dba9d 100644 --- a/src/vnode/src/vnodeMgmt.c +++ b/src/vnode/src/vnodeMgmt.c @@ -148,6 +148,7 @@ static void vnodeBuildVloadMsg(SVnodeObj *pVnode, SStatusMsg *pStatus) { pLoad->status = pVnode->status; pLoad->role = pVnode->role; pLoad->replica = pVnode->syncCfg.replica; + pLoad->compact = 1;//pVnode->compact; } int32_t vnodeGetVnodeList(int32_t vnodeList[], int32_t *numOfVnodes) { -- GitLab