enh: timeseries calculation
This commit is contained in:
parent
e50b8a3a0d
commit
986788d4fe
|
@ -173,11 +173,11 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
|
||||||
void dmSendNotifyReq(SDnodeMgmt *pMgmt) {
|
void dmSendNotifyReq(SDnodeMgmt *pMgmt) {
|
||||||
SNotifyReq req = {0};
|
SNotifyReq req = {0};
|
||||||
|
|
||||||
// taosThreadRwlockRdlock(&pMgmt->pData->lock);
|
taosThreadRwlockRdlock(&pMgmt->pData->lock);
|
||||||
// req.dnodeId = pMgmt->pData->dnodeId;
|
req.dnodeId = pMgmt->pData->dnodeId;
|
||||||
// taosThreadRwlockUnlock(&pMgmt->pData->lock);
|
taosThreadRwlockUnlock(&pMgmt->pData->lock);
|
||||||
|
|
||||||
// req.clusterId = pMgmt->pData->clusterId;
|
req.clusterId = pMgmt->pData->clusterId;
|
||||||
|
|
||||||
SMonVloadInfo vinfo = {0};
|
SMonVloadInfo vinfo = {0};
|
||||||
(*pMgmt->getVnodeLoadsLiteFp)(&vinfo);
|
(*pMgmt->getVnodeLoadsLiteFp)(&vinfo);
|
||||||
|
|
|
@ -1531,8 +1531,8 @@ int32_t metaGetStbStats(void *pVnode, int64_t uid, int64_t *numOfTables, int32_t
|
||||||
metaULock(pVnodeObj->pMeta);
|
metaULock(pVnodeObj->pMeta);
|
||||||
if (numOfTables) *numOfTables = state.ctbNum;
|
if (numOfTables) *numOfTables = state.ctbNum;
|
||||||
if (numOfCols) *numOfCols = state.colNum;
|
if (numOfCols) *numOfCols = state.colNum;
|
||||||
assert(state.colNum > 0);
|
ASSERTS(state.colNum > 0, "vgId:%d, suid:%" PRIi64 " nCols:%d <= 0 in metaCache", TD_VID(pVnodeObj), uid,
|
||||||
assert(state.ctbNum >= 0);
|
state.colNum);
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -423,7 +423,7 @@ _exit:
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
tdbTbcClose(pTbDbc);
|
tdbTbcClose(pTbDbc);
|
||||||
tdbTbcClose(pUidIdxc);
|
tdbTbcClose(pUidIdxc);
|
||||||
return ret;
|
return 0;
|
||||||
}
|
}
|
||||||
int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
SMetaEntry oStbEntry = {0};
|
SMetaEntry oStbEntry = {0};
|
||||||
|
@ -850,8 +850,8 @@ int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq, SArray *tbUi
|
||||||
void *pData = NULL;
|
void *pData = NULL;
|
||||||
int nData = 0;
|
int nData = 0;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
tb_uid_t uid;
|
tb_uid_t uid = 0;
|
||||||
tb_uid_t suid;
|
tb_uid_t suid = 0;
|
||||||
int type;
|
int type;
|
||||||
|
|
||||||
rc = tdbTbGet(pMeta->pNameIdx, pReq->name, strlen(pReq->name) + 1, &pData, &nData);
|
rc = tdbTbGet(pMeta->pNameIdx, pReq->name, strlen(pReq->name) + 1, &pData, &nData);
|
||||||
|
@ -891,38 +891,40 @@ _exit:
|
||||||
void metaDropTables(SMeta *pMeta, SArray *tbUids) {
|
void metaDropTables(SMeta *pMeta, SArray *tbUids) {
|
||||||
if (taosArrayGetSize(tbUids) == 0) return;
|
if (taosArrayGetSize(tbUids) == 0) return;
|
||||||
|
|
||||||
int64_t ctbNum = 0;
|
int64_t nCtbDropped = 0;
|
||||||
SSHashObj *suidHash = tSimpleHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT));
|
SSHashObj *suidHash = tSimpleHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT));
|
||||||
|
|
||||||
metaWLock(pMeta);
|
metaWLock(pMeta);
|
||||||
for (int i = 0; i < taosArrayGetSize(tbUids); ++i) {
|
for (int i = 0; i < taosArrayGetSize(tbUids); ++i) {
|
||||||
tb_uid_t uid = *(tb_uid_t *)taosArrayGet(tbUids, i);
|
tb_uid_t uid = *(tb_uid_t *)taosArrayGet(tbUids, i);
|
||||||
tb_uid_t suid = 0;
|
tb_uid_t suid = 0;
|
||||||
metaDropTableByUid(pMeta, uid, NULL, &suid);
|
int type;
|
||||||
if (suid != 0 && suidHash) {
|
metaDropTableByUid(pMeta, uid, &type, &suid);
|
||||||
int64_t *cnt = tSimpleHashGet(suidHash, &suid, sizeof(tb_uid_t));
|
if (type == TSDB_CHILD_TABLE && suid != 0 && suidHash) {
|
||||||
if (cnt) {
|
int64_t *pVal = tSimpleHashGet(suidHash, &suid, sizeof(tb_uid_t));
|
||||||
ctbNum = *cnt + 1;
|
if (pVal) {
|
||||||
|
nCtbDropped = *pVal + 1;
|
||||||
} else {
|
} else {
|
||||||
ctbNum = 1;
|
nCtbDropped = 1;
|
||||||
}
|
}
|
||||||
tSimpleHashPut(suidHash, &suid, sizeof(tb_uid_t), &ctbNum, sizeof(int64_t));
|
tSimpleHashPut(suidHash, &suid, sizeof(tb_uid_t), &nCtbDropped, sizeof(int64_t));
|
||||||
}
|
}
|
||||||
metaDebug("batch drop table:%" PRId64, uid);
|
metaDebug("batch drop table:%" PRId64, uid);
|
||||||
}
|
}
|
||||||
metaULock(pMeta);
|
metaULock(pMeta);
|
||||||
|
|
||||||
// update timeseries
|
// update timeseries
|
||||||
void *pCtbNum = NULL;
|
void *pCtbDropped = NULL;
|
||||||
int32_t iter = 0;
|
int32_t iter = 0;
|
||||||
while ((pCtbNum = tSimpleHashIterate(suidHash, pCtbNum, &iter))) {
|
while ((pCtbDropped = tSimpleHashIterate(suidHash, pCtbDropped, &iter))) {
|
||||||
tb_uid_t *pSuid = tSimpleHashGetKey(pCtbNum, NULL);
|
tb_uid_t *pSuid = tSimpleHashGetKey(pCtbDropped, NULL);
|
||||||
int32_t nCols = 0;
|
int32_t nCols = 0;
|
||||||
SVnodeStats *pStats = &pMeta->pVnode->config.vndStats;
|
SVnodeStats *pStats = &pMeta->pVnode->config.vndStats;
|
||||||
if (metaGetStbStats(pMeta->pVnode, *pSuid, NULL, &nCols) == 0) {
|
if (metaGetStbStats(pMeta->pVnode, *pSuid, NULL, &nCols) == 0) {
|
||||||
pStats->numOfTimeSeries -= *(int64_t *)pCtbNum * (nCols - 1);
|
pStats->numOfTimeSeries -= *(int64_t *)pCtbDropped * (nCols - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
tSimpleHashCleanup(suidHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t metaFilterTableByHash(SMeta *pMeta, SArray *uidList) {
|
static int32_t metaFilterTableByHash(SMeta *pMeta, SArray *uidList) {
|
||||||
|
|
Loading…
Reference in New Issue