diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 3bc73772676f8bf14b830bb7c41d32a8cd991ff5..37dccba175284effb4d88f9dc9cd9eae05fd4805 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -2798,7 +2798,6 @@ int32_t setKillInfo(SSqlObj* pSql, struct SSqlInfo* pInfo, int32_t killType) { } static int32_t setCompactVnodeInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { SSqlCmd* pCmd = &pSql->cmd; - //STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0); pCmd->command = pInfo->type; return TSDB_CODE_SUCCESS; diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 180dae0afb83caf1ebdea1f3ef484a283451809b..1c9b29ccf715d70d7615da2e22dec1fb58707d18 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -1575,7 +1575,7 @@ int tscBuildCompactMsg(SSqlObj *pSql, SSqlInfo *pInfo) { for (int32_t i = 0; i < size; i++) { tSqlExprItem* pSub = taosArrayGet(pList, i); tVariant* pVar = &pSub->pNode->value; - if (pVar->nType >= TSDB_DATA_TYPE_TINYINT && pVar->nType <= TSDB_DATA_TYPE_INT) { + if (pVar->nType >= TSDB_DATA_TYPE_TINYINT && pVar->nType <= TSDB_DATA_TYPE_BIGINT) { result[i] = (int32_t)(pVar->i64); } else { free(result); @@ -1603,7 +1603,7 @@ int tscBuildCompactMsg(SSqlObj *pSql, SSqlInfo *pInfo) { } else { tNameGetFullDbName(&pTableMetaInfo->name, pCompactMsg->db); } - + pCompactMsg->numOfVgroup = htons(count); for (int32_t i = 0; i < count; i++) { pCompactMsg->vgid[i] = htons(result[i]); diff --git a/src/dnode/src/dnodeShell.c b/src/dnode/src/dnodeShell.c index 50343cfd32405d5408cc9d6c5e939db30bf9b832..c80e1059b40b08b9eb592dc150974bef9746a1a9 100644 --- a/src/dnode/src/dnodeShell.c +++ b/src/dnode/src/dnodeShell.c @@ -61,6 +61,7 @@ int32_t dnodeInitShell() { dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_KILL_STREAM] = dnodeDispatchToMWriteQueue; dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_KILL_CONN] = dnodeDispatchToMWriteQueue; dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CONFIG_DNODE]= dnodeDispatchToMWriteQueue; + dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_COMPACT_VNODE]= dnodeDispatchToMWriteQueue; // the following message shall be treated as mnode query dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_HEARTBEAT] = dnodeDispatchToMReadQueue; diff --git a/src/mnode/src/mnodeDb.c b/src/mnode/src/mnodeDb.c index 9e064a2f9e3686bb9bde06916a832943665e5425..3c78a0e33daee4c8415f2621125e90f6cc06883d 100644 --- a/src/mnode/src/mnodeDb.c +++ b/src/mnode/src/mnodeDb.c @@ -1226,25 +1226,34 @@ static int32_t mnodeSyncDb(SDbObj *pDb, SMnodeMsg *pMsg) { static int32_t mnodeCompact(SDbObj *pDb, SCompactMsg *pCompactMsg) { - int32_t count = htonl(pCompactMsg->numOfVgroup); - int32_t *buf = malloc(sizeof(int32_t) * count); + int32_t count = ntohs(pCompactMsg->numOfVgroup); + int32_t *buf = malloc(sizeof(int32_t) * count); if (buf == NULL) { return TSDB_CODE_MND_OUT_OF_MEMORY; } for (int32_t i = 0; i < count; i++) { - buf[i] = htonl(pCompactMsg->vgid[i]); + buf[i] = ntohs(pCompactMsg->vgid[i]); } // copy from mnodeSyncDb, so ugly - void *pIter = NULL; - SVgObj *pVgroup = NULL; - while (1) { - pIter = mnodeGetNextVgroup(pIter, &pVgroup); - if (pVgroup == NULL) break; - if (pVgroup->pDb == pDb) { - mnodeSendCompactVgroupMsg(pVgroup); + for (int32_t i = 0; i < count; i++) { + SVgObj *pVgroup = NULL; + void *pIter = NULL; + bool valid = false; + while (1) { + pIter = mnodeGetNextVgroup(pIter, &pVgroup); + if (pVgroup == NULL) break; + if (pVgroup->pDb == pDb && pVgroup->vgId == buf[i]) { + mnodeSendCompactVgroupMsg(pVgroup); + mnodeDecVgroupRef(pVgroup); + valid = true; + break; + } + mnodeDecVgroupRef(pVgroup); + } + if (valid == false) { + mLError("db:%s, cannot find valid vgId: %d", pDb->name, buf[i]); } - mnodeDecVgroupRef(pVgroup); } free(buf); @@ -1279,6 +1288,7 @@ static int32_t mnodeProcessCompactMsg(SMnodeMsg *pMsg) { mDebug("db:%s, compact is received from thandle:%p", pCompact->db, pMsg->rpcMsg.handle); if (pMsg->pDb == NULL) pMsg->pDb = mnodeGetDb(pCompact->db); + if (pMsg->pDb == NULL) return TSDB_CODE_MND_DB_NOT_SELECTED; if (pMsg->pDb->status != TSDB_DB_STATUS_READY) { mError("db:%s, status:%d, in dropping, ignore compact request", pCompact->db, pMsg->pDb->status);