提交 bf9d1274 编写于 作者: S slguan

[TD-184] fix bug while drop dnode

上级 0cce9bea
......@@ -206,7 +206,6 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
case TSDB_SQL_DROP_ACCT:
case TSDB_SQL_DROP_DNODE:
case TSDB_SQL_DROP_DB: {
const char* msg1 = "invalid ip address";
const char* msg2 = "invalid name";
const char* msg3 = "param name too long";
......@@ -230,10 +229,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3);
}
} else if (pInfo->type == TSDB_SQL_DROP_DNODE) {
if (!validateIpAddress(pzName->z, pzName->n)) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
}
pzName->n = strdequote(pzName->z);
strncpy(pTableMetaInfo->name, pzName->z, pzName->n);
} else { // drop user
if (pzName->n > TSDB_USER_LEN) {
......@@ -304,10 +300,6 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
SSQLToken* pIpAddr = &pInfo->pDCLInfo->a[0];
// if (!validateIpAddress(pIpAddr->z, pIpAddr->n)) {
// return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg);
// }
pIpAddr->n = strdequote(pIpAddr->z);
break;
}
......
......@@ -38,7 +38,7 @@ void * mgmtGetNextDnode(void *pNode, SDnodeObj **pDnode);
void mgmtIncDnodeRef(SDnodeObj *pDnode);
void mgmtDecDnodeRef(SDnodeObj *pDnode);
void * mgmtGetDnode(int32_t dnodeId);
void * mgmtGetDnodeByIp(char *ep);
void * mgmtGetDnodeByEp(char *ep);
void mgmtUpdateDnode(SDnodeObj *pDnode);
int32_t mgmtDropDnode(SDnodeObj *pDnode);
......
......@@ -74,7 +74,9 @@ static int32_t mgmtDnodeActionInsert(SSdbOper *pOper) {
static int32_t mgmtDnodeActionDelete(SSdbOper *pOper) {
SDnodeObj *pDnode = pOper->pObj;
#ifndef _SYNC
mgmtDropAllDnodeVgroups(pDnode);
#endif
mgmtDropMnodeLocal(pDnode->dnodeId);
balanceNotify();
......@@ -113,7 +115,7 @@ static int32_t mgmtDnodeActionRestored() {
int32_t numOfRows = sdbGetNumOfRows(tsDnodeSdb);
if (numOfRows <= 0 && dnodeIsFirstDeploy()) {
mgmtCreateDnode(tsLocalEp);
SDnodeObj *pDnode = mgmtGetDnodeByIp(tsLocalEp);
SDnodeObj *pDnode = mgmtGetDnodeByEp(tsLocalEp);
mgmtAddMnode(pDnode->dnodeId);
mgmtDecDnodeRef(pDnode);
}
......@@ -181,7 +183,7 @@ void *mgmtGetDnode(int32_t dnodeId) {
return sdbGetRow(tsDnodeSdb, &dnodeId);
}
void *mgmtGetDnodeByIp(char *ep) {
void *mgmtGetDnodeByEp(char *ep) {
SDnodeObj *pDnode = NULL;
void * pNode = NULL;
......@@ -271,7 +273,7 @@ void mgmtProcessDnodeStatusMsg(SRpcMsg *rpcMsg) {
SDnodeObj *pDnode = NULL;
if (pStatus->dnodeId == 0) {
pDnode = mgmtGetDnodeByIp(pStatus->dnodeEp);
pDnode = mgmtGetDnodeByEp(pStatus->dnodeEp);
if (pDnode == NULL) {
mTrace("dnode %s not created", pStatus->dnodeEp);
mgmtSendSimpleResp(rpcMsg->handle, TSDB_CODE_DNODE_NOT_EXIST);
......@@ -358,7 +360,7 @@ static int32_t mgmtCreateDnode(char *ep) {
return grantCode;
}
SDnodeObj *pDnode = mgmtGetDnodeByIp(ep);
SDnodeObj *pDnode = mgmtGetDnodeByEp(ep);
if (pDnode != NULL) {
mgmtDecDnodeRef(pDnode);
mError("dnode:%d is alredy exist, %s:%d", pDnode->dnodeId, pDnode->dnodeFqdn, pDnode->dnodePort);
......@@ -391,6 +393,7 @@ static int32_t mgmtCreateDnode(char *ep) {
return code;
}
//TODO drop others tables
int32_t mgmtDropDnode(SDnodeObj *pDnode) {
SSdbOper oper = {
.type = SDB_OPER_GLOBAL,
......@@ -407,8 +410,9 @@ int32_t mgmtDropDnode(SDnodeObj *pDnode) {
return code;
}
static int32_t mgmtDropDnodeByIp(char *ep) {
SDnodeObj *pDnode = mgmtGetDnodeByIp(ep);
static int32_t mgmtDropDnodeByEp(char *ep) {
SDnodeObj *pDnode = mgmtGetDnodeByEp(ep);
if (pDnode == NULL) {
mError("dnode:%s, is not exist", ep);
return TSDB_CODE_DNODE_NOT_EXIST;
......@@ -437,7 +441,7 @@ static void mgmtProcessCreateDnodeMsg(SQueuedMsg *pMsg) {
} else {
rpcRsp.code = mgmtCreateDnode(pCreate->ep);
if (rpcRsp.code == TSDB_CODE_SUCCESS) {
SDnodeObj *pDnode = mgmtGetDnodeByIp(pCreate->ep);
SDnodeObj *pDnode = mgmtGetDnodeByEp(pCreate->ep);
mLPrint("dnode:%d, %s is created by %s", pDnode->dnodeId, pCreate->ep, pMsg->pUser->user);
mgmtDecDnodeRef(pDnode);
} else {
......@@ -456,7 +460,7 @@ static void mgmtProcessDropDnodeMsg(SQueuedMsg *pMsg) {
if (strcmp(pMsg->pUser->user, "root") != 0) {
rpcRsp.code = TSDB_CODE_NO_RIGHTS;
} else {
rpcRsp.code = mgmtDropDnodeByIp(pDrop->ep);
rpcRsp.code = mgmtDropDnodeByEp(pDrop->ep);
if (rpcRsp.code == TSDB_CODE_SUCCESS) {
mLPrint("dnode:%s is dropped by %s", pDrop->ep, pMsg->pUser->user);
} else {
......@@ -812,7 +816,7 @@ static int32_t mgmtGetVnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pCo
SDnodeObj *pDnode = NULL;
if (pShow->payloadLen > 0 ) {
pDnode = mgmtGetDnodeByIp(pShow->payload);
pDnode = mgmtGetDnodeByEp(pShow->payload);
} else {
mgmtGetNextDnode(NULL, (SDnodeObj **)&pDnode);
}
......
......@@ -277,7 +277,7 @@ SSubclauseInfo *setSubclause(SSubclauseInfo *pClause, void *pSqlExprInfo);
SSubclauseInfo *appendSelectClause(SSubclauseInfo *pInfo, void *pSubclause);
void setCreatedMeterName(SSqlInfo *pInfo, SSQLToken *pMeterName, SSQLToken *pIfNotExists);
void setCreatedTableName(SSqlInfo *pInfo, SSQLToken *pMeterName, SSQLToken *pIfNotExists);
void SQLInfoDestroy(SSqlInfo *pInfo);
......
......@@ -264,7 +264,7 @@ signed(A) ::= MINUS INTEGER(X). { A = -strtol(X.z, NULL, 10);}
////////////////////////////////// The CREATE TABLE statement ///////////////////////////////
cmd ::= CREATE TABLE ifnotexists(Y) ids(X) cpxName(Z) create_table_args. {
X.n += Z.n;
setCreatedMeterName(pInfo, &X, &Y);
setCreatedTableName(pInfo, &X, &Y);
}
%type create_table_args{SCreateTableSQL*}
......
......@@ -731,7 +731,7 @@ SSubclauseInfo* appendSelectClause(SSubclauseInfo *pQueryInfo, void *pSubclause)
return pQueryInfo;
}
void setCreatedMeterName(SSqlInfo *pInfo, SSQLToken *pMeterName, SSQLToken *pIfNotExists) {
void setCreatedTableName(SSqlInfo *pInfo, SSQLToken *pMeterName, SSQLToken *pIfNotExists) {
pInfo->pCreateTableInfo->name = *pMeterName;
pInfo->pCreateTableInfo->existCheck = (pIfNotExists->n != 0);
}
......
此差异已折叠。
#run unique/big/balance.sim
#run unique/big/maxvnodes.sim
run unique/big/tcp.sim
#run unique/big/tcp.sim
......@@ -106,7 +106,7 @@ sleep 8000
sql show mnodes
$dnode1Role = $data2_1
$dnode2Role = $data3_4
$dnode2Role = $data2_4
$dnode3Role = $data2_3
print dnode1 ==> $dnode1Role
print dnode2 ==> $dnode2Role
......@@ -128,7 +128,7 @@ sleep 10000
sql show mnodes
$dnode1Role = $data2_1
$dnode2Role = $data3_4
$dnode2Role = $data2_4
$dnode3Role = $data2_3
print dnode1 ==> $dnode1Role
print dnode2 ==> $dnode2Role
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册