diff --git a/src/mnode/src/mnodeSdb.c b/src/mnode/src/mnodeSdb.c index d8fc9aee5a680913ce52753214cac27b225033ab..c0c5b9df3021dea4da94a8d64a338b1390be44c8 100644 --- a/src/mnode/src/mnodeSdb.c +++ b/src/mnode/src/mnodeSdb.c @@ -389,7 +389,7 @@ void sdbIncRef(void *handle, void *pObj) { SSdbTable *pTable = handle; int32_t * pRefCount = (int32_t *)(pObj + pTable->refCountPos); atomic_add_fetch_32(pRefCount, 1); - if (0 && (pTable->tableId == SDB_TABLE_CTABLE || pTable->tableId == SDB_TABLE_DB)) { + if (1) { sdbTrace("add ref to table:%s record:%p:%s:%d", pTable->tableName, pObj, sdbGetKeyStrFromObj(pTable, pObj), *pRefCount); } } @@ -400,7 +400,7 @@ 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); - if (0 && (pTable->tableId == SDB_TABLE_CTABLE || pTable->tableId == SDB_TABLE_DB)) { + if (1) { sdbTrace("def ref of table:%s record:%p:%s:%d", pTable->tableName, pObj, sdbGetKeyStrFromObj(pTable, pObj), *pRefCount); } diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index a421b01d7a04f049472e9a8c8486fbd89eea67e0..a30b359970adb40f8fce1777d9a96fed10dcf6ce 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -185,7 +185,9 @@ static int32_t mnodeChildTableActionUpdate(SSdbOper *pOper) { void *oldTableId = pTable->info.tableId; void *oldSql = pTable->sql; void *oldSchema = pTable->schema; + int32_t oldRefCount = pTable->refCount; memcpy(pTable, pNew, sizeof(SChildTableObj)); + pTable->refCount = oldRefCount; pTable->sql = pNew->sql; pTable->schema = pNew->schema; free(pNew); @@ -375,7 +377,7 @@ static void mnodeAddTableIntoStable(SSuperTableObj *pStable, SChildTableObj *pCt pStable->numOfTables++; if (pStable->vgHash == NULL) { - pStable->vgHash = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false); + pStable->vgHash = taosHashInit(100000, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false); } if (pStable->vgHash != NULL) { @@ -439,9 +441,14 @@ static int32_t mnodeSuperTableActionUpdate(SSdbOper *pOper) { if (pTable != pNew) { void *oldTableId = pTable->info.tableId; void *oldSchema = pTable->schema; + void *oldVgHash = pTable->vgHash; + int32_t oldRefCount = pTable->refCount; + memcpy(pTable, pNew, sizeof(SSuperTableObj)); + + pTable->vgHash = oldVgHash; + pTable->refCount = oldRefCount; pTable->schema = pNew->schema; - free(pNew->vgHash); free(pNew); free(oldTableId); free(oldSchema);