From 0b1cab6cc60e3fc1c152437e0f2ef9c4cd951b4b Mon Sep 17 00:00:00 2001 From: slguan Date: Sat, 9 May 2020 22:08:41 +0800 Subject: [PATCH] fix bug while drop sdb --- src/dnode/src/dnodeVWrite.c | 2 +- src/inc/taosmsg.h | 1 + src/mnode/src/mgmtTable.c | 49 ++++++++++++++++++++----------------- src/vnode/src/vnodeMain.c | 2 +- 4 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/dnode/src/dnodeVWrite.c b/src/dnode/src/dnodeVWrite.c index 147d2bdfbb..5de4c16c50 100644 --- a/src/dnode/src/dnodeVWrite.c +++ b/src/dnode/src/dnodeVWrite.c @@ -85,7 +85,7 @@ void dnodeCleanupWrite() { void dnodeDispatchToVnodeWriteQueue(SRpcMsg *pMsg) { char *pCont = (char *)pMsg->pCont; - if (pMsg->msgType == TSDB_MSG_TYPE_SUBMIT || pMsg->msgType == TSDB_MSG_TYPE_MD_DROP_STABLE) { + if (pMsg->msgType == TSDB_MSG_TYPE_SUBMIT) { SMsgDesc *pDesc = (SMsgDesc *)pCont; pDesc->numOfVnodes = htonl(pDesc->numOfVnodes); pCont += sizeof(SMsgDesc); diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index c359ede22e..8dac73606d 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -326,6 +326,7 @@ 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 2225e08f58..bfe357cf7c 100644 --- a/src/mnode/src/mgmtTable.c +++ b/src/mnode/src/mgmtTable.c @@ -701,10 +701,10 @@ static void mgmtProcessDropTableMsg(SQueuedMsg *pMsg) { } if (pMsg->pTable->type == TSDB_SUPER_TABLE) { - mTrace("table:%s, start to drop stable", pDrop->tableId); + mPrint("table:%s, start to drop stable", pDrop->tableId); mgmtProcessDropSuperTableMsg(pMsg); } else { - mTrace("table:%s, start to drop ctable", pDrop->tableId); + mPrint("table:%s, start to drop ctable", pDrop->tableId); mgmtProcessDropChildTableMsg(pMsg); } } @@ -802,29 +802,32 @@ static void mgmtProcessDropSuperTableMsg(SQueuedMsg *pMsg) { int32_t vgId = pStable->vgList[vg]; if (vgId == 0) break; + SVgObj *pVgroup = mgmtGetVgroup(vgId); + if (pVgroup == NULL) break; + SMDDropSTableMsg *pDrop = rpcMallocCont(sizeof(SMDDropSTableMsg)); + pDrop->contLen = htonl(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}; - dnodeSendMsgToDnode(&ipSet, &rpcMsg); - mgmtDecVgroupRef(pVgroup); - } + + mPrint("stable:%s, send drop stable msg to vgId:%d", pStable->info.tableId, vgId); + SRpcIpSet ipSet = mgmtGetIpSetFromVgroup(pVgroup); + SRpcMsg rpcMsg = {.pCont = pDrop, .contLen = sizeof(SMDDropSTableMsg), .msgType = TSDB_MSG_TYPE_MD_DROP_STABLE}; + dnodeSendMsgToDnode(&ipSet, &rpcMsg); + mgmtDecVgroupRef(pVgroup); } - } else { - SSdbOper oper = { - .type = SDB_OPER_GLOBAL, - .table = tsSuperTableSdb, - .pObj = pStable - }; - int32_t code = sdbDeleteRow(&oper); - mLPrint("stable:%s, is dropped from sdb, result:%s", pStable->info.tableId, tstrerror(code)); - mgmtSendSimpleResp(pMsg->thandle, code); - } + } + + SSdbOper oper = { + .type = SDB_OPER_GLOBAL, + .table = tsSuperTableSdb, + .pObj = pStable + }; + + int32_t code = sdbDeleteRow(&oper); + mLPrint("stable:%s, is dropped from sdb, result:%s", pStable->info.tableId, tstrerror(code)); + mgmtSendSimpleResp(pMsg->thandle, code); } static int32_t mgmtFindSuperTableTagIndex(SSuperTableObj *pStable, const char *tagName) { @@ -1303,7 +1306,7 @@ static void mgmtProcessSuperTableVgroupMsg(SQueuedMsg *pMsg) { } static void mgmtProcessDropSuperTableRsp(SRpcMsg *rpcMsg) { - mTrace("drop stable rsp received, handle:%p code:%s", rpcMsg->handle, tstrerror(rpcMsg->code)); + mPrint("drop stable rsp received, result:%s", tstrerror(rpcMsg->code)); } static void *mgmtBuildCreateChildTableMsg(SCMCreateTableMsg *pMsg, SChildTableObj *pTable) { @@ -1540,7 +1543,7 @@ static void mgmtProcessDropChildTableMsg(SQueuedMsg *pMsg) { SRpcIpSet ipSet = mgmtGetIpSetFromVgroup(pMsg->pVgroup); - mTrace("table:%s, send drop ctable msg", pDrop->tableId); + mPrint("table:%s, send drop ctable msg", pDrop->tableId); SQueuedMsg *newMsg = mgmtCloneQueuedMsg(pMsg); newMsg->ahandle = pMsg->pTable; SRpcMsg rpcMsg = { @@ -1867,7 +1870,7 @@ static void mgmtProcessDropChildTableRsp(SRpcMsg *rpcMsg) { queueMsg->received++; SChildTableObj *pTable = queueMsg->ahandle; - mTrace("table:%s, drop table rsp received, thandle:%p result:%s", pTable->info.tableId, queueMsg->thandle, tstrerror(rpcMsg->code)); + mPrint("table:%s, drop table rsp received, thandle:%p result:%s", pTable->info.tableId, queueMsg->thandle, tstrerror(rpcMsg->code)); if (rpcMsg->code != TSDB_CODE_SUCCESS) { mError("table:%s, failed to drop in dnode, reason:%s", pTable->info.tableId, tstrerror(rpcMsg->code)); diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index 6ffac08b4e..16845812bf 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -301,7 +301,7 @@ void *vnodeGetVnode(int32_t vgId) { SVnodeObj **ppVnode = (SVnodeObj **)taosGetIntHashData(tsDnodeVnodesHash, vgId); if (ppVnode == NULL || *ppVnode == NULL) { terrno = TSDB_CODE_INVALID_VGROUP_ID; - vPrint("vgId:%d not exist", vgId); + vPrint("vgId:%d, not exist", vgId); return NULL; } -- GitLab