Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
94948c6f
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
未验证
提交
94948c6f
编写于
7月 21, 2022
作者:
L
Li Minghao
提交者:
GitHub
7月 21, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15238 from taosdata/feature/3.0_mhli
fix(sync): raft store persist
上级
3ae378e0
8915486e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
70 addition
and
12 deletion
+70
-12
source/libs/sync/src/syncAppendEntries.c
source/libs/sync/src/syncAppendEntries.c
+6
-6
source/libs/sync/src/syncRaftStore.c
source/libs/sync/src/syncRaftStore.c
+6
-6
source/libs/sync/test/sh/a.sh
source/libs/sync/test/sh/a.sh
+58
-0
未找到文件。
source/libs/sync/src/syncAppendEntries.c
浏览文件 @
94948c6f
...
...
@@ -473,13 +473,13 @@ static bool syncNodeOnAppendEntriesBatchLogOK(SSyncNode* pSyncNode, SyncAppendEn
SyncIndex
myLastIndex
=
syncNodeGetLastIndex
(
pSyncNode
);
if
(
pMsg
->
prevLogIndex
>
myLastIndex
)
{
sDebug
(
"vgId:%d sync log not ok, preindex:%"
PRId64
,
pSyncNode
->
vgId
,
pMsg
->
prevLogIndex
);
sDebug
(
"vgId:%d
,
sync log not ok, preindex:%"
PRId64
,
pSyncNode
->
vgId
,
pMsg
->
prevLogIndex
);
return
false
;
}
SyncTerm
myPreLogTerm
=
syncNodeGetPreTerm
(
pSyncNode
,
pMsg
->
prevLogIndex
+
1
);
if
(
myPreLogTerm
==
SYNC_TERM_INVALID
)
{
sDebug
(
"vgId:%d sync log not ok2, preindex:%"
PRId64
,
pSyncNode
->
vgId
,
pMsg
->
prevLogIndex
);
sDebug
(
"vgId:%d
,
sync log not ok2, preindex:%"
PRId64
,
pSyncNode
->
vgId
,
pMsg
->
prevLogIndex
);
return
false
;
}
...
...
@@ -487,7 +487,7 @@ static bool syncNodeOnAppendEntriesBatchLogOK(SSyncNode* pSyncNode, SyncAppendEn
return
true
;
}
sDebug
(
"vgId:%d sync log not ok3, preindex:%"
PRId64
,
pSyncNode
->
vgId
,
pMsg
->
prevLogIndex
);
sDebug
(
"vgId:%d
,
sync log not ok3, preindex:%"
PRId64
,
pSyncNode
->
vgId
,
pMsg
->
prevLogIndex
);
return
false
;
}
...
...
@@ -500,13 +500,13 @@ static bool syncNodeOnAppendEntriesLogOK(SSyncNode* pSyncNode, SyncAppendEntries
SyncIndex
myLastIndex
=
syncNodeGetLastIndex
(
pSyncNode
);
if
(
pMsg
->
prevLogIndex
>
myLastIndex
)
{
sDebug
(
"vgId:%d sync log not ok, preindex:%"
PRId64
,
pSyncNode
->
vgId
,
pMsg
->
prevLogIndex
);
sDebug
(
"vgId:%d
,
sync log not ok, preindex:%"
PRId64
,
pSyncNode
->
vgId
,
pMsg
->
prevLogIndex
);
return
false
;
}
SyncTerm
myPreLogTerm
=
syncNodeGetPreTerm
(
pSyncNode
,
pMsg
->
prevLogIndex
+
1
);
if
(
myPreLogTerm
==
SYNC_TERM_INVALID
)
{
sDebug
(
"vgId:%d sync log not ok2, preindex:%"
PRId64
,
pSyncNode
->
vgId
,
pMsg
->
prevLogIndex
);
sDebug
(
"vgId:%d
,
sync log not ok2, preindex:%"
PRId64
,
pSyncNode
->
vgId
,
pMsg
->
prevLogIndex
);
return
false
;
}
...
...
@@ -514,7 +514,7 @@ static bool syncNodeOnAppendEntriesLogOK(SSyncNode* pSyncNode, SyncAppendEntries
return
true
;
}
sDebug
(
"vgId:%d sync log not ok3, preindex:%"
PRId64
,
pSyncNode
->
vgId
,
pMsg
->
prevLogIndex
);
sDebug
(
"vgId:%d
,
sync log not ok3, preindex:%"
PRId64
,
pSyncNode
->
vgId
,
pMsg
->
prevLogIndex
);
return
false
;
}
...
...
source/libs/sync/src/syncRaftStore.c
浏览文件 @
94948c6f
...
...
@@ -108,10 +108,10 @@ int32_t raftStoreSerialize(SRaftStore *pRaftStore, char *buf, size_t len) {
cJSON
*
pRoot
=
cJSON_CreateObject
();
char
u64Buf
[
128
]
=
{
0
};
snprintf
(
u64Buf
,
sizeof
(
u64Buf
),
""
PRIu64
""
,
pRaftStore
->
currentTerm
);
snprintf
(
u64Buf
,
sizeof
(
u64Buf
),
"
%
"
PRIu64
""
,
pRaftStore
->
currentTerm
);
cJSON_AddStringToObject
(
pRoot
,
"current_term"
,
u64Buf
);
snprintf
(
u64Buf
,
sizeof
(
u64Buf
),
""
PRIu64
""
,
pRaftStore
->
voteFor
.
addr
);
snprintf
(
u64Buf
,
sizeof
(
u64Buf
),
"
%
"
PRIu64
""
,
pRaftStore
->
voteFor
.
addr
);
cJSON_AddStringToObject
(
pRoot
,
"vote_for_addr"
,
u64Buf
);
cJSON_AddNumberToObject
(
pRoot
,
"vote_for_vgid"
,
pRaftStore
->
voteFor
.
vgId
);
...
...
@@ -142,11 +142,11 @@ int32_t raftStoreDeserialize(SRaftStore *pRaftStore, char *buf, size_t len) {
cJSON
*
pCurrentTerm
=
cJSON_GetObjectItem
(
pRoot
,
"current_term"
);
ASSERT
(
cJSON_IsString
(
pCurrentTerm
));
sscanf
(
pCurrentTerm
->
valuestring
,
""
PRIu64
""
,
&
(
pRaftStore
->
currentTerm
));
sscanf
(
pCurrentTerm
->
valuestring
,
"
%
"
PRIu64
""
,
&
(
pRaftStore
->
currentTerm
));
cJSON
*
pVoteForAddr
=
cJSON_GetObjectItem
(
pRoot
,
"vote_for_addr"
);
ASSERT
(
cJSON_IsString
(
pVoteForAddr
));
sscanf
(
pVoteForAddr
->
valuestring
,
""
PRIu64
""
,
&
(
pRaftStore
->
voteFor
.
addr
));
sscanf
(
pVoteForAddr
->
valuestring
,
"
%
"
PRIu64
""
,
&
(
pRaftStore
->
voteFor
.
addr
));
cJSON
*
pVoteForVgid
=
cJSON_GetObjectItem
(
pRoot
,
"vote_for_vgid"
);
pRaftStore
->
voteFor
.
vgId
=
pVoteForVgid
->
valueint
;
...
...
@@ -188,11 +188,11 @@ cJSON *raftStore2Json(SRaftStore *pRaftStore) {
cJSON
*
pRoot
=
cJSON_CreateObject
();
if
(
pRaftStore
!=
NULL
)
{
snprintf
(
u64buf
,
sizeof
(
u64buf
),
""
PRIu64
""
,
pRaftStore
->
currentTerm
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"
%
"
PRIu64
""
,
pRaftStore
->
currentTerm
);
cJSON_AddStringToObject
(
pRoot
,
"currentTerm"
,
u64buf
);
cJSON
*
pVoteFor
=
cJSON_CreateObject
();
snprintf
(
u64buf
,
sizeof
(
u64buf
),
""
PRIu64
""
,
pRaftStore
->
voteFor
.
addr
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"
%
"
PRIu64
""
,
pRaftStore
->
voteFor
.
addr
);
cJSON_AddStringToObject
(
pVoteFor
,
"addr"
,
u64buf
);
{
uint64_t
u64
=
pRaftStore
->
voteFor
.
addr
;
...
...
source/libs/sync/test/sh/a.sh
0 → 100644
浏览文件 @
94948c6f
#!/bin/bash
if
[
$#
!=
1
]
;
then
echo
"Uasge:
$0
log-path"
echo
""
exit
1
fi
logpath
=
$1
echo
"logpath:
${
logpath
}
"
echo
""
echo
"clean old log ..."
rm
-f
${
logpath
}
/log.
*
echo
""
echo
"generate log.dnode ..."
for
dnode
in
`
ls
${
logpath
}
|
grep
dnode
`
;
do
echo
"generate log.
${
dnode
}
"
cat
${
logpath
}
/
${
dnode
}
/log/taosdlog.
*
|
grep
SYN
>
${
logpath
}
/log.
${
dnode
}
done
echo
""
echo
"generate vgId ..."
cat
${
logpath
}
/log.dnode
*
|
grep
"vgId:"
|
grep
-v
ERROR |
awk
'{print $5}'
|
sort
|
uniq
>
${
logpath
}
/log.vgIds.tmp
echo
"all vgIds:"
>
${
logpath
}
/log.vgIds
cat
${
logpath
}
/log.dnode
*
|
grep
"vgId:"
|
grep
-v
ERROR |
awk
'{print $5}'
|
sort
|
uniq
>>
${
logpath
}
/log.vgIds
for
dnode
in
`
ls
${
logpath
}
|
grep
dnode |
grep
-v
log
`
;
do
echo
""
>>
${
logpath
}
/log.vgIds
echo
""
>>
${
logpath
}
/log.vgIds
echo
"
${
dnode
}
:"
>>
${
logpath
}
/log.vgIds
cat
${
logpath
}
/
${
dnode
}
/log/taosdlog.
*
|
grep
SYN |
grep
"vgId:"
|
grep
-v
ERROR |
awk
'{print $5}'
|
sort
|
uniq
>>
${
logpath
}
/log.vgIds
done
echo
""
echo
"generate log.dnode.vgId ..."
for
logdnode
in
`
ls
${
logpath
}
/log.dnode
*
`
;
do
for
vgId
in
`
cat
${
logpath
}
/log.vgIds.tmp
`
;
do
rowNum
=
`
cat
${
logdnode
}
|
grep
"
${
vgId
}
"
|
awk
'BEGIN{rowNum=0}{rowNum++}END{print rowNum}'
`
#echo "-----${rowNum}"
if
[
$rowNum
-gt
0
]
;
then
echo
"generate
${
logdnode
}
.
${
vgId
}
"
cat
${
logdnode
}
|
grep
"
${
vgId
}
"
>
${
logdnode
}
.
${
vgId
}
fi
done
done
echo
""
echo
"generate log.dnode.main ..."
for
file
in
`
ls
${
logpath
}
/log.dnode
*
|
grep
-v
vgId
`
;
do
echo
"generate
${
file
}
.main"
cat
${
file
}
|
awk
'{ if(index($0, "sync open") > 0 || index($0, "sync close") > 0 || index($0, "become leader") > 0) {print $0} }'
>
${
file
}
.main
done
exit
0
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录