tsdbCache/usage: new cacheload column for db.vgroups to check usage
This commit is contained in:
parent
bd0523ddb9
commit
97d533d520
|
@ -1066,6 +1066,7 @@ typedef struct {
|
|||
typedef struct {
|
||||
int32_t vgId;
|
||||
int32_t syncState;
|
||||
int64_t cacheUsage;
|
||||
int64_t numOfTables;
|
||||
int64_t numOfTimeSeries;
|
||||
int64_t totalStorage;
|
||||
|
@ -2069,9 +2070,9 @@ int32_t tDeserializeSVCreateTbBatchRsp(void* buf, int32_t bufLen, SVCreateTbBatc
|
|||
|
||||
// TDMT_VND_DROP_TABLE =================
|
||||
typedef struct {
|
||||
char* name;
|
||||
uint64_t suid; // for tmq in wal format
|
||||
int8_t igNotExists;
|
||||
char* name;
|
||||
uint64_t suid; // for tmq in wal format
|
||||
int8_t igNotExists;
|
||||
} SVDropTbReq;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -206,6 +206,7 @@ static const SSysDbTableSchema vgroupsSchema[] = {
|
|||
{.name = "v3_dnode", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "v3_status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "status", .bytes = 12 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "cacheload", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "nfiles", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "file_size", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "tsma", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT, .sysInfo = true},
|
||||
|
|
|
@ -994,6 +994,7 @@ int32_t tSerializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) {
|
|||
SVnodeLoad *pload = taosArrayGet(pReq->pVloads, i);
|
||||
if (tEncodeI32(&encoder, pload->vgId) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pload->syncState) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pload->cacheUsage) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pload->numOfTables) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pload->numOfTimeSeries) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pload->totalStorage) < 0) return -1;
|
||||
|
@ -1063,6 +1064,7 @@ int32_t tDeserializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) {
|
|||
SVnodeLoad vload = {0};
|
||||
if (tDecodeI32(&decoder, &vload.vgId) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &vload.syncState) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &vload.cacheUsage) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &vload.numOfTables) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &vload.numOfTimeSeries) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &vload.totalStorage) < 0) return -1;
|
||||
|
|
|
@ -340,6 +340,7 @@ typedef struct {
|
|||
uint32_t hashEnd;
|
||||
char dbName[TSDB_DB_FNAME_LEN];
|
||||
int64_t dbUid;
|
||||
int64_t cacheUsage;
|
||||
int64_t numOfTables;
|
||||
int64_t numOfTimeSeries;
|
||||
int64_t totalStorage;
|
||||
|
|
|
@ -347,6 +347,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
|||
SVgObj *pVgroup = mndAcquireVgroup(pMnode, pVload->vgId);
|
||||
if (pVgroup != NULL) {
|
||||
if (pVload->syncState == TAOS_SYNC_STATE_LEADER) {
|
||||
pVgroup->cacheUsage = pVload->cacheUsage;
|
||||
pVgroup->numOfTables = pVload->numOfTables;
|
||||
pVgroup->numOfTimeSeries = pVload->numOfTimeSeries;
|
||||
pVgroup->totalStorage = pVload->totalStorage;
|
||||
|
@ -853,8 +854,8 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
|
|||
}
|
||||
|
||||
int32_t code = -1;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
void *pIter = NULL;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
void *pIter = NULL;
|
||||
while (1) {
|
||||
SDnodeObj *pDnode = NULL;
|
||||
pIter = sdbFetch(pSdb, SDB_DNODE, pIter, (void **)&pDnode);
|
||||
|
@ -877,7 +878,7 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
|
|||
|
||||
sdbRelease(pSdb, pDnode);
|
||||
}
|
||||
|
||||
|
||||
if (code == -1) {
|
||||
terrno = TSDB_CODE_MND_DNODE_NOT_EXIST;
|
||||
}
|
||||
|
|
|
@ -693,6 +693,9 @@ static int32_t mndRetrieveVgroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p
|
|||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppendNULL(pColInfo, numOfRows);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, numOfRows, (const char *)&pVgroup->cacheUsage, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppendNULL(pColInfo, numOfRows);
|
||||
|
||||
|
|
|
@ -155,6 +155,7 @@ int32_t tsdbGetTableSchema(SVnode *pVnode, int64_t uid, STSchema **pSchema, int6
|
|||
|
||||
void tsdbCacheSetCapacity(SVnode *pVnode, size_t capacity);
|
||||
size_t tsdbCacheGetCapacity(SVnode *pVnode);
|
||||
size_t tsdbCacheGetUsage(SVnode *pVnode);
|
||||
|
||||
// tq
|
||||
typedef struct SMetaTableInfo {
|
||||
|
|
|
@ -1334,3 +1334,5 @@ void tsdbCacheSetCapacity(SVnode *pVnode, size_t capacity) {
|
|||
}
|
||||
|
||||
size_t tsdbCacheGetCapacity(SVnode *pVnode) { return taosLRUCacheGetCapacity(pVnode->pTsdb->lruCache); }
|
||||
|
||||
size_t tsdbCacheGetUsage(SVnode *pVnode) { return taosLRUCacheGetUsage(pVnode->pTsdb->lruCache); }
|
||||
|
|
|
@ -368,6 +368,7 @@ _exit:
|
|||
int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) {
|
||||
pLoad->vgId = TD_VID(pVnode);
|
||||
pLoad->syncState = syncGetMyRole(pVnode->sync);
|
||||
pLoad->cacheUsage = tsdbCacheGetUsage(pVnode);
|
||||
pLoad->numOfTables = metaGetTbNum(pVnode->pMeta);
|
||||
pLoad->numOfTimeSeries = metaGetTimeSeriesNum(pVnode->pMeta);
|
||||
pLoad->totalStorage = (int64_t)3 * 1073741824;
|
||||
|
@ -424,8 +425,8 @@ int32_t vnodeGetCtbIdList(SVnode *pVnode, int64_t suid, SArray *list) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t vnodeGetStbIdList(SVnode* pVnode, int64_t suid, SArray* list) {
|
||||
SMStbCursor* pCur = metaOpenStbCursor(pVnode->pMeta, suid);
|
||||
int32_t vnodeGetStbIdList(SVnode *pVnode, int64_t suid, SArray *list) {
|
||||
SMStbCursor *pCur = metaOpenStbCursor(pVnode->pMeta, suid);
|
||||
if (!pCur) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
|
|
@ -510,6 +510,7 @@ int32_t tSerializeSMonVloadInfo(void *buf, int32_t bufLen, SMonVloadInfo *pInfo)
|
|||
SVnodeLoad *pLoad = taosArrayGet(pInfo->pVloads, i);
|
||||
if (tEncodeI32(&encoder, pLoad->vgId) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pLoad->syncState) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pLoad->cacheUsage) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pLoad->numOfTables) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pLoad->numOfTimeSeries) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pLoad->totalStorage) < 0) return -1;
|
||||
|
@ -544,6 +545,7 @@ int32_t tDeserializeSMonVloadInfo(void *buf, int32_t bufLen, SMonVloadInfo *pInf
|
|||
SVnodeLoad load = {0};
|
||||
if (tDecodeI32(&decoder, &load.vgId) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &load.syncState) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &load.cacheUsage) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &load.numOfTables) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &load.numOfTimeSeries) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &load.totalStorage) < 0) return -1;
|
||||
|
@ -594,7 +596,6 @@ int32_t tDeserializeSMonMloadInfo(void *buf, int32_t bufLen, SMonMloadInfo *pInf
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int32_t tSerializeSQnodeLoad(void *buf, int32_t bufLen, SQnodeLoad *pInfo) {
|
||||
SEncoder encoder = {0};
|
||||
tEncoderInit(&encoder, buf, bufLen);
|
||||
|
@ -639,5 +640,3 @@ int32_t tDeserializeSQnodeLoad(void *buf, int32_t bufLen, SQnodeLoad *pInfo) {
|
|||
tDecoderClear(&decoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue