Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1ade3140
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
1ade3140
编写于
5月 19, 2023
作者:
W
wade zhang
提交者:
GitHub
5月 19, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #21325 from taosdata/feat/force-drop-dnode
Feat/force drop dnode
上级
7374ea2f
32c6ef4b
变更
22
展开全部
隐藏空白更改
内联
并排
Showing
22 changed file
with
4944 addition
and
5664 deletion
+4944
-5664
include/common/tmsg.h
include/common/tmsg.h
+1
-0
include/common/ttokendef.h
include/common/ttokendef.h
+282
-280
include/libs/nodes/cmdnodes.h
include/libs/nodes/cmdnodes.h
+1
-0
include/util/taoserror.h
include/util/taoserror.h
+1
-0
source/common/src/tmsg.c
source/common/src/tmsg.c
+7
-0
source/dnode/mnode/impl/inc/mndStb.h
source/dnode/mnode/impl/inc/mndStb.h
+1
-0
source/dnode/mnode/impl/inc/mndVgroup.h
source/dnode/mnode/impl/inc/mndVgroup.h
+1
-1
source/dnode/mnode/impl/src/mndDnode.c
source/dnode/mnode/impl/src/mndDnode.c
+12
-5
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+25
-0
source/dnode/mnode/impl/src/mndVgroup.c
source/dnode/mnode/impl/src/mndVgroup.c
+30
-5
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+7
-0
source/libs/parser/inc/parAst.h
source/libs/parser/inc/parAst.h
+1
-1
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+8
-2
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+2
-1
source/libs/parser/src/parTokenizer.c
source/libs/parser/src/parTokenizer.c
+1
-0
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+1
-0
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+4542
-5354
source/libs/parser/test/parInitialDTest.cpp
source/libs/parser/test/parInitialDTest.cpp
+17
-2
source/util/src/terror.c
source/util/src/terror.c
+1
-0
tests/pytest/util/dnodes.py
tests/pytest/util/dnodes.py
+0
-12
tests/script/tsim/dnode/drop_dnode_force.sim
tests/script/tsim/dnode/drop_dnode_force.sim
+2
-1
tests/system-test/forcedrop
tests/system-test/forcedrop
+1
-0
未找到文件。
include/common/tmsg.h
浏览文件 @
1ade3140
...
...
@@ -1642,6 +1642,7 @@ typedef struct {
char
fqdn
[
TSDB_FQDN_LEN
];
int32_t
port
;
int8_t
force
;
int8_t
unsafe
;
}
SDropDnodeReq
;
int32_t
tSerializeSDropDnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SDropDnodeReq
*
pReq
);
...
...
include/common/ttokendef.h
浏览文件 @
1ade3140
此差异已折叠。
点击以展开。
include/libs/nodes/cmdnodes.h
浏览文件 @
1ade3140
...
...
@@ -249,6 +249,7 @@ typedef struct SDropDnodeStmt {
char
fqdn
[
TSDB_FQDN_LEN
];
int32_t
port
;
bool
force
;
bool
unsafe
;
}
SDropDnodeStmt
;
typedef
struct
SAlterDnodeStmt
{
...
...
include/util/taoserror.h
浏览文件 @
1ade3140
...
...
@@ -446,6 +446,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_VND_NOT_CATCH_UP TAOS_DEF_ERROR_CODE(0, 0x0532) // internal
#define TSDB_CODE_VND_ALREADY_IS_VOTER TAOS_DEF_ERROR_CODE(0, 0x0533) // internal
#define TSDB_CODE_VND_DIR_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0534)
#define TSDB_CODE_VND_META_DATA_UNSAFE_DELETE TAOS_DEF_ERROR_CODE(0, 0x0535)
// tsdb
#define TSDB_CODE_TDB_INVALID_TABLE_ID TAOS_DEF_ERROR_CODE(0, 0x0600)
...
...
source/common/src/tmsg.c
浏览文件 @
1ade3140
...
...
@@ -1701,6 +1701,7 @@ int32_t tSerializeSDropDnodeReq(void *buf, int32_t bufLen, SDropDnodeReq *pReq)
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
fqdn
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
port
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
force
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
unsafe
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
...
...
@@ -1717,6 +1718,12 @@ int32_t tDeserializeSDropDnodeReq(void *buf, int32_t bufLen, SDropDnodeReq *pReq
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
fqdn
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
port
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
force
)
<
0
)
return
-
1
;
if
(
!
tDecodeIsEnd
(
&
decoder
))
{
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
unsafe
)
<
0
)
return
-
1
;
}
else
{
pReq
->
unsafe
=
false
;
}
tEndDecode
(
&
decoder
);
tDecoderClear
(
&
decoder
);
...
...
source/dnode/mnode/impl/inc/mndStb.h
浏览文件 @
1ade3140
...
...
@@ -47,6 +47,7 @@ int32_t mndAllocStbSchemas(const SStbObj *pOld, SStbObj *pNew);
int32_t
mndCheckColAndTagModifiable
(
SMnode
*
pMnode
,
const
char
*
stbFullName
,
int64_t
suid
,
col_id_t
colId
);
void
*
mndBuildVCreateStbReq
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
,
SStbObj
*
pStb
,
int32_t
*
pContLen
,
void
*
alterOriData
,
int32_t
alterOriDataLen
);
int32_t
mndSetForceDropCreateStbRedoActions
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SVgObj
*
pVgroup
,
SStbObj
*
pStb
);
#ifdef __cplusplus
}
...
...
source/dnode/mnode/impl/inc/mndVgroup.h
浏览文件 @
1ade3140
...
...
@@ -40,7 +40,7 @@ int32_t mndAddCreateVnodeAction(SMnode *, STrans *pTrans, SDbObj *pDb, SVgObj *p
int32_t
mndAddAlterVnodeConfirmAction
(
SMnode
*
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
);
int32_t
mndAddAlterVnodeAction
(
SMnode
*
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
,
tmsg_t
msgType
);
int32_t
mndAddDropVnodeAction
(
SMnode
*
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
,
SVnodeGid
*
pVgid
,
bool
isRedo
);
int32_t
mndSetMoveVgroupsInfoToTrans
(
SMnode
*
,
STrans
*
pTrans
,
int32_t
dropDnodeId
,
bool
force
);
int32_t
mndSetMoveVgroupsInfoToTrans
(
SMnode
*
,
STrans
*
pTrans
,
int32_t
dropDnodeId
,
bool
force
,
bool
unsafe
);
int32_t
mndBuildAlterVgroupAction
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pOldDb
,
SDbObj
*
pNewDb
,
SVgObj
*
pVgroup
,
SArray
*
pArray
);
int32_t
mndBuildCompactVgroupAction
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
,
int64_t
compactTs
,
...
...
source/dnode/mnode/impl/src/mndDnode.c
浏览文件 @
1ade3140
...
...
@@ -804,7 +804,7 @@ int32_t mndProcessRestoreDnodeReqImpl(SRpcMsg *pReq){
#endif
static
int32_t
mndDropDnode
(
SMnode
*
pMnode
,
SRpcMsg
*
pReq
,
SDnodeObj
*
pDnode
,
SMnodeObj
*
pMObj
,
SQnodeObj
*
pQObj
,
SSnodeObj
*
pSObj
,
int32_t
numOfVnodes
,
bool
force
)
{
SSnodeObj
*
pSObj
,
int32_t
numOfVnodes
,
bool
force
,
bool
unsafe
)
{
int32_t
code
=
-
1
;
SSdbRaw
*
pRaw
=
NULL
;
STrans
*
pTrans
=
NULL
;
...
...
@@ -844,7 +844,7 @@ static int32_t mndDropDnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode, SM
if
(
numOfVnodes
>
0
)
{
mInfo
(
"trans:%d, %d vnodes on dnode:%d will be dropped"
,
pTrans
->
id
,
numOfVnodes
,
pDnode
->
id
);
if
(
mndSetMoveVgroupsInfoToTrans
(
pMnode
,
pTrans
,
pDnode
->
id
,
force
)
!=
0
)
goto
_OVER
;
if
(
mndSetMoveVgroupsInfoToTrans
(
pMnode
,
pTrans
,
pDnode
->
id
,
force
,
unsafe
)
!=
0
)
goto
_OVER
;
}
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
...
...
@@ -871,11 +871,18 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) {
goto
_OVER
;
}
mInfo
(
"dnode:%d, start to drop, ep:%s:%d"
,
dropReq
.
dnodeId
,
dropReq
.
fqdn
,
dropReq
.
port
);
mInfo
(
"dnode:%d, start to drop, ep:%s:%d, force:%s, unsafe:%s"
,
dropReq
.
dnodeId
,
dropReq
.
fqdn
,
dropReq
.
port
,
dropReq
.
force
?
"true"
:
"false"
,
dropReq
.
unsafe
?
"true"
:
"false"
);
if
(
mndCheckOperPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_MNODE
)
!=
0
)
{
goto
_OVER
;
}
bool
force
=
dropReq
.
force
;
if
(
dropReq
.
unsafe
)
{
force
=
true
;
}
pDnode
=
mndAcquireDnode
(
pMnode
,
dropReq
.
dnodeId
);
if
(
pDnode
==
NULL
)
{
int32_t
err
=
terrno
;
...
...
@@ -903,7 +910,7 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) {
}
int32_t
numOfVnodes
=
mndGetVnodesNum
(
pMnode
,
pDnode
->
id
);
if
((
numOfVnodes
>
0
||
pMObj
!=
NULL
||
pSObj
!=
NULL
||
pQObj
!=
NULL
)
&&
!
dropReq
.
force
)
{
if
((
numOfVnodes
>
0
||
pMObj
!=
NULL
||
pSObj
!=
NULL
||
pQObj
!=
NULL
)
&&
!
force
)
{
if
(
!
mndIsDnodeOnline
(
pDnode
,
taosGetTimestampMs
()))
{
terrno
=
TSDB_CODE_DNODE_OFFLINE
;
mError
(
"dnode:%d, failed to drop since %s, vnodes:%d mnode:%d qnode:%d snode:%d"
,
pDnode
->
id
,
terrstr
(),
...
...
@@ -912,7 +919,7 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) {
}
}
code
=
mndDropDnode
(
pMnode
,
pReq
,
pDnode
,
pMObj
,
pQObj
,
pSObj
,
numOfVnodes
,
dropReq
.
forc
e
);
code
=
mndDropDnode
(
pMnode
,
pReq
,
pDnode
,
pMObj
,
pQObj
,
pSObj
,
numOfVnodes
,
force
,
dropReq
.
unsaf
e
);
if
(
code
==
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
_OVER:
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
1ade3140
...
...
@@ -687,6 +687,31 @@ static int32_t mndSetCreateStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj
return
0
;
}
int32_t
mndSetForceDropCreateStbRedoActions
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SVgObj
*
pVgroup
,
SStbObj
*
pStb
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
contLen
;
void
*
pReq
=
mndBuildVCreateStbReq
(
pMnode
,
pVgroup
,
pStb
,
&
contLen
,
NULL
,
0
);
if
(
pReq
==
NULL
)
{
return
-
1
;
}
STransAction
action
=
{
0
};
action
.
mTraceId
=
pTrans
->
mTraceId
;
action
.
epSet
=
mndGetVgroupEpset
(
pMnode
,
pVgroup
);
action
.
pCont
=
pReq
;
action
.
contLen
=
contLen
;
action
.
msgType
=
TDMT_VND_CREATE_STB
;
action
.
acceptableCode
=
TSDB_CODE_TDB_STB_ALREADY_EXIST
;
action
.
retryCode
=
TSDB_CODE_TDB_STB_NOT_EXIST
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
taosMemoryFree
(
pReq
);
return
-
1
;
}
return
0
;
}
static
int32_t
mndSetCreateStbUndoActions
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SStbObj
*
pStb
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SVgObj
*
pVgroup
=
NULL
;
...
...
source/dnode/mnode/impl/src/mndVgroup.c
浏览文件 @
1ade3140
...
...
@@ -23,6 +23,7 @@
#include "mndTrans.h"
#include "mndUser.h"
#include "tmisce.h"
#include "mndStb.h"
#define VGROUP_VER_NUMBER 1
#define VGROUP_RESERVE_SIZE 64
...
...
@@ -1378,7 +1379,7 @@ int32_t mndAddDropVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgOb
}
int32_t
mndSetMoveVgroupInfoToTrans
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
,
int32_t
vnIndex
,
SArray
*
pArray
,
bool
force
)
{
SArray
*
pArray
,
bool
force
,
bool
unsafe
)
{
SVgObj
newVg
=
{
0
};
memcpy
(
&
newVg
,
pVgroup
,
sizeof
(
SVgObj
));
...
...
@@ -1455,7 +1456,7 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb,
mInfo
(
"vgId:%d, will add 1 vnode and force remove 1 vnode"
,
pVgroup
->
vgId
);
if
(
mndAddVnodeToVgroup
(
pMnode
,
pTrans
,
&
newVg
,
pArray
)
!=
0
)
return
-
1
;
newVg
.
replica
--
;
SVnodeGid
del
=
newVg
.
vnodeGid
[
vnIndex
];
//
SVnodeGid del = newVg.vnodeGid[vnIndex];
newVg
.
vnodeGid
[
vnIndex
]
=
newVg
.
vnodeGid
[
newVg
.
replica
];
memset
(
&
newVg
.
vnodeGid
[
newVg
.
replica
],
0
,
sizeof
(
SVnodeGid
));
{
...
...
@@ -1476,7 +1477,31 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb,
if
(
mndAddCreateVnodeAction
(
pMnode
,
pTrans
,
pDb
,
&
newVg
,
&
newVg
.
vnodeGid
[
vnIndex
])
!=
0
)
return
-
1
;
if
(
mndAddAlterVnodeConfirmAction
(
pMnode
,
pTrans
,
pDb
,
&
newVg
)
!=
0
)
return
-
1
;
if
(
newVg
.
replica
==
1
)
{
if
(
newVg
.
replica
==
1
){
if
(
force
&&
!
unsafe
){
terrno
=
TSDB_CODE_VND_META_DATA_UNSAFE_DELETE
;
return
-
1
;
}
SSdb
*
pSdb
=
pMnode
->
pSdb
;
void
*
pIter
=
NULL
;
while
(
1
)
{
SStbObj
*
pStb
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_STB
,
pIter
,
(
void
**
)
&
pStb
);
if
(
pIter
==
NULL
)
break
;
if
(
strcmp
(
pStb
->
db
,
pDb
->
name
)
==
0
)
{
if
(
mndSetForceDropCreateStbRedoActions
(
pMnode
,
pTrans
,
&
newVg
,
pStb
)
!=
0
)
{
sdbCancelFetch
(
pSdb
,
pIter
);
sdbRelease
(
pSdb
,
pStb
);
return
-
1
;
}
}
sdbRelease
(
pSdb
,
pStb
);
}
mInfo
(
"vgId:%d, all data is dropped since replica=1"
,
pVgroup
->
vgId
);
}
}
...
...
@@ -1498,7 +1523,7 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb,
return
0
;
}
int32_t
mndSetMoveVgroupsInfoToTrans
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
int32_t
delDnodeId
,
bool
force
)
{
int32_t
mndSetMoveVgroupsInfoToTrans
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
int32_t
delDnodeId
,
bool
force
,
bool
unsafe
)
{
int32_t
code
=
0
;
SArray
*
pArray
=
mndBuildDnodesArray
(
pMnode
,
delDnodeId
);
if
(
pArray
==
NULL
)
return
-
1
;
...
...
@@ -1521,7 +1546,7 @@ int32_t mndSetMoveVgroupsInfoToTrans(SMnode *pMnode, STrans *pTrans, int32_t del
if
(
vnIndex
!=
-
1
)
{
mInfo
(
"vgId:%d, vnode:%d will be removed from dnode:%d, force:%d"
,
pVgroup
->
vgId
,
vnIndex
,
delDnodeId
,
force
);
SDbObj
*
pDb
=
mndAcquireDb
(
pMnode
,
pVgroup
->
dbName
);
code
=
mndSetMoveVgroupInfoToTrans
(
pMnode
,
pTrans
,
pDb
,
pVgroup
,
vnIndex
,
pArray
,
force
);
code
=
mndSetMoveVgroupInfoToTrans
(
pMnode
,
pTrans
,
pDb
,
pVgroup
,
vnIndex
,
pArray
,
force
,
unsafe
);
mndReleaseDb
(
pMnode
,
pDb
);
}
...
...
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
1ade3140
...
...
@@ -5510,6 +5510,7 @@ static const char* jkDropDnodeStmtDnodeId = "DnodeId";
static
const
char
*
jkDropDnodeStmtFqdn
=
"Fqdn"
;
static
const
char
*
jkDropDnodeStmtPort
=
"Port"
;
static
const
char
*
jkDropDnodeStmtForce
=
"Force"
;
static
const
char
*
jkDropDnodeStmtUnsafe
=
"Unsafe"
;
static
int32_t
dropDnodeStmtToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SDropDnodeStmt
*
pNode
=
(
const
SDropDnodeStmt
*
)
pObj
;
...
...
@@ -5524,6 +5525,9 @@ static int32_t dropDnodeStmtToJson(const void* pObj, SJson* pJson) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddBoolToObject
(
pJson
,
jkDropDnodeStmtForce
,
pNode
->
force
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddBoolToObject
(
pJson
,
jkDropDnodeStmtUnsafe
,
pNode
->
unsafe
);
}
return
code
;
}
...
...
@@ -5541,6 +5545,9 @@ static int32_t jsonToDropDnodeStmt(const SJson* pJson, void* pObj) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetBoolValue
(
pJson
,
jkDropDnodeStmtForce
,
&
pNode
->
force
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetBoolValue
(
pJson
,
jkDropDnodeStmtUnsafe
,
&
pNode
->
unsafe
);
}
return
code
;
}
...
...
source/libs/parser/inc/parAst.h
浏览文件 @
1ade3140
...
...
@@ -192,7 +192,7 @@ SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const ST
SNode
*
createAlterUserStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pUserName
,
int8_t
alterType
,
const
SToken
*
pVal
);
SNode
*
createDropUserStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pUserName
);
SNode
*
createCreateDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pFqdn
,
const
SToken
*
pPort
);
SNode
*
createDropDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnode
,
bool
force
);
SNode
*
createDropDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnode
,
bool
force
,
bool
unsafe
);
SNode
*
createAlterDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnode
,
const
SToken
*
pConfig
,
const
SToken
*
pValue
);
SNode
*
createRealTableNodeForIndexName
(
SAstCreateContext
*
pCxt
,
SToken
*
pDbName
,
SToken
*
pIndexName
);
SNode
*
createCreateIndexStmt
(
SAstCreateContext
*
pCxt
,
EIndexType
type
,
bool
ignoreExists
,
SNode
*
pIndexName
,
...
...
source/libs/parser/inc/sql.y
浏览文件 @
1ade3140
...
...
@@ -126,8 +126,10 @@ with_opt(A) ::= WITH search_condition(B).
/************************************************ create/drop/alter/restore dnode *********************************************/
cmd ::= CREATE DNODE dnode_endpoint(A). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, NULL); }
cmd ::= CREATE DNODE dnode_endpoint(A) PORT NK_INTEGER(B). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, &B); }
cmd ::= DROP DNODE NK_INTEGER(A) force_opt(B). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A, B); }
cmd ::= DROP DNODE dnode_endpoint(A) force_opt(B). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A, B); }
cmd ::= DROP DNODE NK_INTEGER(A) force_opt(B). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A, B, false); }
cmd ::= DROP DNODE dnode_endpoint(A) force_opt(B). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A, B, false); }
cmd ::= DROP DNODE NK_INTEGER(A) unsafe_opt(B). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A, false, B); }
cmd ::= DROP DNODE dnode_endpoint(A) unsafe_opt(B). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A, false, B); }
cmd ::= ALTER DNODE NK_INTEGER(A) NK_STRING(B). { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &A, &B, NULL); }
cmd ::= ALTER DNODE NK_INTEGER(A) NK_STRING(B) NK_STRING(C). { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &A, &B, &C); }
cmd ::= ALTER ALL DNODES NK_STRING(A). { pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &A, NULL); }
...
...
@@ -145,6 +147,10 @@ dnode_endpoint(A) ::= NK_IPTOKEN(B).
force_opt(A) ::= . { A = false; }
force_opt(A) ::= FORCE. { A = true; }
%type unsafe_opt { bool }
%destructor unsafe_opt { }
unsafe_opt(A) ::= UNSAFE. { A = true; }
/************************************************ alter local *********************************************************/
cmd ::= ALTER LOCAL NK_STRING(A). { pCxt->pRootNode = createAlterLocalStmt(pCxt, &A, NULL); }
cmd ::= ALTER LOCAL NK_STRING(A) NK_STRING(B). { pCxt->pRootNode = createAlterLocalStmt(pCxt, &A, &B); }
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
1ade3140
...
...
@@ -1576,7 +1576,7 @@ SNode* createCreateDnodeStmt(SAstCreateContext* pCxt, const SToken* pFqdn, const
return
(
SNode
*
)
pStmt
;
}
SNode
*
createDropDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnode
,
bool
force
)
{
SNode
*
createDropDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnode
,
bool
force
,
bool
unsafe
)
{
CHECK_PARSER_STATUS
(
pCxt
);
SDropDnodeStmt
*
pStmt
=
(
SDropDnodeStmt
*
)
nodesMakeNode
(
QUERY_NODE_DROP_DNODE_STMT
);
CHECK_OUT_OF_MEM
(
pStmt
);
...
...
@@ -1589,6 +1589,7 @@ SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, bool f
}
}
pStmt
->
force
=
force
;
pStmt
->
unsafe
=
unsafe
;
return
(
SNode
*
)
pStmt
;
}
...
...
source/libs/parser/src/parTokenizer.c
浏览文件 @
1ade3140
...
...
@@ -241,6 +241,7 @@ static SKeyword keywordTable[] = {
{
"TSERIES"
,
TK_TSERIES
},
{
"TTL"
,
TK_TTL
},
{
"UNION"
,
TK_UNION
},
{
"UNSAFE"
,
TK_UNSAFE
},
{
"UNSIGNED"
,
TK_UNSIGNED
},
{
"UNTREATED"
,
TK_UNTREATED
},
{
"UPDATE"
,
TK_UPDATE
},
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
1ade3140
...
...
@@ -5517,6 +5517,7 @@ static int32_t translateDropDnode(STranslateContext* pCxt, SDropDnodeStmt* pStmt
strcpy
(
dropReq
.
fqdn
,
pStmt
->
fqdn
);
dropReq
.
port
=
pStmt
->
port
;
dropReq
.
force
=
pStmt
->
force
;
dropReq
.
unsafe
=
pStmt
->
unsafe
;
return
buildCmdMsg
(
pCxt
,
TDMT_MND_DROP_DNODE
,
(
FSerializeFunc
)
tSerializeSDropDnodeReq
,
&
dropReq
);
}
...
...
source/libs/parser/src/sql.c
浏览文件 @
1ade3140
此差异已折叠。
点击以展开。
source/libs/parser/test/parInitialDTest.cpp
浏览文件 @
1ade3140
...
...
@@ -94,15 +94,17 @@ TEST_F(ParserInitialDTest, dropDnode) {
auto
clearDropDnodeReq
=
[
&
]()
{
memset
(
&
expect
,
0
,
sizeof
(
SDropDnodeReq
));
};
auto
setDropDnodeReqById
=
[
&
](
int32_t
dnodeId
,
bool
force
=
false
)
{
auto
setDropDnodeReqById
=
[
&
](
int32_t
dnodeId
,
bool
force
=
false
,
bool
unsafe
=
false
)
{
expect
.
dnodeId
=
dnodeId
;
expect
.
force
=
force
;
expect
.
unsafe
=
unsafe
;
};
auto
setDropDnodeReqByEndpoint
=
[
&
](
const
char
*
pFqdn
,
int32_t
port
=
tsServerPort
,
bool
force
=
false
)
{
auto
setDropDnodeReqByEndpoint
=
[
&
](
const
char
*
pFqdn
,
int32_t
port
=
tsServerPort
,
bool
force
=
false
,
bool
unsafe
=
false
)
{
strcpy
(
expect
.
fqdn
,
pFqdn
);
expect
.
port
=
port
;
expect
.
force
=
force
;
expect
.
unsafe
=
unsafe
;
};
setCheckDdlFunc
([
&
](
const
SQuery
*
pQuery
,
ParserStage
stage
)
{
...
...
@@ -114,6 +116,7 @@ TEST_F(ParserInitialDTest, dropDnode) {
ASSERT_EQ
(
std
::
string
(
req
.
fqdn
),
std
::
string
(
expect
.
fqdn
));
ASSERT_EQ
(
req
.
port
,
expect
.
port
);
ASSERT_EQ
(
req
.
force
,
expect
.
force
);
ASSERT_EQ
(
req
.
unsafe
,
expect
.
unsafe
);
});
setDropDnodeReqById
(
1
);
...
...
@@ -124,6 +127,10 @@ TEST_F(ParserInitialDTest, dropDnode) {
run
(
"DROP DNODE 2 FORCE"
);
clearDropDnodeReq
();
setDropDnodeReqById
(
2
,
false
,
true
);
run
(
"DROP DNODE 2 UNSAFE"
);
clearDropDnodeReq
();
setDropDnodeReqByEndpoint
(
"host1"
,
7030
);
run
(
"DROP DNODE 'host1:7030'"
);
clearDropDnodeReq
();
...
...
@@ -132,6 +139,10 @@ TEST_F(ParserInitialDTest, dropDnode) {
run
(
"DROP DNODE 'host2:8030' FORCE"
);
clearDropDnodeReq
();
setDropDnodeReqByEndpoint
(
"host2"
,
8030
,
false
,
true
);
run
(
"DROP DNODE 'host2:8030' UNSAFE"
);
clearDropDnodeReq
();
setDropDnodeReqByEndpoint
(
"host1"
);
run
(
"DROP DNODE host1"
);
clearDropDnodeReq
();
...
...
@@ -139,6 +150,10 @@ TEST_F(ParserInitialDTest, dropDnode) {
setDropDnodeReqByEndpoint
(
"host2"
,
tsServerPort
,
true
);
run
(
"DROP DNODE host2 FORCE"
);
clearDropDnodeReq
();
setDropDnodeReqByEndpoint
(
"host2"
,
tsServerPort
,
false
,
true
);
run
(
"DROP DNODE host2 UNSAFE"
);
clearDropDnodeReq
();
}
// todo DROP function
...
...
source/util/src/terror.c
浏览文件 @
1ade3140
...
...
@@ -343,6 +343,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_VND_QUERY_BUSY, "Query busy")
TAOS_DEFINE_ERROR
(
TSDB_CODE_VND_NOT_CATCH_UP
,
"Vnode didn't catch up its leader"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_VND_ALREADY_IS_VOTER
,
"Vnode already is a voter"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_VND_DIR_ALREADY_EXIST
,
"Vnode directory already exist"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_VND_META_DATA_UNSAFE_DELETE
,
"Single replica vnode data will lost permanently after this operation, if you make sure this, please use drop dnode <id> unsafe to execute"
)
// tsdb
TAOS_DEFINE_ERROR
(
TSDB_CODE_TDB_INVALID_TABLE_ID
,
"Invalid table ID"
)
...
...
tests/pytest/util/dnodes.py
浏览文件 @
1ade3140
...
...
@@ -130,18 +130,6 @@ class TDDnode:
"locale"
:
"en_US.UTF-8"
,
"charset"
:
"UTF-8"
,
"asyncLog"
:
"0"
,
"mDebugFlag"
:
"143"
,
"dDebugFlag"
:
"143"
,
"vDebugFlag"
:
"143"
,
"tqDebugFlag"
:
"143"
,
"cDebugFlag"
:
"143"
,
"jniDebugFlag"
:
"143"
,
"qDebugFlag"
:
"143"
,
"rpcDebugFlag"
:
"143"
,
"tmrDebugFlag"
:
"131"
,
"uDebugFlag"
:
"143"
,
"sDebugFlag"
:
"143"
,
"wDebugFlag"
:
"143"
,
"numOfLogLines"
:
"100000000"
,
"statusInterval"
:
"1"
,
"enableQueryHb"
:
"1"
,
...
...
tests/script/tsim/dnode/drop_dnode_force.sim
浏览文件 @
1ade3140
...
...
@@ -209,7 +209,8 @@ endi
print =============== step5a: drop dnode 3
sql_error drop dnode 3
sql drop dnode 3 force
sql_error drop dnode 3 force
sql drop dnode 3 unsafe
print select * from information_schema.ins_dnodes;
sql select * from information_schema.ins_dnodes;
...
...
tests/system-test/forcedrop
0 → 120000
浏览文件 @
1ade3140
/home/ubuntu/Documents/github/cadem/emptydebug/forcedrop/
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录