Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
afdd343e
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
afdd343e
编写于
7月 15, 2020
作者:
陶建辉(Jeff)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
minor changes
上级
bba1e0bc
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
43 addition
and
28 deletion
+43
-28
src/vnode/src/vnodeMain.c
src/vnode/src/vnodeMain.c
+43
-28
未找到文件。
src/vnode/src/vnodeMain.c
浏览文件 @
afdd343e
...
...
@@ -164,18 +164,11 @@ int32_t vnodeAlter(void *param, SMDCreateVnodeMsg *pVnodeCfg) {
// vnode in non-ready state and still needs to return success instead of TSDB_CODE_VND_INVALID_STATUS
// cfgVersion can be corrected by status msg
if
(
pVnode
->
status
!=
TAOS_VN_STATUS_READY
)
{
if
(
atomic_val_compare_exchange_8
(
&
pVnode
->
status
,
TAOS_VN_STATUS_READY
,
TAOS_VN_STATUS_UPDATING
)
!=
TAOS_VN_STATUS_READY
)
{
vDebug
(
"vgId:%d, vnode is not ready, do alter operation later"
,
pVnode
->
vgId
);
return
TSDB_CODE_SUCCESS
;
}
// the vnode may always fail to synchronize because of it in low cfgVersion
// so cannot use the following codes
// if (pVnode->syncCfg.replica > 1 && pVnode->role == TAOS_SYNC_ROLE_UNSYNCED)
// return TSDB_CODE_VND_NOT_SYNCED;
pVnode
->
status
=
TAOS_VN_STATUS_UPDATING
;
int32_t
code
=
vnodeSaveCfg
(
pVnodeCfg
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
pVnode
->
status
=
TAOS_VN_STATUS_READY
;
...
...
@@ -403,12 +396,6 @@ void *vnodeAcquireVnode(int32_t vgId) {
}
SVnodeObj
*
pVnode
=
*
ppVnode
;
if
(
pVnode
->
status
==
TAOS_VN_STATUS_RESET
)
{
terrno
=
TSDB_CODE_VND_INVALID_STATUS
;
vInfo
(
"vgId:%d, status is in reset"
,
vgId
);
return
NULL
;
}
atomic_add_fetch_32
(
&
pVnode
->
refCount
,
1
);
vDebug
(
"vgId:%d, get vnode, refCount:%d"
,
pVnode
->
vgId
,
pVnode
->
refCount
);
...
...
@@ -418,12 +405,28 @@ void *vnodeAcquireVnode(int32_t vgId) {
void
*
vnodeAcquireRqueue
(
int32_t
vgId
)
{
SVnodeObj
*
pVnode
=
vnodeAcquireVnode
(
vgId
);
if
(
pVnode
==
NULL
)
return
NULL
;
if
(
pVnode
->
status
==
TAOS_VN_STATUS_RESET
)
{
terrno
=
TSDB_CODE_VND_INVALID_STATUS
;
vInfo
(
"vgId:%d, status is in reset"
,
vgId
);
vnodeRelease
(
pVnode
);
return
NULL
;
}
return
pVnode
->
rqueue
;
}
void
*
vnodeAcquireWqueue
(
int32_t
vgId
)
{
SVnodeObj
*
pVnode
=
vnodeAcquireVnode
(
vgId
);
if
(
pVnode
==
NULL
)
return
NULL
;
if
(
pVnode
->
status
==
TAOS_VN_STATUS_RESET
)
{
terrno
=
TSDB_CODE_VND_INVALID_STATUS
;
vInfo
(
"vgId:%d, status is in reset"
,
vgId
);
vnodeRelease
(
pVnode
);
return
NULL
;
}
return
pVnode
->
wqueue
;
}
...
...
@@ -509,8 +512,16 @@ void vnodeSetAccess(SDMVgroupAccess *pAccess, int32_t numOfVnodes) {
static
void
vnodeCleanUp
(
SVnodeObj
*
pVnode
)
{
// remove from hash, so new messages wont be consumed
taosHashRemove
(
tsDnodeVnodesHash
,
(
const
char
*
)
&
pVnode
->
vgId
,
sizeof
(
int32_t
));
int
i
=
0
;
pVnode
->
status
=
TSDB_VN_STATUS_CLOSING
;
if
(
pVnode
->
status
!=
TAOS_VN_STATUS_INIT
)
{
// it may be in updateing or reset state, then it shall wait
while
(
atomic_val_compare_exchange_8
(
&
pVnode
->
status
,
TAOS_VN_STATUS_READY
,
TAOS_VN_STATUS_CLOSING
)
!=
TAOS_VN_STATUS_READY
)
{
if
(
++
i
%
1000
==
0
)
{
sched_yield
();
}
}
}
// stop replication module
if
(
pVnode
->
sync
)
{
...
...
@@ -562,20 +573,17 @@ static void vnodeNotifyRole(void *ahandle, int8_t role) {
cqStop
(
pVnode
->
cq
);
}
static
int
vnodeNotifyFileSynced
(
void
*
ahandle
,
uint64_t
fversion
)
{
SVnodeObj
*
pVnode
=
ahandle
;
vDebug
(
"vgId:%d, data file is synced, fversion:%"
PRId64
,
pVnode
->
vgId
,
fversion
);
pVnode
->
fversion
=
fversion
;
pVnode
->
version
=
fversion
;
vnodeSaveVersion
(
pVnode
);
static
int
vnodeResetTsdb
(
SVnodeObj
*
pVnode
)
{
char
rootDir
[
128
]
=
"
\0
"
;
sprintf
(
rootDir
,
"%s/tsdb"
,
pVnode
->
rootDir
);
if
(
atomic_val_compare_exchange_8
(
&
pVnode
->
status
,
TAOS_VN_STATUS_READY
,
TAOS_VN_STATUS_RESET
)
!=
TAOS_VN_STATUS_READY
)
return
-
1
;
void
*
tsdb
=
pVnode
->
tsdb
;
pVnode
->
tsdb
=
NULL
;
// acquire vnode
int32_t
refCount
=
atomic_add_fetch_32
(
&
pVnode
->
refCount
,
1
);
...
...
@@ -583,9 +591,6 @@ static int vnodeNotifyFileSynced(void *ahandle, uint64_t fversion) {
tsem_wait
(
&
pVnode
->
sem
);
// close tsdb, then open tsdb
void
*
tsdb
=
pVnode
->
tsdb
;
pVnode
->
tsdb
=
NULL
;
tsdbCloseRepo
(
tsdb
,
0
);
STsdbAppH
appH
=
{
0
};
appH
.
appH
=
(
void
*
)
pVnode
;
...
...
@@ -596,13 +601,23 @@ static int vnodeNotifyFileSynced(void *ahandle, uint64_t fversion) {
appH
.
configFunc
=
dnodeSendCfgTableToRecv
;
pVnode
->
tsdb
=
tsdbOpenRepo
(
rootDir
,
&
appH
);
// vnode status may be changed to DELETING or CLOSING
atomic_val_compare_exchange_8
(
&
pVnode
->
status
,
TAOS_VN_STATUS_RESET
,
TAOS_VN_STATUS_READY
);
pVnode
->
status
=
TAOS_VN_STATUS_READY
;
vnodeRelease
(
pVnode
);
return
0
;
}
static
int
vnodeNotifyFileSynced
(
void
*
ahandle
,
uint64_t
fversion
)
{
SVnodeObj
*
pVnode
=
ahandle
;
vDebug
(
"vgId:%d, data file is synced, fversion:%"
PRId64
,
pVnode
->
vgId
,
fversion
);
pVnode
->
fversion
=
fversion
;
pVnode
->
version
=
fversion
;
vnodeSaveVersion
(
pVnode
);
return
vnodeResetTsdb
(
pVnode
);
}
static
int32_t
vnodeSaveCfg
(
SMDCreateVnodeMsg
*
pVnodeCfg
)
{
char
cfgFile
[
TSDB_FILENAME_LEN
+
30
]
=
{
0
};
sprintf
(
cfgFile
,
"%s/vnode%d/config.json"
,
tsVnodeDir
,
pVnodeCfg
->
cfg
.
vgId
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录