From 364ff9634764bf7e3c080815286ca10db8421ba9 Mon Sep 17 00:00:00 2001 From: slguan Date: Thu, 30 Apr 2020 23:27:32 +0800 Subject: [PATCH] [TD-147] fix invalid write in drop vgroup --- src/mnode/src/mgmtDb.c | 19 +++++++++++++++++++ src/mnode/src/mgmtVgroup.c | 7 ++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/mnode/src/mgmtDb.c b/src/mnode/src/mgmtDb.c index ae241f2320..3e7577af06 100644 --- a/src/mnode/src/mgmtDb.c +++ b/src/mnode/src/mgmtDb.c @@ -351,8 +351,27 @@ bool mgmtCheckIsMonitorDB(char *db, char *monitordb) { return (strncasecmp(dbName, monitordb, len) == 0 && len == strlen(monitordb)); } +#if 0 +void mgmtPrintVgroups(SDbObj *pDb, char *oper) { + mPrint("db:%s, vgroup link from head, oper:%s", pDb->name, oper); + SVgObj *pVgroup = pDb->pHead; + while (pVgroup != NULL) { + mPrint("vgId:%d", pVgroup->vgId); + pVgroup = pVgroup->next; + } + + mPrint("db:%s, vgroup link from tail", pDb->name, pDb->numOfVgroups); + pVgroup = pDb->pTail; + while (pVgroup != NULL) { + mPrint("vgId:%d", pVgroup->vgId); + pVgroup = pVgroup->prev; + } +} +#endif + void mgmtAddVgroupIntoDb(SVgObj *pVgroup) { SDbObj *pDb = pVgroup->pDb; + pVgroup->next = pDb->pHead; pVgroup->prev = NULL; diff --git a/src/mnode/src/mgmtVgroup.c b/src/mnode/src/mgmtVgroup.c index d2580fc4ca..839dce5c38 100644 --- a/src/mnode/src/mgmtVgroup.c +++ b/src/mnode/src/mgmtVgroup.c @@ -516,7 +516,7 @@ void mgmtAddTableIntoVgroup(SVgObj *pVgroup, SChildTableObj *pTable) { } if (pVgroup->numOfTables >= pVgroup->pDb->cfg.maxTables) { - mgmtAddVgroupIntoDbTail(pVgroup); + mgmtMoveVgroupToTail(pVgroup); } mgmtIncVgroupRef(pVgroup); @@ -529,10 +529,7 @@ void mgmtRemoveTableFromVgroup(SVgObj *pVgroup, SChildTableObj *pTable) { pVgroup->numOfTables--; } - if (pVgroup->numOfTables == 0) { - mgmtRemoveVgroupFromDb(pVgroup); - } - + mgmtMoveVgroupToHead(pVgroup); mgmtDecVgroupRef(pVgroup); } -- GitLab