Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
93aa8f9a
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
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看板
未验证
提交
93aa8f9a
编写于
7月 29, 2022
作者:
L
Li Minghao
提交者:
GitHub
7月 29, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15568 from taosdata/feature/3.0_mhli
refactor(sync): speed up sync point
上级
29c94d17
e0e23fc2
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
139 addition
and
4 deletion
+139
-4
source/libs/sync/src/syncAppendEntriesReply.c
source/libs/sync/src/syncAppendEntriesReply.c
+5
-0
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+8
-2
source/libs/sync/src/syncReplication.c
source/libs/sync/src/syncReplication.c
+4
-2
source/libs/sync/test/sh/auto_bench.sh
source/libs/sync/test/sh/auto_bench.sh
+45
-0
source/libs/sync/test/sh/insert.tpl.json
source/libs/sync/test/sh/insert.tpl.json
+77
-0
未找到文件。
source/libs/sync/src/syncAppendEntriesReply.c
浏览文件 @
93aa8f9a
...
...
@@ -213,6 +213,11 @@ int32_t syncNodeOnAppendEntriesReplySnapshot2Cb(SSyncNode* ths, SyncAppendEntrie
if
(
nextIndex
>
SYNC_INDEX_BEGIN
)
{
--
nextIndex
;
// speed up
if
(
nextIndex
>
pMsg
->
matchIndex
+
1
)
{
nextIndex
=
pMsg
->
matchIndex
+
1
;
}
bool
needStartSnapshot
=
false
;
if
(
nextIndex
>=
SYNC_INDEX_BEGIN
&&
!
ths
->
pLogStore
->
syncLogExist
(
ths
->
pLogStore
,
nextIndex
))
{
needStartSnapshot
=
true
;
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
93aa8f9a
...
...
@@ -2222,13 +2222,18 @@ SyncTerm syncNodeGetPreTerm(SSyncNode* pSyncNode, SyncIndex index) {
SyncIndex
preIndex
=
index
-
1
;
SSyncRaftEntry
*
pPreEntry
=
NULL
;
int32_t
code
=
pSyncNode
->
pLogStore
->
syncLogGetEntry
(
pSyncNode
->
pLogStore
,
preIndex
,
&
pPreEntry
);
SSnapshot
snapshot
=
{.
data
=
NULL
,
.
lastApplyIndex
=
SYNC_INDEX_INVALID
,
.
lastApplyTerm
=
SYNC_TERM_INVALID
,
.
lastConfigIndex
=
SYNC_INDEX_INVALID
};
if
(
code
==
0
)
{
ASSERT
(
pPreEntry
!=
NULL
);
preTerm
=
pPreEntry
->
term
;
taosMemoryFree
(
pPreEntry
);
return
preTerm
;
}
else
{
SSnapshot
snapshot
=
{.
data
=
NULL
,
.
lastApplyIndex
=
-
1
,
.
lastApplyTerm
=
0
,
.
lastConfigIndex
=
-
1
};
if
(
pSyncNode
->
pFsm
->
FpGetSnapshotInfo
!=
NULL
)
{
pSyncNode
->
pFsm
->
FpGetSnapshotInfo
(
pSyncNode
->
pFsm
,
&
snapshot
);
if
(
snapshot
.
lastApplyIndex
==
preIndex
)
{
...
...
@@ -2239,7 +2244,8 @@ SyncTerm syncNodeGetPreTerm(SSyncNode* pSyncNode, SyncIndex index) {
do
{
char
logBuf
[
128
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"sync node get pre term error, index:%"
PRId64
,
index
);
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"sync node get pre term error, index:%ld, snap-index:%ld, snap-term:%lu"
,
index
,
snapshot
.
lastApplyIndex
,
snapshot
.
lastApplyTerm
);
syncNodeErrorLog
(
pSyncNode
,
logBuf
);
}
while
(
0
);
...
...
source/libs/sync/src/syncReplication.c
浏览文件 @
93aa8f9a
...
...
@@ -132,7 +132,8 @@ int32_t syncNodeAppendEntriesPeersSnapshot2(SSyncNode* pSyncNode) {
SyncIndex
preLogIndex
=
syncNodeGetPreIndex
(
pSyncNode
,
nextIndex
);
SyncTerm
preLogTerm
=
syncNodeGetPreTerm
(
pSyncNode
,
nextIndex
);
if
(
preLogTerm
==
SYNC_TERM_INVALID
)
{
SyncIndex
newNextIndex
=
syncNodeGetLastIndex
(
pSyncNode
)
+
1
;
// SyncIndex newNextIndex = syncNodeGetLastIndex(pSyncNode) + 1;
SyncIndex
newNextIndex
=
nextIndex
+
1
;
syncIndexMgrSetIndex
(
pSyncNode
->
pNextIndex
,
pDestId
,
newNextIndex
);
syncIndexMgrSetIndex
(
pSyncNode
->
pMatchIndex
,
pDestId
,
SYNC_INDEX_INVALID
);
sError
(
"vgId:%d sync get pre term error, nextIndex:%"
PRId64
", update next-index:%"
PRId64
...
...
@@ -222,7 +223,8 @@ int32_t syncNodeAppendEntriesPeersSnapshot(SSyncNode* pSyncNode) {
SyncIndex
preLogIndex
=
syncNodeGetPreIndex
(
pSyncNode
,
nextIndex
);
SyncTerm
preLogTerm
=
syncNodeGetPreTerm
(
pSyncNode
,
nextIndex
);
if
(
preLogTerm
==
SYNC_TERM_INVALID
)
{
SyncIndex
newNextIndex
=
syncNodeGetLastIndex
(
pSyncNode
)
+
1
;
// SyncIndex newNextIndex = syncNodeGetLastIndex(pSyncNode) + 1;
SyncIndex
newNextIndex
=
nextIndex
+
1
;
syncIndexMgrSetIndex
(
pSyncNode
->
pNextIndex
,
pDestId
,
newNextIndex
);
syncIndexMgrSetIndex
(
pSyncNode
->
pMatchIndex
,
pDestId
,
SYNC_INDEX_INVALID
);
sError
(
"vgId:%d sync get pre term error, nextIndex:%"
PRId64
", update next-index:%"
PRId64
...
...
source/libs/sync/test/sh/auto_bench.sh
0 → 100644
浏览文件 @
93aa8f9a
#!/bin/bash
if
[
$#
!=
5
]
;
then
echo
"Uasge:
$0
instances vgroups replica ctables rows"
echo
""
exit
1
fi
instances
=
$1
vgroups
=
$2
replica
=
$3
ctables
=
$4
rows
=
$5
echo
"params: instances:
${
instances
}
, vgroups:
${
vgroups
}
, replica:
${
replica
}
, ctables:
${
ctables
}
, rows:
${
rows
}
"
dt
=
`
date
"+%Y-%m-%d-%H-%M-%S"
`
casedir
=
instances_
${
instances
}
_vgroups_
${
vgroups
}
_replica_
${
replica
}
_ctables_
${
ctables
}
_rows_
${
rows
}
_
${
dt
}
mkdir
${
casedir
}
cp
./insert.tpl.json
${
casedir
}
cd
${
casedir
}
for
i
in
`
seq
1
${
instances
}
`
;
do
#echo ===$i===
cfg_file
=
bench_
${
i
}
.json
cp
./insert.tpl.json
${
cfg_file
}
rstfile
=
result_
${
i
}
sed
-i
's/tpl_vgroups_tpl/'
${
vgroups
}
'/g'
${
cfg_file
}
sed
-i
's/tpl_replica_tpl/'
${
replica
}
'/g'
${
cfg_file
}
sed
-i
's/tpl_ctables_tpl/'
${
ctables
}
'/g'
${
cfg_file
}
sed
-i
's/tpl_stid_tpl/'
${
i
}
'/g'
${
cfg_file
}
sed
-i
's/tpl_rows_tpl/'
${
rows
}
'/g'
${
cfg_file
}
sed
-i
's/tpl_insert_result_tpl/'
${
rstfile
}
'/g'
${
cfg_file
}
done
for
conf_file
in
`
ls
./bench_
*
.json
`
;
do
echo
"nohup taosBenchmark -f
${
conf_file
}
&"
nohup
taosBenchmark
-f
${
conf_file
}
&
done
cd
-
exit
0
source/libs/sync/test/sh/insert.tpl.json
0 → 100644
浏览文件 @
93aa8f9a
{
"filetype"
:
"insert"
,
"cfgdir"
:
"/etc/taos/"
,
"host"
:
"v3cluster-0001"
,
"port"
:
7100
,
"user"
:
"root"
,
"password"
:
"taosdata"
,
"thread_count"
:
8
,
"thread_count_create_tbl"
:
8
,
"result_file"
:
"./tpl_insert_result_tpl"
,
"confirm_parameter_prompt"
:
"no"
,
"insert_interval"
:
0
,
"interlace_rows"
:
0
,
"num_of_records_per_req"
:
100000
,
"databases"
:
[
{
"dbinfo"
:
{
"name"
:
"db1"
,
"drop"
:
"yes"
,
"vgroups"
:
tpl_vgroups_tpl
,
"replica"
:
tpl_replica_tpl
},
"super_tables"
:
[
{
"name"
:
"stb_tpl_stid_tpl"
,
"child_table_exists"
:
"no"
,
"childtable_count"
:
tpl_ctables_tpl
,
"childtable_prefix"
:
"stb_tpl_stid_tpl_"
,
"auto_create_table"
:
"no"
,
"batch_create_tbl_num"
:
50000
,
"data_source"
:
"rand"
,
"insert_mode"
:
"taosc"
,
"insert_rows"
:
tpl_rows_tpl
,
"interlace_rows"
:
0
,
"insert_interval"
:
0
,
"max_sql_len"
:
10000000
,
"disorder_ratio"
:
0
,
"disorder_range"
:
1000
,
"timestamp_step"
:
10
,
"sample_format"
:
"csv"
,
"use_sample_ts"
:
"no"
,
"tags_file"
:
""
,
"columns"
:
[
{
"type"
:
"INT"
},
{
"type"
:
"DOUBLE"
,
"count"
:
1
},
{
"type"
:
"BINARY"
,
"len"
:
40
,
"count"
:
1
},
{
"type"
:
"nchar"
,
"len"
:
20
,
"count"
:
1
}
],
"tags"
:
[
{
"type"
:
"TINYINT"
,
"count"
:
1
},
{
"type"
:
"BINARY"
,
"len"
:
16
,
"count"
:
1
}
]
}
]
}
]
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录