Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
92e05b8e
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看板
提交
92e05b8e
编写于
12月 27, 2022
作者:
B
Benguang Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: schedule vnodeCommit uniformly distributed
上级
691b75ad
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
20 addition
and
6 deletion
+20
-6
source/dnode/vnode/src/inc/vnd.h
source/dnode/vnode/src/inc/vnd.h
+1
-0
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+6
-1
source/dnode/vnode/src/vnd/vnodeCommit.c
source/dnode/vnode/src/vnd/vnodeCommit.c
+10
-3
source/dnode/vnode/src/vnd/vnodeOpen.c
source/dnode/vnode/src/vnd/vnodeOpen.c
+2
-1
source/dnode/vnode/src/vnd/vnodeSync.c
source/dnode/vnode/src/vnd/vnodeSync.c
+1
-1
未找到文件。
source/dnode/vnode/src/inc/vnd.h
浏览文件 @
92e05b8e
...
...
@@ -86,6 +86,7 @@ int32_t vnodeGetBatchMeta(SVnode* pVnode, SRpcMsg* pMsg);
// vnodeCommit.c
int32_t
vnodeBegin
(
SVnode
*
pVnode
);
int32_t
vnodeShouldCommit
(
SVnode
*
pVnode
);
void
vnodeUpdCommitSched
(
SVnode
*
pVnode
);
void
vnodeRollback
(
SVnode
*
pVnode
);
int32_t
vnodeSaveInfo
(
const
char
*
dir
,
const
SVnodeInfo
*
pCfg
);
int32_t
vnodeCommitInfo
(
const
char
*
dir
,
const
SVnodeInfo
*
pInfo
);
...
...
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
92e05b8e
...
...
@@ -332,6 +332,11 @@ struct STsdbKeepCfg {
int32_t
keep2
;
};
typedef
struct
SVCommitSched
{
int64_t
commitMs
;
int64_t
maxWaitMs
;
}
SVCommitSched
;
struct
SVnode
{
char
*
path
;
SVnodeCfg
config
;
...
...
@@ -350,7 +355,7 @@ struct SVnode {
STQ
*
pTq
;
SSink
*
pSink
;
tsem_t
canCommit
;
int64_t
commitMs
;
SVCommitSched
commitSched
;
int64_t
sync
;
TdThreadMutex
lock
;
bool
blocked
;
...
...
source/dnode/vnode/src/vnd/vnodeCommit.c
浏览文件 @
92e05b8e
...
...
@@ -58,15 +58,22 @@ int vnodeBegin(SVnode *pVnode) {
return
0
;
}
void
vnodeUpdCommitSched
(
SVnode
*
pVnode
)
{
int64_t
randNum
=
taosRand
();
pVnode
->
commitSched
.
commitMs
=
taosGetMonoTimestampMs
();
pVnode
->
commitSched
.
maxWaitMs
=
SYNC_VND_COMMIT_MAX_MS
+
(
randNum
%
SYNC_VND_COMMIT_MAX_MS
);
}
int
vnodeShouldCommit
(
SVnode
*
pVnode
)
{
if
(
!
pVnode
->
inUse
||
!
osDataSpaceAvailable
())
{
return
false
;
}
SVCommitSched
*
pSched
=
&
pVnode
->
commitSched
;
int64_t
nowMs
=
taosGetMonoTimestampMs
();
return
(((
pVnode
->
inUse
->
size
>
pVnode
->
inUse
->
node
.
size
)
&&
(
p
Vnode
->
commitMs
+
SYNC_VND_COMMIT_MIN_MS
<
nowMs
))
||
(
pVnode
->
inUse
->
size
>
0
&&
p
Vnode
->
commitMs
+
SYNC_VND_COMMIT_MAX_MS
<
nowMs
));
return
(((
pVnode
->
inUse
->
size
>
pVnode
->
inUse
->
node
.
size
)
&&
(
p
Sched
->
commitMs
+
SYNC_VND_COMMIT_MIN_MS
<
nowMs
))
||
(
pVnode
->
inUse
->
size
>
0
&&
p
Sched
->
commitMs
+
pSched
->
maxWaitMs
<
nowMs
));
}
int
vnodeShouldCommitOld
(
SVnode
*
pVnode
)
{
...
...
@@ -306,7 +313,7 @@ static int vnodeCommitImpl(SCommitInfo *pInfo) {
vInfo
(
"vgId:%d, start to commit, commitId:%"
PRId64
" version:%"
PRId64
" term: %"
PRId64
,
TD_VID
(
pVnode
),
pInfo
->
info
.
state
.
commitID
,
pInfo
->
info
.
state
.
committed
,
pInfo
->
info
.
state
.
commitTerm
);
pVnode
->
commitMs
=
taosGetMonoTimestampMs
(
);
vnodeUpdCommitSched
(
pVnode
);
// persist wal before starting
if
(
walPersist
(
pVnode
->
pWal
)
<
0
)
{
...
...
source/dnode/vnode/src/vnd/vnodeOpen.c
浏览文件 @
92e05b8e
...
...
@@ -142,7 +142,6 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
pVnode
->
path
=
(
char
*
)
&
pVnode
[
1
];
strcpy
(
pVnode
->
path
,
path
);
pVnode
->
config
=
info
.
config
;
pVnode
->
commitMs
=
taosGetMonoTimestampMs
();
pVnode
->
state
.
committed
=
info
.
state
.
committed
;
pVnode
->
state
.
commitTerm
=
info
.
state
.
commitTerm
;
pVnode
->
state
.
commitID
=
info
.
state
.
commitID
;
...
...
@@ -158,6 +157,8 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
taosThreadMutexInit
(
&
pVnode
->
mutex
,
NULL
);
taosThreadCondInit
(
&
pVnode
->
poolNotEmpty
,
NULL
);
vnodeUpdCommitSched
(
pVnode
);
int8_t
rollback
=
vnodeShouldRollback
(
pVnode
);
// open buffer pool
...
...
source/dnode/vnode/src/vnd/vnodeSync.c
浏览文件 @
92e05b8e
...
...
@@ -154,7 +154,7 @@ void vnodeProposeCommitOnNeed(SVnode *pVnode) {
vInfo
(
"vgId:%d, proposed vnode commit"
,
pVnode
->
config
.
vgId
);
_out:
pVnode
->
commitMs
=
taosGetMonoTimestampMs
(
);
vnodeUpdCommitSched
(
pVnode
);
rpcFreeCont
(
rpcMsg
.
pCont
);
rpcMsg
.
pCont
=
NULL
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录