diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c
index 111ebc4e8c690cef9c52ea214dacde0cf5d58dfd..8b896fb90e42006c1382a84535bd18d6374c7c65 100644
--- a/src/client/src/tscServer.c
+++ b/src/client/src/tscServer.c
@@ -1065,7 +1065,7 @@ int32_t tscBuildDropDnodeMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
return TSDB_CODE_SUCCESS;
}
-int32_t tscBuildDropAcctMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
+int32_t tscBuildDropUserMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
SSqlCmd *pCmd = &pSql->cmd;
pCmd->payloadLen = sizeof(SCMDropUserMsg);
pCmd->msgType = TSDB_MSG_TYPE_CM_DROP_USER;
@@ -1082,6 +1082,23 @@ int32_t tscBuildDropAcctMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
return TSDB_CODE_SUCCESS;
}
+int32_t tscBuildDropAcctMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
+ SSqlCmd *pCmd = &pSql->cmd;
+ pCmd->payloadLen = sizeof(SCMDropUserMsg);
+ pCmd->msgType = TSDB_MSG_TYPE_CM_DROP_ACCT;
+
+ if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, pCmd->payloadLen)) {
+ tscError("%p failed to malloc for query msg", pSql);
+ return TSDB_CODE_CLI_OUT_OF_MEMORY;
+ }
+
+ SCMDropUserMsg *pDropMsg = (SCMDropUserMsg*)pCmd->payload;
+ STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
+ strcpy(pDropMsg->user, pTableMetaInfo->name);
+
+ return TSDB_CODE_SUCCESS;
+}
+
int32_t tscBuildUseDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
SSqlCmd *pCmd = &pSql->cmd;
pCmd->payloadLen = sizeof(SCMUseDbMsg);
@@ -2550,7 +2567,7 @@ void tscInitMsgsFp() {
tscBuildMsg[TSDB_SQL_ALTER_ACCT] = tscBuildAcctMsg;
tscBuildMsg[TSDB_SQL_CREATE_TABLE] = tscBuildCreateTableMsg;
- tscBuildMsg[TSDB_SQL_DROP_USER] = tscBuildDropAcctMsg;
+ tscBuildMsg[TSDB_SQL_DROP_USER] = tscBuildDropUserMsg;
tscBuildMsg[TSDB_SQL_DROP_ACCT] = tscBuildDropAcctMsg;
tscBuildMsg[TSDB_SQL_DROP_DB] = tscBuildDropDbMsg;
tscBuildMsg[TSDB_SQL_DROP_TABLE] = tscBuildDropTableMsg;
diff --git a/src/dnode/src/dnodeMgmt.c b/src/dnode/src/dnodeMgmt.c
index 4d335d73534b452b71753b63d6d1b814b0df674b..1ffcf94ccda410b4f18b21b3687cf5f7f61dc0d6 100644
--- a/src/dnode/src/dnodeMgmt.c
+++ b/src/dnode/src/dnodeMgmt.c
@@ -30,24 +30,24 @@
#include "dnodeWrite.h"
typedef struct {
- int32_t vgId; // global vnode group ID
- int32_t refCount; // reference count
- int8_t dirty;
- int8_t status; // status: master, slave, notready, deleting
- int64_t version;
- void *wworker;
- void *rworker;
- void *wal;
- void *tsdb;
- void *replica;
- void *events;
- void *cq; // continuous query
+ int32_t vgId; // global vnode group ID
+ int32_t refCount; // reference count
+ EVnodeStatus status; // status: master, slave, notready, deleting
+ int64_t version;
+ void * wworker;
+ void * rworker;
+ void * wal;
+ void * tsdb;
+ void * replica;
+ void * events;
+ void * cq; // continuous query
} SVnodeObj;
static int32_t dnodeOpenVnodes();
static void dnodeCleanupVnodes();
static int32_t dnodeOpenVnode(int32_t vnode, char *rootDir);
static void dnodeCleanupVnode(SVnodeObj *pVnode);
+static void dnodeDoCleanupVnode(SVnodeObj *pVnode);
static int32_t dnodeCreateVnode(SMDCreateVnodeMsg *cfg);
static void dnodeDropVnode(SVnodeObj *pVnode);
static void dnodeDoDropVnode(SVnodeObj *pVnode);
@@ -89,9 +89,14 @@ int32_t dnodeInitMgmt() {
dError("failed to init dnode timer");
return -1;
}
- taosTmrReset(dnodeSendStatusMsg, 500, NULL, tsDnodeTmr, &tsStatusTimer);
+
+ int32_t code = dnodeOpenVnodes();
+ if (code != TSDB_CODE_SUCCESS) {
+ return -1;
+ }
- return dnodeOpenVnodes();
+ taosTmrReset(dnodeSendStatusMsg, 500, NULL, tsDnodeTmr, &tsStatusTimer);
+ return TSDB_CODE_SUCCESS;
}
void dnodeCleanupMgmt() {
@@ -141,6 +146,8 @@ void *dnodeGetVnode(int32_t vgId) {
}
atomic_add_fetch_32(&pVnode->refCount, 1);
+ dTrace("pVnode:%p, vgroup:%d, get vnode, refCount:%d", pVnode, pVnode->vgId, pVnode->refCount);
+
return pVnode;
}
@@ -166,10 +173,24 @@ void *dnodeGetVnodeTsdb(void *pVnode) {
void dnodeReleaseVnode(void *pVnodeRaw) {
SVnodeObj *pVnode = pVnodeRaw;
- int32_t count = atomic_sub_fetch_32(&pVnode->refCount, 1);
- if (count == 0 && pVnode->dirty) {
- dnodeDoDropVnode(pVnode);
+ int32_t refCount = atomic_sub_fetch_32(&pVnode->refCount, 1);
+ if (pVnode->status == TSDB_VN_STATUS_DELETING) {
+ if (refCount <= 0) {
+ dPrint("pVnode:%p, vgroup:%d, drop vnode, refCount:%d", pVnode, pVnode->vgId, refCount);
+ dnodeDoDropVnode(pVnode);
+ } else {
+ dTrace("pVnode:%p, vgroup:%d, vnode will be dropped until refCount:%d is 0", pVnode, pVnode->vgId, refCount);
+ }
+ } else if (pVnode->status == TSDB_VN_STATUS_CLOSING) {
+ if (refCount <= 0) {
+ dPrint("pVnode:%p, vgroup:%d, cleanup vnode, refCount:%d", pVnode, pVnode->vgId, refCount);
+ dnodeDoCleanupVnode(pVnode);
+ } else {
+ dTrace("pVnode:%p, vgroup:%d, vnode will cleanup until refCount:%d is 0", pVnode, pVnode->vgId, refCount);
+ }
+ } else {
+ dTrace("pVnode:%p, vgroup:%d, release vnode, refCount:%d", pVnode, pVnode->vgId, refCount);
}
}
@@ -210,42 +231,42 @@ static void dnodeCleanupVnodes() {
}
static int32_t dnodeOpenVnode(int32_t vnode, char *rootDir) {
+ SVnodeObj vnodeObj = {0};
+ vnodeObj.vgId = vnode;
+ vnodeObj.status = TSDB_VN_STATUS_NOT_READY;
+ vnodeObj.refCount = 1;
+ vnodeObj.version = 0;
+ SVnodeObj *pVnode = (SVnodeObj *)taosAddIntHash(tsDnodeVnodesHash, vnodeObj.vgId, (char *)(&vnodeObj));
+
char tsdbDir[TSDB_FILENAME_LEN];
sprintf(tsdbDir, "%s/tsdb", rootDir);
void *pTsdb = tsdbOpenRepo(tsdbDir);
if (pTsdb == NULL) {
- dError("failed to open tsdb in vnode:%d %s, reason:%s", vnode, tsdbDir, tstrerror(terrno));
+ dError("pVnode:%p, vgroup:%d, failed to open tsdb in %s, reason:%s", pVnode, pVnode->vgId, tsdbDir, tstrerror(terrno));
+ taosDeleteIntHash(tsDnodeVnodesHash, pVnode->vgId);
return terrno;
}
- //STsdbRepoInfo *tsdbInfo = tsdbGetStatus(pTsdb);
-
- SVnodeObj vnodeObj = {0};
- vnodeObj.vgId = vnode;//tsdbInfo->tsdbCfg.tsdbId;
- vnodeObj.status = TSDB_VN_STATUS_NOT_READY;
- vnodeObj.refCount = 1;
- vnodeObj.version = 0;
- vnodeObj.wal = NULL;
- vnodeObj.tsdb = pTsdb;
- vnodeObj.replica = NULL;
- vnodeObj.events = NULL;
- vnodeObj.cq = NULL;
-
- SVnodeObj *pVnode = (SVnodeObj *)taosAddIntHash(tsDnodeVnodesHash, vnodeObj.vgId, (char *)(&vnodeObj));
+ pVnode->wal = NULL;
+ pVnode->tsdb = pTsdb;
+ pVnode->replica = NULL;
+ pVnode->events = NULL;
+ pVnode->cq = NULL;
pVnode->wworker = dnodeAllocateWriteWorker(pVnode);
pVnode->rworker = dnodeAllocateReadWorker(pVnode);
- dTrace("open vnode:%d in %s", pVnode->vgId, rootDir);
+ //TODO: jude status while replca is not null
+ if (pVnode->replica == NULL) {
+ pVnode->status = TSDB_VN_STATUS_MASTER;
+ }
+
+ dTrace("pVnode:%p, vgroup:%d, vnode is opened in %s", pVnode, pVnode->vgId, rootDir);
return TSDB_CODE_SUCCESS;
}
-static void dnodeCleanupVnode(SVnodeObj *pVnode) {
- pVnode->status = TSDB_VN_STATUS_NOT_READY;
- int32_t count = atomic_sub_fetch_32(&pVnode->refCount, 1);
- if (count > 0) {
- // wait refcount
- }
-
+static void dnodeDoCleanupVnode(SVnodeObj *pVnode) {
+ dTrace("pVnode:%p, vgroup:%d, cleanup vnode", pVnode, pVnode->vgId);
+
// remove replica
// remove read queue
@@ -263,8 +284,11 @@ static void dnodeCleanupVnode(SVnodeObj *pVnode) {
tsdbCloseRepo(pVnode->tsdb);
pVnode->tsdb = NULL;
}
+}
- dTrace("cleanup vnode:%d", pVnode->vgId);
+static void dnodeCleanupVnode(SVnodeObj *pVnode) {
+ pVnode->status = TSDB_VN_STATUS_CLOSING;
+ dnodeReleaseVnode(pVnode);
}
static int32_t dnodeCreateVnode(SMDCreateVnodeMsg *pVnodeCfg) {
@@ -311,7 +335,7 @@ static int32_t dnodeCreateVnode(SMDCreateVnodeMsg *pVnodeCfg) {
SVnodeObj vnodeObj = {0};
vnodeObj.vgId = pVnodeCfg->cfg.vgId;
- vnodeObj.status = TSDB_VN_STATUS_NOT_READY;
+ vnodeObj.status = TSDB_VN_STATUS_CREATING;
vnodeObj.refCount = 1;
vnodeObj.version = 0;
vnodeObj.wal = NULL;
@@ -323,32 +347,27 @@ static int32_t dnodeCreateVnode(SMDCreateVnodeMsg *pVnodeCfg) {
SVnodeObj *pVnode = (SVnodeObj *)taosAddIntHash(tsDnodeVnodesHash, vnodeObj.vgId, (char *)(&vnodeObj));
pVnode->wworker = dnodeAllocateWriteWorker(pVnode);
pVnode->rworker = dnodeAllocateReadWorker(pVnode);
+ if (pVnode->replica == NULL) {
+ pVnode->status = TSDB_VN_STATUS_MASTER;
+ }
dPrint("vgroup:%d, vnode:%d is created", pVnode->vgId, pVnode->vgId);
return TSDB_CODE_SUCCESS;
}
static void dnodeDoDropVnode(SVnodeObj *pVnode) {
- if (pVnode->tsdb) {
- tsdbDropRepo(pVnode->tsdb);
- pVnode->tsdb = NULL;
- }
-
- dnodeCleanupVnode(pVnode);
+ dnodeDoCleanupVnode(pVnode);
taosDeleteIntHash(tsDnodeVnodesHash, pVnode->vgId);
+
+ char rootDir[TSDB_FILENAME_LEN] = {0};
+ sprintf(rootDir, "%s/vnode%d", tsVnodeDir, pVnode->vgId);
+ dPrint("pVnode:%p, vgroup:%d, drop file:%s from disk", pVnode, pVnode->vgId, rootDir);
+ // rmdir(rootDir);
}
static void dnodeDropVnode(SVnodeObj *pVnode) {
- pVnode->status = TSDB_VN_STATUS_NOT_READY;
- pVnode->dirty = true;
-
- int32_t count = atomic_sub_fetch_32(&pVnode->refCount, 1);
- if (count > 0) {
- dTrace("vgroup:%d, vnode will be dropped until refcount:%d is 0", pVnode->vgId, count);
- return;
- }
-
- dnodeDoDropVnode(pVnode);
+ pVnode->status = TSDB_VN_STATUS_DELETING;
+ dnodeReleaseVnode(pVnode);
}
static void dnodeProcessCreateVnodeMsg(SRpcMsg *rpcMsg) {
@@ -359,7 +378,7 @@ static void dnodeProcessCreateVnodeMsg(SRpcMsg *rpcMsg) {
pCreate->cfg.maxSessions = htonl(pCreate->cfg.maxSessions);
pCreate->cfg.daysPerFile = htonl(pCreate->cfg.daysPerFile);
- dTrace("vgroup:%d, start to create vnode:%d in dnode", pCreate->cfg.vgId, pCreate->cfg.vgId);
+ dTrace("vgroup:%d, start to create vnode in dnode", pCreate->cfg.vgId);
SVnodeObj *pVnodeObj = (SVnodeObj *) taosGetIntHashData(tsDnodeVnodesHash, pCreate->cfg.vgId);
if (pVnodeObj != NULL) {
@@ -378,13 +397,13 @@ static void dnodeProcessDropVnodeMsg(SRpcMsg *rpcMsg) {
SMDDropVnodeMsg *pDrop = rpcMsg->pCont;
pDrop->vgId = htonl(pDrop->vgId);
- dTrace("vgroup:%d, start to drop vnode in dnode", pDrop->vgId);
-
SVnodeObj *pVnodeObj = (SVnodeObj *) taosGetIntHashData(tsDnodeVnodesHash, pDrop->vgId);
if (pVnodeObj != NULL) {
+ dPrint("pVnode:%p, vgroup:%d, start to drop vnode in dnode", pVnodeObj, pDrop->vgId);
dnodeDropVnode(pVnodeObj);
rpcRsp.code = TSDB_CODE_SUCCESS;
} else {
+ dTrace("vgroup:%d, failed drop vnode in dnode, vgroup not exist", pDrop->vgId);
rpcRsp.code = TSDB_CODE_INVALID_VGROUP_ID;
}
@@ -403,8 +422,10 @@ static void dnodeProcessAlterVnodeMsg(SRpcMsg *rpcMsg) {
SVnodeObj *pVnodeObj = (SVnodeObj *) taosGetIntHashData(tsDnodeVnodesHash, pCreate->cfg.vgId);
if (pVnodeObj != NULL) {
+ dPrint("pVnode:%p, vgroup:%d, start to alter vnode in dnode", pVnodeObj, pCreate->cfg.vgId);
rpcRsp.code = TSDB_CODE_SUCCESS;
} else {
+ dTrace("vgroup:%d, alter vnode msg received, start to create vnode", pCreate->cfg.vgId);
rpcRsp.code = dnodeCreateVnode(pCreate);;
}
@@ -432,7 +453,8 @@ static void dnodeProcessConfigDnodeMsg(SRpcMsg *pMsg) {
static void dnodeBuildVloadMsg(char *pNode, void * param) {
SVnodeObj *pVnode = (SVnodeObj *) pNode;
- if (pVnode->dirty) return;
+ dPrint("===> pVnode:%p, vgroup:%d status:%s", pVnode, pVnode->vgId, taosGetVnodeStatusStr(pVnode->status));
+ if (pVnode->status == TSDB_VN_STATUS_DELETING) return;
SDMStatusMsg *pStatus = param;
if (pStatus->openVnodes >= TSDB_MAX_VNODES) return;
@@ -528,4 +550,3 @@ void dnodeUpdateDnodeId(int32_t dnodeId) {
dnodeSaveDnodeId();
}
}
-
diff --git a/src/dnode/src/dnodeMnode.c b/src/dnode/src/dnodeMnode.c
index 9d1be0148ebf3e011ec0e649e38d2cf402b42d2e..c19a63c0e73d3a654bd205b957753ac7833770b0 100644
--- a/src/dnode/src/dnodeMnode.c
+++ b/src/dnode/src/dnodeMnode.c
@@ -79,6 +79,12 @@ static void dnodeProcessMsgFromMnode(SRpcMsg *pMsg) {
return;
}
+ if (pMsg->pCont == NULL) {
+ rspMsg.code = TSDB_CODE_INVALID_MSG_LEN;
+ rpcSendResponse(&rspMsg);
+ return;
+ }
+
if (dnodeProcessMgmtMsgFp[pMsg->msgType]) {
(*dnodeProcessMgmtMsgFp[pMsg->msgType])(pMsg);
} else {
diff --git a/src/mnode/src/mgmtDServer.c b/src/mnode/src/mgmtDServer.c
index b1d01b91f1f147b600fc70bd696be8e986c3eadf..ca23a3cfcaaffbbddd3738c0b7743d13368ce54f 100644
--- a/src/mnode/src/mgmtDServer.c
+++ b/src/mnode/src/mgmtDServer.c
@@ -32,11 +32,11 @@
#include "mgmtTable.h"
#include "mgmtVgroup.h"
-
static void mgmtProcessMsgFromDnode(SRpcMsg *rpcMsg);
static int mgmtDServerRetrieveAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey);
static void (*mgmtProcessDnodeMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *rpcMsg);
static void *tsMgmtDServerRpc;
+static void *tsMgmtDServerQhandle = NULL;
int32_t mgmtInitDServer() {
SRpcInit rpcInit = {0};
@@ -56,11 +56,18 @@ int32_t mgmtInitDServer() {
return -1;
}
+ tsMgmtDServerQhandle = taosInitScheduler(tsMaxShellConns, 1, "MS");
+
mPrint("server connection to dnode is opened");
return 0;
}
void mgmtCleanupDServer() {
+ if (tsMgmtDServerQhandle) {
+ taosCleanUpScheduler(tsMgmtDServerQhandle);
+ tsMgmtDServerQhandle = NULL;
+ }
+
if (tsMgmtDServerRpc) {
rpcClose(tsMgmtDServerRpc);
tsMgmtDServerRpc = NULL;
@@ -72,14 +79,34 @@ void mgmtAddDServerMsgHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)) {
mgmtProcessDnodeMsgFp[msgType] = fp;
}
+static void mgmtProcessDServerRequest(SSchedMsg *sched) {
+ SRpcMsg *pMsg = sched->msg;
+ (*mgmtProcessDnodeMsgFp[pMsg->msgType])(pMsg);
+ rpcFreeCont(pMsg->pCont);
+ free(pMsg);
+}
+
+static void mgmtAddToDServerQueue(SRpcMsg *pMsg) {
+ SSchedMsg schedMsg;
+ schedMsg.msg = pMsg;
+ schedMsg.fp = mgmtProcessDServerRequest;
+ taosScheduleTask(tsMgmtDServerQhandle, &schedMsg);
+}
+
static void mgmtProcessMsgFromDnode(SRpcMsg *rpcMsg) {
+ if (rpcMsg->pCont == NULL) {
+ mgmtSendSimpleResp(rpcMsg->handle, TSDB_CODE_INVALID_MSG_LEN);
+ return;
+ }
+
if (mgmtProcessDnodeMsgFp[rpcMsg->msgType]) {
- (*mgmtProcessDnodeMsgFp[rpcMsg->msgType])(rpcMsg);
+ SRpcMsg *pMsg = malloc(sizeof(SRpcMsg));
+ memcpy(pMsg, rpcMsg, sizeof(SRpcMsg));
+ mgmtAddToDServerQueue(pMsg);
} else {
mError("%s is not processed in dserver", taosMsg[rpcMsg->msgType]);
+ rpcFreeCont(rpcMsg->pCont);
}
-
- rpcFreeCont(rpcMsg->pCont);
}
static int mgmtDServerRetrieveAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey) {
diff --git a/src/mnode/src/mgmtDb.c b/src/mnode/src/mgmtDb.c
index 41e7a70276a9a8b62a36842774717be34258129e..5f28c30423780be1c12b6478757248ad7fd7bcae 100644
--- a/src/mnode/src/mgmtDb.c
+++ b/src/mnode/src/mgmtDb.c
@@ -903,9 +903,10 @@ static void mgmtProcessDropDbMsg(SQueuedMsg *pMsg) {
void mgmtDropAllDbs(SAcctObj *pAcct) {
int32_t numOfDbs = 0;
SDbObj *pDb = NULL;
+ void *pNode = NULL;
while (1) {
- void *pNode = sdbFetchRow(tsDbSdb, pNode, (void **)&pDb);
+ pNode = sdbFetchRow(tsDbSdb, pNode, (void **)&pDb);
if (pDb == NULL) break;
if (pDb->pAcct == pAcct) {
@@ -914,5 +915,5 @@ void mgmtDropAllDbs(SAcctObj *pAcct) {
}
}
- mTrace("acct:%s, all dbs is is set dirty", pAcct->acctId, numOfDbs);
+ mTrace("acct:%s, all dbs is is set dirty", pAcct->user, numOfDbs);
}
\ No newline at end of file
diff --git a/src/mnode/src/mgmtDnode.c b/src/mnode/src/mgmtDnode.c
index fbe9738a135cd67506f6d2a0d68aab10f289e26b..0cabaa813544f72ef990b02c097db4b27d1988c3 100644
--- a/src/mnode/src/mgmtDnode.c
+++ b/src/mnode/src/mgmtDnode.c
@@ -144,19 +144,24 @@ void mgmtProcessDnodeStatusMsg(SRpcMsg *rpcMsg) {
SDMStatusMsg *pStatus = rpcMsg->pCont;
pStatus->dnodeId = htonl(pStatus->dnodeId);
+ pStatus->privateIp = htonl(pStatus->privateIp);
+ pStatus->publicIp = htonl(pStatus->publicIp);
+ pStatus->lastReboot = htonl(pStatus->lastReboot);
+ pStatus->numOfCores = htons(pStatus->numOfCores);
+ pStatus->numOfTotalVnodes = htons(pStatus->numOfTotalVnodes);
SDnodeObj *pDnode = NULL;
if (pStatus->dnodeId == 0) {
- pDnode = mgmtGetDnodeByIp(htonl(pStatus->privateIp));
+ pDnode = mgmtGetDnodeByIp(pStatus->privateIp);
if (pDnode == NULL) {
- mTrace("dnode not created, privateIp:%s", taosIpStr(htonl(pStatus->privateIp)));
+ mTrace("dnode not created, privateIp:%s", taosIpStr(pStatus->privateIp));
mgmtSendSimpleResp(rpcMsg->handle, TSDB_CODE_DNODE_NOT_EXIST);
return;
}
} else {
pDnode = mgmtGetDnode(pStatus->dnodeId);
if (pDnode == NULL) {
- mError("dnode:%d, not exist, privateIp:%s", taosIpStr(pStatus->dnodeId), pStatus->dnodeName);
+ mError("dnode:%d, not exist, privateIp:%s", pStatus->dnodeId, taosIpStr(pStatus->privateIp));
mgmtSendSimpleResp(rpcMsg->handle, TSDB_CODE_DNODE_NOT_EXIST);
return;
}
@@ -169,16 +174,16 @@ void mgmtProcessDnodeStatusMsg(SRpcMsg *rpcMsg) {
return ;
}
- pDnode->privateIp = htonl(pStatus->privateIp);
- pDnode->publicIp = htonl(pStatus->publicIp);
- pDnode->lastReboot = htonl(pStatus->lastReboot);
- pDnode->numOfCores = htons(pStatus->numOfCores);
+ pDnode->privateIp = pStatus->privateIp;
+ pDnode->publicIp = pStatus->publicIp;
+ pDnode->lastReboot = pStatus->lastReboot;
+ pDnode->numOfCores = pStatus->numOfCores;
pDnode->diskAvailable = pStatus->diskAvailable;
pDnode->alternativeRole = pStatus->alternativeRole;
- pDnode->numOfTotalVnodes = htons(pStatus->numOfTotalVnodes);
+ pDnode->numOfTotalVnodes = pStatus->numOfTotalVnodes;
if (pStatus->dnodeId == 0) {
- mTrace("dnode:%d, first access, privateIp:%s, name:%s, ", pDnode->dnodeId, taosIpStr(pDnode->privateIp), pDnode->dnodeName);
+ mTrace("dnode:%d, first access, privateIp:%s, name:%s", pDnode->dnodeId, taosIpStr(pDnode->privateIp), pDnode->dnodeName);
}
int32_t openVnodes = htons(pStatus->openVnodes);
@@ -191,7 +196,7 @@ void mgmtProcessDnodeStatusMsg(SRpcMsg *rpcMsg) {
SVgObj *pVgroup = mgmtGetVgroup(pDnode->vload[j].vgId);
if (pVgroup == NULL) {
SRpcIpSet ipSet = mgmtGetIpSetFromIp(pDnode->privateIp);
- mPrint("dnode:%d, vnode:%d not exist in mnode, drop it", pDnode->dnodeId, pDnode->vload[j].vgId);
+ mPrint("dnode:%d, vgroup:%d not exist in mnode, drop it", pDnode->dnodeId, pDnode->vload[j].vgId);
mgmtSendDropVnodeMsg(pDnode->vload[j].vgId, &ipSet, NULL);
}
}
diff --git a/src/mnode/src/mgmtShell.c b/src/mnode/src/mgmtShell.c
index 9004ba02e4c890b046b5e0671734a3546f69a0d6..5664fef5b5a4bb5b3ad8050fcf2c476437293df5 100644
--- a/src/mnode/src/mgmtShell.c
+++ b/src/mnode/src/mgmtShell.c
@@ -131,6 +131,10 @@ void mgmtAddToShellQueue(SQueuedMsg *queuedMsg) {
}
static void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg) {
+ if (rpcMsg == NULL || rpcMsg->pCont == NULL) {
+ return;
+ }
+
if (!mgmtInServerStatus()) {
mgmtProcessMsgWhileNotReady(rpcMsg);
rpcFreeCont(rpcMsg->pCont);
@@ -221,14 +225,17 @@ static void mgmtProcessShowMsg(SQueuedMsg *pMsg) {
.handle = pMsg->thandle,
.pCont = pShowRsp,
.contLen = sizeof(SCMShowRsp) + sizeof(SSchema) * pShow->numOfColumns,
- .code = code,
- .msgType = 0
+ .code = code
};
rpcSendResponse(&rpcRsp);
} else {
mError("show:%p, type:%s, failed to get meta, reason:%s", pShow, taosGetShowTypeStr(pShowMsg->type), tstrerror(code));
mgmtFreeQhandle(pShow);
- rpcFreeCont(pShowRsp);
+ SRpcMsg rpcRsp = {
+ .handle = pMsg->thandle,
+ .code = code
+ };
+ rpcSendResponse(&rpcRsp);
}
}
diff --git a/src/mnode/src/mgmtUser.c b/src/mnode/src/mgmtUser.c
index a44afc02bc311cb488f4392a80215b03a3126fb5..c497fd6e8fd9182c9790a9f4b9e4c3507e468b92 100644
--- a/src/mnode/src/mgmtUser.c
+++ b/src/mnode/src/mgmtUser.c
@@ -61,7 +61,9 @@ static int32_t mgmtUserActionDelete(SSdbOperDesc *pOper) {
SUserObj *pUser = pOper->pObj;
SAcctObj *pAcct = acctGetAcct(pUser->acct);
- acctRemoveUser(pAcct, pUser);
+ if (pAcct != NULL) {
+ acctRemoveUser(pAcct, pUser);
+ }
return TSDB_CODE_SUCCESS;
}
@@ -448,7 +450,8 @@ static void mgmtProcessDropUserMsg(SQueuedMsg *pMsg) {
return ;
}
- if (strcmp(pUser->user, "monitor") == 0 || (strcmp(pUser->user + 1, pUser->acct) == 0 && pUser->user[0] == '_')) {
+ if (strcmp(pUser->user, "monitor") == 0 || strcmp(pUser->user, pUser->acct) == 0 ||
+ (strcmp(pUser->user + 1, pUser->acct) == 0 && pUser->user[0] == '_')) {
mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_NO_RIGHTS);
return ;
}
@@ -490,6 +493,7 @@ void mgmtDropAllUsers(SAcctObj *pAcct) {
SUserObj *pUser = NULL;
while (1) {
+ pLastNode = pNode;
pNode = sdbFetchRow(tsUserSdb, pNode, (void **)&pUser);
if (pUser == NULL) break;
@@ -506,5 +510,5 @@ void mgmtDropAllUsers(SAcctObj *pAcct) {
}
}
- mTrace("acct:%s, all users is dropped from sdb", pAcct->acctId, numOfUsers);
+ mTrace("acct:%s, all users:%d is dropped from sdb", pAcct->user, numOfUsers);
}
\ No newline at end of file
diff --git a/src/mnode/src/mgmtVgroup.c b/src/mnode/src/mgmtVgroup.c
index 0ae9f4bfa928a04f3b49d3c51b41e4a96b863f83..59880d204dd7d945f4deae35757516361f6e9989 100644
--- a/src/mnode/src/mgmtVgroup.c
+++ b/src/mnode/src/mgmtVgroup.c
@@ -602,7 +602,7 @@ static void mgmtSendDropVgroupMsg(SVgObj *pVgroup, void *ahandle) {
}
static void mgmtProcessDropVnodeRsp(SRpcMsg *rpcMsg) {
- mTrace("drop vnode msg is received");
+ mTrace("drop vnode rsp is received");
if (rpcMsg->handle == NULL) return;
SQueuedMsg *queueMsg = rpcMsg->handle;
diff --git a/src/util/inc/tstatus.h b/src/util/inc/tstatus.h
index 3b6dfc283a93b8477d185468dbd6d27f604f1747..9a65bb3ac118e27fa632753fc823431d5f619488 100644
--- a/src/util/inc/tstatus.h
+++ b/src/util/inc/tstatus.h
@@ -41,14 +41,13 @@ enum _TSDB_DB_STATUS {
};
typedef enum _TSDB_VN_STATUS {
- TSDB_VN_STATUS_OFFLINE,
- TSDB_VN_STATUS_CREATING,
+ TSDB_VN_STATUS_NOT_READY,
TSDB_VN_STATUS_UNSYNCED,
TSDB_VN_STATUS_SLAVE,
TSDB_VN_STATUS_MASTER,
+ TSDB_VN_STATUS_CREATING,
TSDB_VN_STATUS_CLOSING,
TSDB_VN_STATUS_DELETING,
- TSDB_VN_STATUS_NOT_READY
} EVnodeStatus;
enum _TSDB_VN_SYNC_STATUS {
diff --git a/src/util/src/.tqueue.c.swp b/src/util/src/.tqueue.c.swp
new file mode 100644
index 0000000000000000000000000000000000000000..40a09d5f638ccd61507bd50661e64d34cccce61c
Binary files /dev/null and b/src/util/src/.tqueue.c.swp differ
diff --git a/src/util/src/tqueue.c b/src/util/src/tqueue.c
index 1ac05556d6a90eb664c0a907f752010bf4ff52f5..bddf68932da310431a5be53ee9d2fed79bd89945 100644
--- a/src/util/src/tqueue.c
+++ b/src/util/src/tqueue.c
@@ -68,10 +68,10 @@ void taosCloseQueue(taos_queue param) {
STaosQnode *pNode = queue->head;
queue->head = NULL;
- pthread_mutex_lock(&queue->mutex);
-
if (queue->qset) taosRemoveFromQset(queue->qset, queue);
+ pthread_mutex_lock(&queue->mutex);
+
while (pNode) {
pTemp = pNode;
pNode = pNode->next;
@@ -253,33 +253,37 @@ void taosRemoveFromQset(taos_qset p1, taos_queue p2) {
STaosQueue *queue = (STaosQueue *)p2;
STaosQset *qset = (STaosQset *)p1;
- STaosQueue *tqueue;
+ STaosQueue *tqueue = NULL;
pthread_mutex_lock(&qset->mutex);
if (qset->head) {
if (qset->head == queue) {
qset->head = qset->head->next;
- qset->numOfQueues--;
+ tqueue = queue;
} else {
STaosQueue *prev = qset->head;
tqueue = qset->head->next;
while (tqueue) {
if (tqueue== queue) {
prev->next = tqueue->next;
- if (qset->current == queue) qset->current = tqueue->next;
- qset->numOfQueues--;
-
- pthread_mutex_lock(&queue->mutex);
- atomic_sub_fetch_32(&qset->numOfItems, queue->numOfItems);
- queue->qset = NULL;
- pthread_mutex_unlock(&queue->mutex);
+ break;
} else {
prev = tqueue;
tqueue = tqueue->next;
}
}
}
+
+ if (tqueue) {
+ if (qset->current == queue) qset->current = tqueue->next;
+ qset->numOfQueues--;
+
+ pthread_mutex_lock(&queue->mutex);
+ atomic_sub_fetch_32(&qset->numOfItems, queue->numOfItems);
+ queue->qset = NULL;
+ pthread_mutex_unlock(&queue->mutex);
+ }
}
pthread_mutex_unlock(&qset->mutex);
diff --git a/src/util/src/tstatus.c b/src/util/src/tstatus.c
index 39704464e800db3be75c623eaac437e9a3fe2214..4cf84304849854be884cad9144141be0d23024c2 100644
--- a/src/util/src/tstatus.c
+++ b/src/util/src/tstatus.c
@@ -40,11 +40,11 @@ char* taosGetDbStatusStr(int32_t dbStatus) {
char* taosGetVnodeStatusStr(int32_t vnodeStatus) {
switch (vnodeStatus) {
- case TSDB_VN_STATUS_OFFLINE: return "offline";
- case TSDB_VN_STATUS_CREATING: return "creating";
+ case TSDB_VN_STATUS_NOT_READY:return "not_ready";
case TSDB_VN_STATUS_UNSYNCED: return "unsynced";
case TSDB_VN_STATUS_SLAVE: return "slave";
case TSDB_VN_STATUS_MASTER: return "master";
+ case TSDB_VN_STATUS_CREATING: return "creating";
case TSDB_VN_STATUS_CLOSING: return "closing";
case TSDB_VN_STATUS_DELETING: return "deleting";
default: return "undefined";
diff --git a/src/util/src/tutil.c b/src/util/src/tutil.c
index cbd08954cc21ffd1f8a0e3cfc9076e0330860c42..4c689a5bcd8570c833be7bf9dada2111b14094f1 100644
--- a/src/util/src/tutil.c
+++ b/src/util/src/tutil.c
@@ -583,7 +583,8 @@ char *taosIpStr(uint32_t ipInt) {
static int ipStrIndex = 0;
char *ipStr = ipStrArray[(ipStrIndex++) % 3];
- sprintf(ipStr, "0x%x:%u.%u.%u.%u", ipInt, ipInt & 0xFF, (ipInt >> 8) & 0xFF, (ipInt >> 16) & 0xFF, (uint8_t)(ipInt >> 24));
+ //sprintf(ipStr, "0x%x:%u.%u.%u.%u", ipInt, ipInt & 0xFF, (ipInt >> 8) & 0xFF, (ipInt >> 16) & 0xFF, (uint8_t)(ipInt >> 24));
+ sprintf(ipStr, "%u.%u.%u.%u", ipInt & 0xFF, (ipInt >> 8) & 0xFF, (ipInt >> 16) & 0xFF, (uint8_t)(ipInt >> 24));
return ipStr;
}
diff --git a/tests/comparisonTest/opentsdb/opentsdbtest/pom.xml b/tests/comparisonTest/opentsdb/opentsdbtest/pom.xml
index 6f5fa6e132ea6d7a7cc6b0322dcd85f9183291f5..b104b6112b3201aac8a7b20ea9a20bd87c5c0f04 100644
--- a/tests/comparisonTest/opentsdb/opentsdbtest/pom.xml
+++ b/tests/comparisonTest/opentsdb/opentsdbtest/pom.xml
@@ -118,7 +118,7 @@
com.fasterxml.jackson.core
jackson-databind
- 2.9.10.1
+ 2.9.10.3
diff --git a/tests/script/basicSuite.sim b/tests/script/basicSuite.sim
index 009abf99e263302a02cd7e2876cffb6b4e846e17..e735099181984d5f58fd67d971c080e6216cfd8c 100644
--- a/tests/script/basicSuite.sim
+++ b/tests/script/basicSuite.sim
@@ -1,3 +1,4 @@
#################################
run general/user/testSuite.sim
+run general/table/testSuite.sim
##################################
diff --git a/tests/script/general/table/basic.sim b/tests/script/general/table/basic.sim
new file mode 100644
index 0000000000000000000000000000000000000000..599d0116532fad30cb1f95808046e27acde33cb0
--- /dev/null
+++ b/tests/script/general/table/basic.sim
@@ -0,0 +1,71 @@
+system sh/stop_dnodes.sh
+system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1
+system sh/exec.sh -n dnode1 -s start
+sql connect
+
+print =============== create database
+sql create database db
+sql show databases
+if $rows != 1 then
+ return -1
+endi
+
+print $data00 $data01 $data02
+
+print =============== create normal table
+sql create table db.n1 (ts timestamp, i int)
+sql show db.tables
+if $rows != 1 then
+ return -1
+endi
+
+print $data00 $data01 $data02
+
+print =============== create super table
+sql create table db.st (ts timestamp, i int) tags (j int)
+sql show db.stables
+if $rows != 1 then
+ return -1
+endi
+
+print $data00 $data01 $data02
+
+print =============== create child table
+sql create table db.c1 using db.st tags(1)
+sql create table db.c2 using db.st tags(2)
+sql show db.tables
+if $rows != 3 then
+ return -1
+endi
+
+print $data00 $data01 $data02
+print $data10 $data11 $data22
+print $data20 $data11 $data22
+
+print =============== insert data
+sql insert into db.n1 values(now, 1)
+sql insert into db.n1 values(now, 2)
+sql insert into db.n1 values(now, 3)
+
+print =============== query data
+sql select * from db.n1
+if $rows != 3 then
+ return -1
+endi
+
+print $data00 $data01
+print $data10 $data11
+print $data20 $data11
+
+if $data01 != 1 then
+ return -1
+endi
+
+if $data11 != 2 then
+ return -1
+endi
+
+if $data21 != 3 then
+ return -1
+endi
+
diff --git a/tests/script/general/table/testSuite.sim b/tests/script/general/table/testSuite.sim
new file mode 100644
index 0000000000000000000000000000000000000000..32677ab1ac9c4a2916ffe6df4fe8d36deea0b2fe
--- /dev/null
+++ b/tests/script/general/table/testSuite.sim
@@ -0,0 +1,3 @@
+#################################
+run general/table/basic.sim
+##################################
diff --git a/tests/script/general/user/testSuite.sim b/tests/script/general/user/testSuite.sim
index cb953b67ace2eacd7c290244d0df33653fbd761d..99414f1d293439c0852292f3ede03474e6fde3b9 100644
--- a/tests/script/general/user/testSuite.sim
+++ b/tests/script/general/user/testSuite.sim
@@ -1,3 +1,3 @@
#################################
-run general/user/basic.sim
+#run general/user/basic.sim
##################################
diff --git a/tests/script/sh/deploy.sh b/tests/script/sh/deploy.sh
index 49dd90c66f944bc18f2a5eacb826efff37dbbffd..6c4ada50fe86c272d7a96ec8fa7f698d9ba3e200 100755
--- a/tests/script/sh/deploy.sh
+++ b/tests/script/sh/deploy.sh
@@ -90,9 +90,9 @@ echo "logDir $LOG_DIR" >> $TAOS_CFG
echo "publicIp $NODE_IP" >> $TAOS_CFG
echo "internalIp $NODE_IP" >> $TAOS_CFG
echo "privateIp $NODE_IP" >> $TAOS_CFG
-echo "dDebugFlag 135" >> $TAOS_CFG
-echo "mDebugFlag 135" >> $TAOS_CFG
-echo "sdbDebugFlag 135" >> $TAOS_CFG
+echo "dDebugFlag 199" >> $TAOS_CFG
+echo "mDebugFlag 199" >> $TAOS_CFG
+echo "sdbDebugFlag 199" >> $TAOS_CFG
echo "rpcDebugFlag 135" >> $TAOS_CFG
echo "tmrDebugFlag 131" >> $TAOS_CFG
echo "cDebugFlag 135" >> $TAOS_CFG
diff --git a/tests/script/sh/exec_up.sh b/tests/script/sh/exec_up.sh
new file mode 100755
index 0000000000000000000000000000000000000000..ee4aabc175ee284596b11843f2bcd0ab9f38a8e8
--- /dev/null
+++ b/tests/script/sh/exec_up.sh
@@ -0,0 +1,109 @@
+#!/bin/sh
+
+# if [ $# != 4 || $# != 5 ]; then
+ # echo "argument list need input : "
+ # echo " -n nodeName"
+ # echo " -s start/stop"
+ # echo " -c clear"
+ # exit 1
+# fi
+
+NODE_NAME=
+EXEC_OPTON=
+CLEAR_OPTION="false"
+while getopts "n:s:u:x:ct" arg
+do
+ case $arg in
+ n)
+ NODE_NAME=$OPTARG
+ ;;
+ s)
+ EXEC_OPTON=$OPTARG
+ ;;
+ c)
+ CLEAR_OPTION="clear"
+ ;;
+ t)
+ SHELL_OPTION="true"
+ ;;
+ u)
+ USERS=$OPTARG
+ ;;
+ x)
+ SIGNAL=$OPTARG
+ ;;
+ ?)
+ echo "unkown argument"
+ ;;
+ esac
+done
+
+SCRIPT_DIR=`dirname $0`
+cd $SCRIPT_DIR/../
+SCRIPT_DIR=`pwd`
+
+cd ../../
+TAOS_DIR=`pwd`
+
+BUILD_DIR=$TAOS_DIR/../debug/build
+SIM_DIR=$TAOS_DIR/sim
+NODE_DIR=$SIM_DIR/$NODE_NAME
+EXE_DIR=$BUILD_DIR/bin
+CFG_DIR=$NODE_DIR/cfg
+LOG_DIR=$NODE_DIR/log
+DATA_DIR=$NODE_DIR/data
+MGMT_DIR=$NODE_DIR/data/mgmt
+TSDB_DIR=$NODE_DIR/data/tsdb
+
+TAOS_CFG=$NODE_DIR/cfg/taos.cfg
+
+echo ------------ $EXEC_OPTON $NODE_NAME
+
+TAOS_FLAG=$SIM_DIR/tsim/flag
+if [ -f "$TAOS_FLAG" ]; then
+ EXE_DIR=/usr/local/bin/taos
+fi
+
+if [ "$CLEAR_OPTION" = "clear" ]; then
+ echo rm -rf $MGMT_DIR $TSDB_DIR
+ rm -rf $TSDB_DIR
+ rm -rf $MGMT_DIR
+fi
+
+if [ "$SHELL_OPTION" = "true" ]; then
+ if [ "$EXEC_OPTON" = "start" ]; then
+ echo "ExcuteCmd:" $EXE_DIR/taos -c $CFG_DIR -u $USERS -p
+ $EXE_DIR/taos -c $CFG_DIR -u $USERS -p
+ else
+ #relative path
+ RCFG_DIR=sim/$NODE_NAME/cfg
+ PID=`ps -ef|grep -v taosd | grep taos | grep $RCFG_DIR | grep -v grep | awk '{print $2}'`
+ if [ -n "$PID" ]; then
+ sudo kill -9 $PID
+ fi
+ fi
+ return
+fi
+
+if [ "$EXEC_OPTON" = "start" ]; then
+ echo "ExcuteCmd:" $EXE_DIR/taosd -c $CFG_DIR
+ nohup $EXE_DIR/taosd -c $CFG_DIR > /dev/null 2>&1 &
+ #TT=`date +%s`
+ #mkdir ${LOG_DIR}/${TT}
+ #echo valgrind --log-file=${LOG_DIR}/${TT}/valgrind.log --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes $EXE_DIR/taosd -c $CFG_DIR
+ #nohup valgrind --log-file=${LOG_DIR}/${TT}/valgrind.log --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes $EXE_DIR/taosd -c $CFG_DIR > /dev/null 2>&1 &
+
+else
+ #relative path
+ RCFG_DIR=sim/$NODE_NAME/cfg
+ PID=`ps -ef|grep taosd | grep $RCFG_DIR | grep -v grep | awk '{print $2}'`
+ if [ -n "$PID" ]; then
+ if [ "$SIGNAL" = "SIGINT" ]; then
+ echo killed by signal
+ sudo kill -sigint $PID
+ else
+ sudo kill -9 $PID
+ fi
+ fi
+fi
+
diff --git a/tests/script/tmp/prepare.sim b/tests/script/tmp/prepare.sim
new file mode 100644
index 0000000000000000000000000000000000000000..a55a92955f9d918e6a0d1400c0e101aa211a772b
--- /dev/null
+++ b/tests/script/tmp/prepare.sim
@@ -0,0 +1,2 @@
+system sh/stop_dnodes.sh
+system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1
\ No newline at end of file
diff --git a/tests/script/unique/account/basic.sim b/tests/script/unique/account/basic.sim
new file mode 100644
index 0000000000000000000000000000000000000000..6f64975ac284d6e420a76a7fd4e356d1beee023f
--- /dev/null
+++ b/tests/script/unique/account/basic.sim
@@ -0,0 +1,45 @@
+system sh/stop_dnodes.sh
+system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1
+system sh/exec_up.sh -n dnode1 -s start
+sql connect
+
+print =============== show accounts
+sql show accounts
+if $rows != 1 then
+ return -1
+endi
+
+print $data00 $data01 $data02
+
+print =============== create account1
+sql create account account1 PASS 'account1'
+sql show accounts
+if $rows != 2 then
+ return -1
+endi
+
+print $data00 $data01 $data02
+print $data10 $data11 $data22
+
+print =============== create account2
+sql create account account2 PASS 'account2'
+sql show accounts
+if $rows != 3 then
+ return -1
+endi
+
+print $data00 $data01 $data02
+print $data10 $data11 $data22
+print $data20 $data11 $data22
+
+print =============== drop account1
+sql drop account account1
+sql show accounts
+if $rows != 2 then
+ return -1
+endi
+
+print $data00 $data01 $data02
+print $data10 $data11 $data22
+
+
diff --git a/tests/script/unique/testSuite.sim b/tests/script/unique/testSuite.sim
new file mode 100644
index 0000000000000000000000000000000000000000..1782f3ccd56b84641d1f90ba73252e6e4506f845
--- /dev/null
+++ b/tests/script/unique/testSuite.sim
@@ -0,0 +1,3 @@
+#################################
+run unique/account/basic.sim
+##################################