Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
dffade96
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
dffade96
编写于
4月 01, 2020
作者:
S
slguan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-17] fix error while drop vnodes
上级
311c56c1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
16 addition
and
20 deletion
+16
-20
src/dnode/src/dnodeMgmt.c
src/dnode/src/dnodeMgmt.c
+14
-19
tests/script/tmp/prepare.sim
tests/script/tmp/prepare.sim
+2
-1
未找到文件。
src/dnode/src/dnodeMgmt.c
浏览文件 @
dffade96
...
...
@@ -29,6 +29,8 @@
#include "dnodeRead.h"
#include "dnodeWrite.h"
typedef
enum
{
CLOSE_TSDB
,
DROP_TSDB
}
ECloseTsdbFlag
;
typedef
struct
{
int32_t
vgId
;
// global vnode group ID
int32_t
refCount
;
// reference count
...
...
@@ -47,10 +49,9 @@ 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
void
dnodeDoCleanupVnode
(
SVnodeObj
*
pVnode
,
ECloseTsdbFlag
dropFlag
);
static
int32_t
dnodeCreateVnode
(
SMDCreateVnodeMsg
*
cfg
);
static
void
dnodeDropVnode
(
SVnodeObj
*
pVnode
);
static
void
dnodeDoDropVnode
(
SVnodeObj
*
pVnode
);
static
void
dnodeProcessCreateVnodeMsg
(
SRpcMsg
*
pMsg
);
static
void
dnodeProcessDropVnodeMsg
(
SRpcMsg
*
pMsg
);
static
void
dnodeProcessAlterVnodeMsg
(
SRpcMsg
*
pMsg
);
...
...
@@ -178,14 +179,14 @@ void dnodeReleaseVnode(void *pVnodeRaw) {
if
(
pVnode
->
status
==
TSDB_VN_STATUS_DELETING
)
{
if
(
refCount
<=
0
)
{
dPrint
(
"pVnode:%p, vgroup:%d, drop vnode, refCount:%d"
,
pVnode
,
pVnode
->
vgId
,
refCount
);
dnodeDo
DropVnode
(
pVnode
);
dnodeDo
CleanupVnode
(
pVnode
,
DROP_TSDB
);
}
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
);
dnodeDoCleanupVnode
(
pVnode
,
CLOSE_TSDB
);
}
else
{
dTrace
(
"pVnode:%p, vgroup:%d, vnode will cleanup until refCount:%d is 0"
,
pVnode
,
pVnode
->
vgId
,
refCount
);
}
...
...
@@ -264,7 +265,7 @@ static int32_t dnodeOpenVnode(int32_t vnode, char *rootDir) {
return
TSDB_CODE_SUCCESS
;
}
static
void
dnodeDoCleanupVnode
(
SVnodeObj
*
pVnode
)
{
static
void
dnodeDoCleanupVnode
(
SVnodeObj
*
pVnode
,
ECloseTsdbFlag
closeFlag
)
{
dTrace
(
"pVnode:%p, vgroup:%d, cleanup vnode"
,
pVnode
,
pVnode
->
vgId
);
// remove replica
...
...
@@ -281,7 +282,12 @@ static void dnodeDoCleanupVnode(SVnodeObj *pVnode) {
// remove tsdb
if
(
pVnode
->
tsdb
)
{
tsdbCloseRepo
(
pVnode
->
tsdb
);
if
(
closeFlag
==
DROP_TSDB
)
{
tsdbDropRepo
(
pVnode
->
tsdb
);
}
else
if
(
closeFlag
==
CLOSE_TSDB
)
{
tsdbCloseRepo
(
pVnode
->
tsdb
);
}
taosDeleteIntHash
(
tsDnodeVnodesHash
,
pVnode
->
vgId
);
pVnode
->
tsdb
=
NULL
;
}
}
...
...
@@ -351,20 +357,10 @@ static int32_t dnodeCreateVnode(SMDCreateVnodeMsg *pVnodeCfg) {
pVnode
->
status
=
TSDB_VN_STATUS_MASTER
;
}
dPrint
(
"
vgroup:%d, vnode:%d is created"
,
pVnode
->
vgId
,
pVnode
->
vgId
);
dPrint
(
"
pVnode:%p, vgroup:%d, vnode:%d is created"
,
pVnode
,
pVnode
->
vgId
,
pVnode
->
vgId
);
return
TSDB_CODE_SUCCESS
;
}
static
void
dnodeDoDropVnode
(
SVnodeObj
*
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_DELETING
;
dnodeReleaseVnode
(
pVnode
);
...
...
@@ -383,7 +379,7 @@ static void dnodeProcessCreateVnodeMsg(SRpcMsg *rpcMsg) {
SVnodeObj
*
pVnodeObj
=
(
SVnodeObj
*
)
taosGetIntHashData
(
tsDnodeVnodesHash
,
pCreate
->
cfg
.
vgId
);
if
(
pVnodeObj
!=
NULL
)
{
rpcRsp
.
code
=
TSDB_CODE_SUCCESS
;
dPrint
(
"
vgroup:%d, vnode is already exist"
,
pCreate
->
cfg
.
vgId
);
dPrint
(
"
pVnode:%p, vgroup:%d, vnode is already exist"
,
pVnodeObj
,
pCreate
->
cfg
.
vgId
);
}
else
{
rpcRsp
.
code
=
dnodeCreateVnode
(
pCreate
);
}
...
...
@@ -453,7 +449,6 @@ static void dnodeProcessConfigDnodeMsg(SRpcMsg *pMsg) {
static
void
dnodeBuildVloadMsg
(
char
*
pNode
,
void
*
param
)
{
SVnodeObj
*
pVnode
=
(
SVnodeObj
*
)
pNode
;
dPrint
(
"===> pVnode:%p, vgroup:%d status:%s"
,
pVnode
,
pVnode
->
vgId
,
taosGetVnodeStatusStr
(
pVnode
->
status
));
if
(
pVnode
->
status
==
TSDB_VN_STATUS_DELETING
)
return
;
SDMStatusMsg
*
pStatus
=
param
;
...
...
tests/script/tmp/prepare.sim
浏览文件 @
dffade96
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
system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1
system sh/deploy.sh -n dnode2 -m 192.168.0.1 -i 192.168.0.2
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录