提交 bf9d1274 编写于 作者: S slguan

[TD-184] fix bug while drop dnode

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