From b345312f8b9dba411ec63548c6779e3160aa5a54 Mon Sep 17 00:00:00 2001 From: slguan Date: Sat, 25 Apr 2020 16:20:18 +0800 Subject: [PATCH] [TD-147] --- src/inc/taosmsg.h | 1 - src/mnode/src/mgmtTable.c | 22 ++++++++++++++++++++-- src/vnode/src/vnodeWrite.c | 5 ++--- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index dd6dc52242..5f3ea93afb 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -345,7 +345,6 @@ typedef struct { } SMDDropTableMsg; typedef struct { - int32_t contLen; int32_t vgId; int64_t uid; char tableId[TSDB_TABLE_ID_LEN + 1]; diff --git a/src/mnode/src/mgmtTable.c b/src/mnode/src/mgmtTable.c index 0edb119724..1813be6522 100644 --- a/src/mnode/src/mgmtTable.c +++ b/src/mnode/src/mgmtTable.c @@ -756,8 +756,26 @@ static void mgmtProcessCreateSuperTableMsg(SQueuedMsg *pMsg) { static void mgmtProcessDropSuperTableMsg(SQueuedMsg *pMsg) { SSuperTableObj *pStable = (SSuperTableObj *)pMsg->pTable; if (pStable->numOfTables != 0) { - mError("stable:%s, numOfTables:%d not 0", pStable->info.tableId, pStable->numOfTables); - mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_OTHERS); + mgmtDropAllChildTablesInStable(pStable); + for (int32_t vg = 0; vg < pTable->vgLen; ++vg) { + int32_t vgId = pTable->vgList[vg]; + if (vgId == 0) break; + + SMDDropSTableMsg *pDrop = rpcMalloc(sizeof(SMDDropSTableMsg)); + pDrop->vgId = htonl(vgId); + pDrop->uid = htobe64(pStable->uid); + mgmtExtractTableName(pStable->info.tableId, pDrop->tableId); + + SVgObj *pVgroup = mgmtGetVgroup(vgId); + if (pVgroup != NULL) { + SRpcIpSet ipSet = mgmtGetIpSetFromVgroup(pVgroup); + SRpcMsg rpcMsg = {.pCont = pDrop, .contLen = sizeof(SMDDropSTableMsg), .msgType = TSDB_MSG_TYPE_MD_DROP_STABLE}; + mgmtSendMsgToDnode(&ipSet, &rpcMsg); + mgmtDecVgroupRef(pVgroup); + } + } + //mError("stable:%s, numOfTables:%d not 0", pStable->info.tableId, pStable->numOfTables); + //mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_OTHERS); } else { SSdbOper oper = { .type = SDB_OPER_GLOBAL, diff --git a/src/vnode/src/vnodeWrite.c b/src/vnode/src/vnodeWrite.c index 81cba7b6fa..26808f2e4e 100644 --- a/src/vnode/src/vnodeWrite.c +++ b/src/vnode/src/vnodeWrite.c @@ -224,11 +224,10 @@ static int32_t vnodeProcessDropStableMsg(SVnodeObj *pVnode, void *pCont, SRspRet int32_t code = 0; dTrace("pVnode:%p vgId:%d, stable:%s, start to drop", pVnode, pVnode->vgId, pTable->tableId); - // int64_t uid = htobe64(pTable->uid); - // TODO: drop stable in vvnode + //int64_t uid = htobe64(pTable->uid); //void *pTsdb = dnodeGetVnodeTsdb(pMsg->pVnode); - //rpcRsp.code = tsdbDropSTable(pTsdb, pTable->uid); + //rpcRsp.code = tsdbDropTable(pTsdb, pTable->uid); code = TSDB_CODE_SUCCESS; dTrace("pVnode:%p vgId:%d, stable:%s, drop stable result:%x", pVnode, pTable->tableId, code); -- GitLab