From 835a7f440b7d55dcd0080ee2fe0de1b9cc64d159 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 29 Jul 2020 18:57:06 +0800 Subject: [PATCH] [TD-997] --- src/mnode/src/mnodeSdb.c | 8 ++++---- src/mnode/src/mnodeTable.c | 8 +++++--- src/mnode/src/mnodeVgroup.c | 10 +++++----- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/mnode/src/mnodeSdb.c b/src/mnode/src/mnodeSdb.c index 374430879d..f3f6e33431 100644 --- a/src/mnode/src/mnodeSdb.c +++ b/src/mnode/src/mnodeSdb.c @@ -414,8 +414,8 @@ void sdbIncRef(void *handle, void *pObj) { SSdbTable *pTable = handle; int32_t * pRefCount = (int32_t *)(pObj + pTable->refCountPos); - atomic_add_fetch_32(pRefCount, 1); - sdbTrace("add ref to table:%s record:%p:%s:%d", pTable->tableName, pObj, sdbGetKeyStrFromObj(pTable, pObj), *pRefCount); + int32_t refCount = atomic_add_fetch_32(pRefCount, 1); + sdbTrace("add ref to table:%s record:%p:%s:%d", pTable->tableName, pObj, sdbGetKeyStrFromObj(pTable, pObj), refCount); } void sdbDecRef(void *handle, void *pObj) { @@ -424,11 +424,11 @@ void sdbDecRef(void *handle, void *pObj) { SSdbTable *pTable = handle; int32_t * pRefCount = (int32_t *)(pObj + pTable->refCountPos); int32_t refCount = atomic_sub_fetch_32(pRefCount, 1); - sdbTrace("def ref of table:%s record:%p:%s:%d", pTable->tableName, pObj, sdbGetKeyStrFromObj(pTable, pObj), *pRefCount); + sdbTrace("def ref of table:%s record:%p:%s:%d", pTable->tableName, pObj, sdbGetKeyStrFromObj(pTable, pObj), refCount); int32_t *updateEnd = pObj + pTable->refCountPos - 4; if (refCount <= 0 && *updateEnd) { - sdbTrace("table:%s, record:%p:%s:%d is destroyed", pTable->tableName, pObj, sdbGetKeyStrFromObj(pTable, pObj), *pRefCount); + sdbTrace("table:%s, record:%p:%s:%d is destroyed", pTable->tableName, pObj, sdbGetKeyStrFromObj(pTable, pObj), refCount); SSdbOper oper = {.pObj = pObj}; (*pTable->destroyFp)(&oper); } diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index df80fb1c47..009633b43b 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -128,9 +128,11 @@ static int32_t mnodeChildTableActionInsert(SSdbOper *pOper) { if (pTable->info.type == TSDB_CHILD_TABLE) { // add ref pTable->superTable = mnodeGetSuperTableByUid(pTable->suid); - mnodeAddTableIntoStable(pTable->superTable, pTable); - grantAdd(TSDB_GRANT_TIMESERIES, pTable->superTable->numOfColumns - 1); - if (pAcct) pAcct->acctInfo.numOfTimeSeries += (pTable->superTable->numOfColumns - 1); + if (pTable->superTable != NULL) { + mnodeAddTableIntoStable(pTable->superTable, pTable); + grantAdd(TSDB_GRANT_TIMESERIES, pTable->superTable->numOfColumns - 1); + if (pAcct) pAcct->acctInfo.numOfTimeSeries += (pTable->superTable->numOfColumns - 1); + } } else { grantAdd(TSDB_GRANT_TIMESERIES, pTable->numOfColumns - 1); if (pAcct) pAcct->acctInfo.numOfTimeSeries += (pTable->numOfColumns - 1); diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index df5df8c94a..0c7a76fd0d 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -535,6 +535,10 @@ int32_t mnodeCreateVgroup(SMnodeMsg *pMsg) { return TSDB_CODE_MND_NO_ENOUGH_DNODES; } + if (pMsg->pVgroup != NULL) { + mnodeDecVgroupRef(pMsg->pVgroup); + } + pMsg->pVgroup = pVgroup; mnodeIncVgroupRef(pVgroup); @@ -922,11 +926,7 @@ static void mnodeProcessCreateVnodeRsp(SRpcMsg *rpcMsg) { .table = tsVgroupSdb, .pObj = pVgroup }; - int32_t code = sdbDeleteRow(&oper); - if (code != 0) { - code = TSDB_CODE_MND_SDB_ERROR; - } - + sdbDeleteRow(&oper); dnodeSendRpcMnodeWriteRsp(mnodeMsg, mnodeMsg->code); } } -- GitLab