未验证 提交 c35e6aa3 编写于 作者: X Xiaoyu Wang 提交者: GitHub

Merge pull request #20842 from taosdata/fix/hash-ref-count-high

add cancel in fetch cluster
...@@ -67,7 +67,7 @@ int32_t mndGetClusterName(SMnode *pMnode, char *clusterName, int32_t len) { ...@@ -67,7 +67,7 @@ int32_t mndGetClusterName(SMnode *pMnode, char *clusterName, int32_t len) {
return 0; return 0;
} }
static SClusterObj *mndAcquireCluster(SMnode *pMnode) { static SClusterObj *mndAcquireCluster(SMnode *pMnode, void **ppIter) {
SSdb *pSdb = pMnode->pSdb; SSdb *pSdb = pMnode->pSdb;
void *pIter = NULL; void *pIter = NULL;
...@@ -76,23 +76,27 @@ static SClusterObj *mndAcquireCluster(SMnode *pMnode) { ...@@ -76,23 +76,27 @@ static SClusterObj *mndAcquireCluster(SMnode *pMnode) {
pIter = sdbFetch(pSdb, SDB_CLUSTER, pIter, (void **)&pCluster); pIter = sdbFetch(pSdb, SDB_CLUSTER, pIter, (void **)&pCluster);
if (pIter == NULL) break; if (pIter == NULL) break;
*ppIter = pIter;
return pCluster; return pCluster;
} }
return NULL; return NULL;
} }
static void mndReleaseCluster(SMnode *pMnode, SClusterObj *pCluster) { static void mndReleaseCluster(SMnode *pMnode, SClusterObj *pCluster, void *pIter) {
SSdb *pSdb = pMnode->pSdb; SSdb *pSdb = pMnode->pSdb;
sdbCancelFetch(pSdb, pIter);
sdbRelease(pSdb, pCluster); sdbRelease(pSdb, pCluster);
} }
int64_t mndGetClusterId(SMnode *pMnode) { int64_t mndGetClusterId(SMnode *pMnode) {
int64_t clusterId = 0; int64_t clusterId = 0;
SClusterObj *pCluster = mndAcquireCluster(pMnode); void *pIter = NULL;
SClusterObj *pCluster = mndAcquireCluster(pMnode, &pIter);
if (pCluster != NULL) { if (pCluster != NULL) {
clusterId = pCluster->id; clusterId = pCluster->id;
mndReleaseCluster(pMnode, pCluster); mndReleaseCluster(pMnode, pCluster, pIter);
} }
return clusterId; return clusterId;
...@@ -100,10 +104,11 @@ int64_t mndGetClusterId(SMnode *pMnode) { ...@@ -100,10 +104,11 @@ int64_t mndGetClusterId(SMnode *pMnode) {
int64_t mndGetClusterCreateTime(SMnode *pMnode) { int64_t mndGetClusterCreateTime(SMnode *pMnode) {
int64_t createTime = 0; int64_t createTime = 0;
SClusterObj *pCluster = mndAcquireCluster(pMnode); void *pIter = NULL;
SClusterObj *pCluster = mndAcquireCluster(pMnode, &pIter);
if (pCluster != NULL) { if (pCluster != NULL) {
createTime = pCluster->createdTime; createTime = pCluster->createdTime;
mndReleaseCluster(pMnode, pCluster); mndReleaseCluster(pMnode, pCluster, pIter);
} }
return createTime; return createTime;
...@@ -121,10 +126,11 @@ static int32_t mndGetClusterUpTimeImp(SClusterObj *pCluster) { ...@@ -121,10 +126,11 @@ static int32_t mndGetClusterUpTimeImp(SClusterObj *pCluster) {
float mndGetClusterUpTime(SMnode *pMnode) { float mndGetClusterUpTime(SMnode *pMnode) {
int64_t upTime = 0; int64_t upTime = 0;
SClusterObj *pCluster = mndAcquireCluster(pMnode); void *pIter = NULL;
SClusterObj *pCluster = mndAcquireCluster(pMnode, &pIter);
if (pCluster != NULL) { if (pCluster != NULL) {
upTime = mndGetClusterUpTimeImp(pCluster); upTime = mndGetClusterUpTimeImp(pCluster);
mndReleaseCluster(pMnode, pCluster); mndReleaseCluster(pMnode, pCluster, pIter);
} }
return upTime / 86400.0f; return upTime / 86400.0f;
...@@ -321,11 +327,12 @@ static void mndCancelGetNextCluster(SMnode *pMnode, void *pIter) { ...@@ -321,11 +327,12 @@ static void mndCancelGetNextCluster(SMnode *pMnode, void *pIter) {
static int32_t mndProcessUptimeTimer(SRpcMsg *pReq) { static int32_t mndProcessUptimeTimer(SRpcMsg *pReq) {
SMnode *pMnode = pReq->info.node; SMnode *pMnode = pReq->info.node;
SClusterObj clusterObj = {0}; SClusterObj clusterObj = {0};
SClusterObj *pCluster = mndAcquireCluster(pMnode); void *pIter = NULL;
SClusterObj *pCluster = mndAcquireCluster(pMnode, &pIter);
if (pCluster != NULL) { if (pCluster != NULL) {
memcpy(&clusterObj, pCluster, sizeof(SClusterObj)); memcpy(&clusterObj, pCluster, sizeof(SClusterObj));
clusterObj.upTime += tsUptimeInterval; clusterObj.upTime += tsUptimeInterval;
mndReleaseCluster(pMnode, pCluster); mndReleaseCluster(pMnode, pCluster, pIter);
} }
if (clusterObj.id <= 0) { if (clusterObj.id <= 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册