Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0747bc12
TDengine
项目概览
taosdata
/
TDengine
12 个月 前同步成功
通知
1180
Star
22014
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
0747bc12
编写于
6月 22, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
6月 22, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #14109 from taosdata/fix/dnode
feat: drop dnode
上级
e8c69502
9f96667f
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
188 addition
and
23 deletion
+188
-23
source/dnode/mnode/impl/src/mndDnode.c
source/dnode/mnode/impl/src/mndDnode.c
+5
-5
source/dnode/mnode/impl/src/mndProfile.c
source/dnode/mnode/impl/src/mndProfile.c
+1
-1
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+4
-4
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+2
-2
source/dnode/mnode/impl/src/mndVgroup.c
source/dnode/mnode/impl/src/mndVgroup.c
+14
-2
source/dnode/mnode/sdb/src/sdbFile.c
source/dnode/mnode/sdb/src/sdbFile.c
+8
-8
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+1
-0
tests/script/tsim/dnode/drop_dnode_has_mnode.sim
tests/script/tsim/dnode/drop_dnode_has_mnode.sim
+2
-1
tests/script/tsim/dnode/drop_dnode_has_vnode_replica1.sim
tests/script/tsim/dnode/drop_dnode_has_vnode_replica1.sim
+151
-0
未找到文件。
source/dnode/mnode/impl/src/mndDnode.c
浏览文件 @
0747bc12
...
...
@@ -508,7 +508,7 @@ static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq) {
goto
_OVER
;
}
m
Debug
(
"dnode:%s:%d, start to create"
,
createReq
.
fqdn
,
createReq
.
port
);
m
Info
(
"dnode:%s:%d, start to create"
,
createReq
.
fqdn
,
createReq
.
port
);
if
(
createReq
.
fqdn
[
0
]
==
0
||
createReq
.
port
<=
0
||
createReq
.
port
>
UINT16_MAX
)
{
terrno
=
TSDB_CODE_MND_INVALID_DNODE_EP
;
...
...
@@ -546,7 +546,7 @@ static int32_t mndDropDnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode, SM
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
TRN_CONFLICT_GLOBAL
,
pReq
);
if
(
pTrans
==
NULL
)
goto
_OVER
;
mndTransSetSerial
(
pTrans
);
m
Debug
(
"trans:%d, used to drop dnode:%d"
,
pTrans
->
id
,
pDnode
->
id
);
m
Info
(
"trans:%d, used to drop dnode:%d"
,
pTrans
->
id
,
pDnode
->
id
);
pRaw
=
mndDnodeActionEncode
(
pDnode
);
if
(
pRaw
==
NULL
||
mndTransAppendRedolog
(
pTrans
,
pRaw
)
!=
0
)
goto
_OVER
;
...
...
@@ -559,11 +559,11 @@ static int32_t mndDropDnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode, SM
pRaw
=
NULL
;
if
(
pMObj
!=
NULL
)
{
m
Debug
(
"trans:%d, mnode on dnode:%d will be dropped"
,
pTrans
->
id
,
pDnode
->
id
);
m
Info
(
"trans:%d, mnode on dnode:%d will be dropped"
,
pTrans
->
id
,
pDnode
->
id
);
if
(
mndSetDropMnodeInfoToTrans
(
pMnode
,
pTrans
,
pMObj
)
!=
0
)
goto
_OVER
;
}
if
(
numOfVnodes
>
0
)
{
m
Debug
(
"trans:%d, %d vnodes on dnode:%d will be dropped"
,
pTrans
->
id
,
numOfVnodes
,
pDnode
->
id
);
m
Info
(
"trans:%d, %d vnodes on dnode:%d will be dropped"
,
pTrans
->
id
,
numOfVnodes
,
pDnode
->
id
);
if
(
mndSetMoveVgroupsInfoToTrans
(
pMnode
,
pTrans
,
pDnode
->
id
)
!=
0
)
goto
_OVER
;
}
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
...
...
@@ -588,7 +588,7 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) {
goto
_OVER
;
}
m
Debug
(
"dnode:%d, start to drop"
,
dropReq
.
dnodeId
);
m
Info
(
"dnode:%d, start to drop"
,
dropReq
.
dnodeId
);
if
(
dropReq
.
dnodeId
<=
0
)
{
terrno
=
TSDB_CODE_MND_INVALID_DNODE_ID
;
...
...
source/dnode/mnode/impl/src/mndProfile.c
浏览文件 @
0747bc12
...
...
@@ -447,7 +447,7 @@ static int32_t mndUpdateAppInfo(SMnode *pMnode, SClientHbReq *pHbReq, SRpcConnIn
mError
(
"failed to create new app %"
PRIx64
" since %s"
,
pReq
->
appId
,
terrstr
());
return
-
1
;
}
else
{
mDebug
(
"a new app %"
PRIx64
"created"
,
pReq
->
appId
);
mDebug
(
"a new app %"
PRIx64
"
is
created"
,
pReq
->
appId
);
mndReleaseApp
(
pMnode
,
pApp
);
return
TSDB_CODE_SUCCESS
;
}
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
0747bc12
...
...
@@ -75,7 +75,7 @@ void mndSyncCommitMsg(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbM
}
int32_t
mndSyncGetSnapshot
(
struct
SSyncFSM
*
pFsm
,
SSnapshot
*
pSnapshot
,
void
*
pReaderParam
,
void
**
ppReader
)
{
m
Info
(
"start to read snapshot from sdb in atomic way"
);
m
Debug
(
"start to read snapshot from sdb in atomic way"
);
SMnode
*
pMnode
=
pFsm
->
data
;
return
sdbStartRead
(
pMnode
->
pSdb
,
(
SSdbIter
**
)
ppReader
,
&
pSnapshot
->
lastApplyIndex
,
&
pSnapshot
->
lastApplyTerm
,
&
pSnapshot
->
lastConfigIndex
);
...
...
@@ -96,7 +96,7 @@ void mndRestoreFinish(struct SSyncFSM *pFsm) {
mndTransPullup
(
pMnode
);
mndSetRestore
(
pMnode
,
true
);
}
else
{
mInfo
(
"mnode sync restore finished
, and will set ready after first deploy
"
);
mInfo
(
"mnode sync restore finished"
);
}
}
...
...
@@ -118,13 +118,13 @@ void mndReConfig(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SReConfigCbMeta cbM
}
int32_t
mndSnapshotStartRead
(
struct
SSyncFSM
*
pFsm
,
void
**
ppReader
)
{
m
Info
(
"start to read snapshot from sdb"
);
m
Debug
(
"start to read snapshot from sdb"
);
SMnode
*
pMnode
=
pFsm
->
data
;
return
sdbStartRead
(
pMnode
->
pSdb
,
(
SSdbIter
**
)
ppReader
,
NULL
,
NULL
,
NULL
);
}
int32_t
mndSnapshotStopRead
(
struct
SSyncFSM
*
pFsm
,
void
*
pReader
)
{
m
Info
(
"stop to read snapshot from sdb"
);
m
Debug
(
"stop to read snapshot from sdb"
);
SMnode
*
pMnode
=
pFsm
->
data
;
return
sdbStopRead
(
pMnode
->
pSdb
,
pReader
);
}
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
0747bc12
...
...
@@ -432,11 +432,11 @@ static const char *mndTransStr(ETrnStage stage) {
}
static
void
mndTransTestStartFunc
(
SMnode
*
pMnode
,
void
*
param
,
int32_t
paramLen
)
{
m
Info
(
"test trans start, param:%s, len:%d"
,
(
char
*
)
param
,
paramLen
);
m
Debug
(
"test trans start, param:%s, len:%d"
,
(
char
*
)
param
,
paramLen
);
}
static
void
mndTransTestStopFunc
(
SMnode
*
pMnode
,
void
*
param
,
int32_t
paramLen
)
{
m
Info
(
"test trans stop, param:%s, len:%d"
,
(
char
*
)
param
,
paramLen
);
m
Debug
(
"test trans stop, param:%s, len:%d"
,
(
char
*
)
param
,
paramLen
);
}
static
TransCbFp
mndTransGetCbFp
(
ETrnFunc
ftype
)
{
...
...
source/dnode/mnode/impl/src/mndVgroup.c
浏览文件 @
0747bc12
...
...
@@ -1017,6 +1017,11 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb,
if
(
mndAddDropVnodeAction
(
pMnode
,
pTrans
,
pDb
,
&
newVg
,
&
del
,
true
)
!=
0
)
return
-
1
;
if
(
mndAddAlterVnodeConfirmAction
(
pMnode
,
pTrans
,
pDb
,
&
newVg
)
!=
0
)
return
-
1
;
SSdbRaw
*
pRaw
=
mndVgroupActionEncode
(
&
newVg
);
if
(
pRaw
==
NULL
||
mndTransAppendCommitlog
(
pTrans
,
pRaw
)
!=
0
)
return
-
1
;
sdbSetRawStatus
(
pRaw
,
SDB_STATUS_READY
);
pRaw
=
NULL
;
mInfo
(
"vgId:%d, vgroup info after move, replica:%d"
,
newVg
.
vgId
,
newVg
.
replica
);
for
(
int32_t
i
=
0
;
i
<
newVg
.
replica
;
++
i
)
{
mInfo
(
"vgId:%d, vnode:%d dnode:%d"
,
newVg
.
vgId
,
i
,
newVg
.
vnodeGid
[
i
].
dnodeId
);
...
...
@@ -1025,6 +1030,7 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb,
}
int32_t
mndSetMoveVgroupsInfoToTrans
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
int32_t
delDnodeId
)
{
int32_t
code
=
0
;
SArray
*
pArray
=
mndBuildDnodesArray
(
pMnode
,
delDnodeId
);
if
(
pArray
==
NULL
)
return
-
1
;
...
...
@@ -1042,18 +1048,24 @@ int32_t mndSetMoveVgroupsInfoToTrans(SMnode *pMnode, STrans *pTrans, int32_t del
}
}
code
=
0
;
if
(
vnIndex
!=
-
1
)
{
mInfo
(
"vgId:%d, vnode:%d will be removed from dnode:%d"
,
pVgroup
->
vgId
,
vnIndex
,
delDnodeId
);
SDbObj
*
pDb
=
mndAcquireDb
(
pMnode
,
pVgroup
->
dbName
);
mndSetMoveVgroupInfoToTrans
(
pMnode
,
pTrans
,
pDb
,
pVgroup
,
vnIndex
,
pArray
);
code
=
mndSetMoveVgroupInfoToTrans
(
pMnode
,
pTrans
,
pDb
,
pVgroup
,
vnIndex
,
pArray
);
mndReleaseDb
(
pMnode
,
pDb
);
}
sdbRelease
(
pMnode
->
pSdb
,
pVgroup
);
if
(
code
!=
0
)
{
sdbCancelFetch
(
pMnode
->
pSdb
,
pIter
);
break
;
}
}
taosArrayDestroy
(
pArray
);
return
0
;
return
code
;
}
static
int32_t
mndAddIncVgroupReplicaToTrans
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
,
...
...
source/dnode/mnode/sdb/src/sdbFile.c
浏览文件 @
0747bc12
...
...
@@ -519,7 +519,7 @@ static void sdbCloseIter(SSdbIter *pIter) {
pIter
->
name
=
NULL
;
}
m
Info
(
"sdbiter:%p, is closed, total:%"
PRId64
,
pIter
,
pIter
->
total
);
m
Debug
(
"sdbiter:%p, is closed, total:%"
PRId64
,
pIter
,
pIter
->
total
);
taosMemoryFree
(
pIter
);
}
...
...
@@ -556,7 +556,7 @@ int32_t sdbStartRead(SSdb *pSdb, SSdbIter **ppIter, int64_t *index, int64_t *ter
if
(
term
!=
NULL
)
*
term
=
commitTerm
;
if
(
config
!=
NULL
)
*
config
=
commitConfig
;
m
Info
(
"sdbiter:%p, is created to read snapshot, commit index:%"
PRId64
" term:%"
PRId64
" config:%"
PRId64
" file:%s"
,
m
Debug
(
"sdbiter:%p, is created to read snapshot, commit index:%"
PRId64
" term:%"
PRId64
" config:%"
PRId64
" file:%s"
,
pIter
,
commitIndex
,
commitTerm
,
commitConfig
,
pIter
->
name
);
return
0
;
}
...
...
@@ -583,14 +583,14 @@ int32_t sdbDoRead(SSdb *pSdb, SSdbIter *pIter, void **ppBuf, int32_t *len) {
taosMemoryFree
(
pBuf
);
return
-
1
;
}
else
if
(
readlen
==
0
)
{
m
Info
(
"sdbiter:%p, read snapshot to the end, total:%"
PRId64
,
pIter
,
pIter
->
total
);
m
Debug
(
"sdbiter:%p, read snapshot to the end, total:%"
PRId64
,
pIter
,
pIter
->
total
);
*
ppBuf
=
NULL
;
*
len
=
0
;
taosMemoryFree
(
pBuf
);
return
0
;
}
else
{
// (readlen <= maxlen)
pIter
->
total
+=
readlen
;
m
Info
(
"sdbiter:%p, read:%d bytes from snapshot, total:%"
PRId64
,
pIter
,
readlen
,
pIter
->
total
);
m
Debug
(
"sdbiter:%p, read:%d bytes from snapshot, total:%"
PRId64
,
pIter
,
readlen
,
pIter
->
total
);
*
ppBuf
=
pBuf
;
*
len
=
readlen
;
return
0
;
...
...
@@ -609,7 +609,7 @@ int32_t sdbStartWrite(SSdb *pSdb, SSdbIter **ppIter) {
}
*
ppIter
=
pIter
;
m
Info
(
"sdbiter:%p, is created to write snapshot, file:%s"
,
pIter
,
pIter
->
name
);
m
Debug
(
"sdbiter:%p, is created to write snapshot, file:%s"
,
pIter
,
pIter
->
name
);
return
0
;
}
...
...
@@ -618,7 +618,7 @@ int32_t sdbStopWrite(SSdb *pSdb, SSdbIter *pIter, bool isApply) {
if
(
!
isApply
)
{
sdbCloseIter
(
pIter
);
m
Info
(
"sdbiter:%p, not apply to sdb"
,
pIter
);
m
Debug
(
"sdbiter:%p, not apply to sdb"
,
pIter
);
return
0
;
}
...
...
@@ -641,7 +641,7 @@ int32_t sdbStopWrite(SSdb *pSdb, SSdbIter *pIter, bool isApply) {
return
-
1
;
}
m
Info
(
"sdbiter:%p, successfully applyed to sdb"
,
pIter
);
m
Debug
(
"sdbiter:%p, successfully applyed to sdb"
,
pIter
);
return
0
;
}
...
...
@@ -654,6 +654,6 @@ int32_t sdbDoWrite(SSdb *pSdb, SSdbIter *pIter, void *pBuf, int32_t len) {
}
pIter
->
total
+=
writelen
;
m
Info
(
"sdbiter:%p, write:%d bytes to snapshot, total:%"
PRId64
,
pIter
,
writelen
,
pIter
->
total
);
m
Debug
(
"sdbiter:%p, write:%d bytes to snapshot, total:%"
PRId64
,
pIter
,
writelen
,
pIter
->
total
);
return
0
;
}
\ No newline at end of file
tests/script/jenkins/basic.txt
浏览文件 @
0747bc12
...
...
@@ -23,6 +23,7 @@
# ---- dnode
./test.sh -f tsim/dnode/create_dnode.sim
./test.sh -f tsim/dnode/drop_dnode_has_mnode.sim
./test.sh -f tsim/dnode/drop_dnode_has_vnode_replica1.sim
# ---- insert
./test.sh -f tsim/insert/basic0.sim
...
...
tests/script/tsim/dnode/drop_dnode_has_mnode.sim
浏览文件 @
0747bc12
...
...
@@ -70,6 +70,7 @@ if $data(2)[2] != follower then
endi
print =============== step4: drop dnode 2
sql_error drop dnode 1
sql drop dnode 2
print show dnodes;
...
...
@@ -83,7 +84,7 @@ if $data00 != 1 then
return -1
endi
print show
d
nodes;
print show
m
nodes;
sql show mnodes
print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4]
print $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4]
...
...
tests/script/tsim/dnode/drop_dnode_has_vnode_replica1.sim
0 → 100644
浏览文件 @
0747bc12
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3
system sh/cfg.sh -n dnode1 -c supportVnodes -v 0
system sh/exec.sh -n dnode1 -s start
system sh/exec.sh -n dnode2 -s start
sql connect
print =============== step1 create dnode2
sql create dnode $hostname port 7200
sql create dnode $hostname port 7300
$x = 0
step1:
$ = $x + 1
sleep 1000
if $x == 10 then
print ====> dnode not online!
return -1
endi
sql show dnodes
print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
if $rows != 3 then
return -1
endi
if $data(1)[4] != ready then
goto step1
endi
if $data(2)[4] != ready then
goto step1
endi
if $data(3)[4] != offline then
goto step1
endi
print =============== step2 drop dnode which not exist
sql_error drop dnode 1
sql_error drop dnode 4
print =============== step3 create database
sql create database d1 vgroups 1
sql use d1
sql create table d1.st (ts timestamp, i int) tags (j int)
sql create table d1.c1 using st tags(1)
sql show d1.tables
if $rows != 1 then
return -1
endi
sql show d1.vgroups
print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4]
if $rows != 1 then
return -1
endi
if $data(2)[3] != 2 then
return -1
endi
print =============== step4: drop dnode 2
print cant drop since no enough vnodes
sql_error drop dnode 2
system sh/exec.sh -n dnode2 -s stop
system sh/exec.sh -n dnode3 -s start
$x = 0
step4:
$ = $x + 1
sleep 1000
if $x == 10 then
print ====> dnode not online!
return -1
endi
sql show dnodes
print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
if $rows != 3 then
return -1
endi
if $data(1)[4] != ready then
goto step4
endi
if $data(2)[4] != offline then
goto step4
endi
if $data(3)[4] != ready then
goto step4
endi
# cant drop since offline
sql_error drop dnode 2
print =============== step5: start dnode2
system sh/exec.sh -n dnode2 -s start
$x = 0
step5:
$ = $x + 1
sleep 1000
if $x == 10 then
print ====> dnode not online!
return -1
endi
sql show dnodes
print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
if $rows != 3 then
return -1
endi
if $data(1)[4] != ready then
goto step5
endi
if $data(2)[4] != ready then
goto step5
endi
if $data(3)[4] != ready then
goto step5
endi
print =============== step6: drop dnode2
sql drop dnode 2
print show dnodes;
sql show dnodes;
print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4]
print $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4]
if $rows != 2 then
return -1
endi
print show d1.vgroups
sql show d1.vgroups
print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4]
if $rows != 1 then
return -1
endi
if $data(2)[3] != 3 then
return -1
endi
print =============== step7: select data
sql show d1.tables
if $rows != 1 then
return -1
endi
return
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录