Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
715f53a8
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
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看板
提交
715f53a8
编写于
9月 30, 2022
作者:
B
Benguang Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: eliminate asserts on errors of appending or getting log entry
上级
9055f637
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
26 addition
and
8 deletion
+26
-8
source/libs/sync/src/syncAppendEntries.c
source/libs/sync/src/syncAppendEntries.c
+4
-0
source/libs/sync/src/syncCommit.c
source/libs/sync/src/syncCommit.c
+4
-1
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+5
-2
source/libs/sync/src/syncRaftLog.c
source/libs/sync/src/syncRaftLog.c
+13
-5
未找到文件。
source/libs/sync/src/syncAppendEntries.c
浏览文件 @
715f53a8
...
@@ -579,6 +579,7 @@ int32_t syncNodeOnAppendEntriesSnapshot2Cb(SSyncNode* ths, SyncAppendEntriesBatc
...
@@ -579,6 +579,7 @@ int32_t syncNodeOnAppendEntriesSnapshot2Cb(SSyncNode* ths, SyncAppendEntriesBatc
SSyncRaftEntry
*
pAppendEntry
=
(
SSyncRaftEntry
*
)(
pMsg
->
data
+
metaTableArr
[
i
].
offset
);
SSyncRaftEntry
*
pAppendEntry
=
(
SSyncRaftEntry
*
)(
pMsg
->
data
+
metaTableArr
[
i
].
offset
);
code
=
ths
->
pLogStore
->
syncLogAppendEntry
(
ths
->
pLogStore
,
pAppendEntry
);
code
=
ths
->
pLogStore
->
syncLogAppendEntry
(
ths
->
pLogStore
,
pAppendEntry
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
sError
(
"vgId:%d, failed to append log entry since %s"
,
ths
->
vgId
,
tstrerror
(
terrno
));
return
-
1
;
return
-
1
;
}
}
...
@@ -710,6 +711,7 @@ int32_t syncNodeOnAppendEntriesSnapshot2Cb(SSyncNode* ths, SyncAppendEntriesBatc
...
@@ -710,6 +711,7 @@ int32_t syncNodeOnAppendEntriesSnapshot2Cb(SSyncNode* ths, SyncAppendEntriesBatc
SSyncRaftEntry
*
pAppendEntry
=
(
SSyncRaftEntry
*
)(
pMsg
->
data
+
metaTableArr
[
i
].
offset
);
SSyncRaftEntry
*
pAppendEntry
=
(
SSyncRaftEntry
*
)(
pMsg
->
data
+
metaTableArr
[
i
].
offset
);
code
=
ths
->
pLogStore
->
syncLogAppendEntry
(
ths
->
pLogStore
,
pAppendEntry
);
code
=
ths
->
pLogStore
->
syncLogAppendEntry
(
ths
->
pLogStore
,
pAppendEntry
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
sError
(
"vgId:%d, failed to append log entry since %s"
,
ths
->
vgId
,
tstrerror
(
terrno
));
return
-
1
;
return
-
1
;
}
}
...
@@ -859,6 +861,7 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
...
@@ -859,6 +861,7 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
code
=
ths
->
pLogStore
->
syncLogAppendEntry
(
ths
->
pLogStore
,
pAppendEntry
);
code
=
ths
->
pLogStore
->
syncLogAppendEntry
(
ths
->
pLogStore
,
pAppendEntry
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
sError
(
"vgId:%d, failed to append log entry since %s"
,
ths
->
vgId
,
tstrerror
(
terrno
));
return
-
1
;
return
-
1
;
}
}
...
@@ -974,6 +977,7 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
...
@@ -974,6 +977,7 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
code
=
ths
->
pLogStore
->
syncLogAppendEntry
(
ths
->
pLogStore
,
pAppendEntry
);
code
=
ths
->
pLogStore
->
syncLogAppendEntry
(
ths
->
pLogStore
,
pAppendEntry
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
sError
(
"vgId:%d, failed to append log entry since %s"
,
ths
->
vgId
,
tstrerror
(
terrno
));
return
-
1
;
return
-
1
;
}
}
...
...
source/libs/sync/src/syncCommit.c
浏览文件 @
715f53a8
...
@@ -76,7 +76,10 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) {
...
@@ -76,7 +76,10 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) {
pEntry
=
(
SSyncRaftEntry
*
)
taosLRUCacheValue
(
pCache
,
h
);
pEntry
=
(
SSyncRaftEntry
*
)
taosLRUCacheValue
(
pCache
,
h
);
}
else
{
}
else
{
pEntry
=
pSyncNode
->
pLogStore
->
getEntry
(
pSyncNode
->
pLogStore
,
index
);
pEntry
=
pSyncNode
->
pLogStore
->
getEntry
(
pSyncNode
->
pLogStore
,
index
);
ASSERT
(
pEntry
!=
NULL
);
if
(
pEntry
==
NULL
)
{
sError
(
"failed to get entry since %s. index:%lld"
,
tstrerror
(
terrno
),
index
);
return
;
}
}
}
// cannot commit, even if quorum agree. need check term!
// cannot commit, even if quorum agree. need check term!
if
(
pEntry
->
term
<=
pSyncNode
->
pRaftStore
->
currentTerm
)
{
if
(
pEntry
->
term
<=
pSyncNode
->
pRaftStore
->
currentTerm
)
{
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
715f53a8
...
@@ -2650,7 +2650,10 @@ static int32_t syncNodeAppendNoop(SSyncNode* ths) {
...
@@ -2650,7 +2650,10 @@ static int32_t syncNodeAppendNoop(SSyncNode* ths) {
if
(
ths
->
state
==
TAOS_SYNC_STATE_LEADER
)
{
if
(
ths
->
state
==
TAOS_SYNC_STATE_LEADER
)
{
int32_t
code
=
ths
->
pLogStore
->
syncLogAppendEntry
(
ths
->
pLogStore
,
pEntry
);
int32_t
code
=
ths
->
pLogStore
->
syncLogAppendEntry
(
ths
->
pLogStore
,
pEntry
);
ASSERT
(
code
==
0
);
if
(
code
!=
0
)
{
sError
(
"vgId:%d, failed to append log entry since %s"
,
ths
->
vgId
,
tstrerror
(
terrno
));
return
-
1
;
}
syncNodeReplicate
(
ths
,
false
);
syncNodeReplicate
(
ths
,
false
);
}
}
...
@@ -2790,8 +2793,8 @@ int32_t syncNodeOnClientRequestBatchCb(SSyncNode* ths, SyncClientRequestBatch* p
...
@@ -2790,8 +2793,8 @@ int32_t syncNodeOnClientRequestBatchCb(SSyncNode* ths, SyncClientRequestBatch* p
code
=
ths
->
pLogStore
->
syncLogAppendEntry
(
ths
->
pLogStore
,
pEntry
);
code
=
ths
->
pLogStore
->
syncLogAppendEntry
(
ths
->
pLogStore
,
pEntry
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
sError
(
"vgId:%d, failed to append log entry since %s"
,
ths
->
vgId
,
tstrerror
(
terrno
));
// del resp mgr, call FpCommitCb
// del resp mgr, call FpCommitCb
ASSERT
(
0
);
return
-
1
;
return
-
1
;
}
}
...
...
source/libs/sync/src/syncRaftLog.c
浏览文件 @
715f53a8
...
@@ -412,13 +412,11 @@ int32_t logStoreAppendEntry(SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry) {
...
@@ -412,13 +412,11 @@ int32_t logStoreAppendEntry(SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry) {
return
0
;
return
0
;
}
}
SSyncRaftEntry
*
logStoreGetEntry
(
SSyncLogStore
*
pLogStore
,
SyncIndex
index
)
{
SSyncRaftEntry
*
logStoreGetEntry
WithoutLock
(
SSyncLogStore
*
pLogStore
,
SyncIndex
index
)
{
SSyncLogStoreData
*
pData
=
pLogStore
->
data
;
SSyncLogStoreData
*
pData
=
pLogStore
->
data
;
SWal
*
pWal
=
pData
->
pWal
;
SWal
*
pWal
=
pData
->
pWal
;
if
(
index
>=
SYNC_INDEX_BEGIN
&&
index
<=
logStoreLastIndex
(
pLogStore
))
{
if
(
index
>=
SYNC_INDEX_BEGIN
&&
index
<=
logStoreLastIndex
(
pLogStore
))
{
taosThreadMutexLock
(
&
(
pData
->
mutex
));
// SWalReadHandle* pWalHandle = walOpenReadHandle(pWal);
// SWalReadHandle* pWalHandle = walOpenReadHandle(pWal);
SWalReader
*
pWalHandle
=
pData
->
pWalHandle
;
SWalReader
*
pWalHandle
=
pData
->
pWalHandle
;
ASSERT
(
pWalHandle
!=
NULL
);
ASSERT
(
pWalHandle
!=
NULL
);
...
@@ -442,7 +440,8 @@ SSyncRaftEntry* logStoreGetEntry(SSyncLogStore* pLogStore, SyncIndex index) {
...
@@ -442,7 +440,8 @@ SSyncRaftEntry* logStoreGetEntry(SSyncLogStore* pLogStore, SyncIndex index) {
}
}
}
while
(
0
);
}
while
(
0
);
ASSERT
(
0
);
sError
(
"failed to read ver since %s. index:%lld"
,
tstrerror
(
terrno
),
index
);
return
NULL
;
}
}
SSyncRaftEntry
*
pEntry
=
syncEntryBuild
(
pWalHandle
->
pHead
->
head
.
bodyLen
);
SSyncRaftEntry
*
pEntry
=
syncEntryBuild
(
pWalHandle
->
pHead
->
head
.
bodyLen
);
...
@@ -463,7 +462,6 @@ SSyncRaftEntry* logStoreGetEntry(SSyncLogStore* pLogStore, SyncIndex index) {
...
@@ -463,7 +462,6 @@ SSyncRaftEntry* logStoreGetEntry(SSyncLogStore* pLogStore, SyncIndex index) {
terrno = saveErr;
terrno = saveErr;
*/
*/
taosThreadMutexUnlock
(
&
(
pData
->
mutex
));
return
pEntry
;
return
pEntry
;
}
else
{
}
else
{
...
@@ -471,6 +469,16 @@ SSyncRaftEntry* logStoreGetEntry(SSyncLogStore* pLogStore, SyncIndex index) {
...
@@ -471,6 +469,16 @@ SSyncRaftEntry* logStoreGetEntry(SSyncLogStore* pLogStore, SyncIndex index) {
}
}
}
}
SSyncRaftEntry
*
logStoreGetEntry
(
SSyncLogStore
*
pLogStore
,
SyncIndex
index
)
{
SSyncLogStoreData
*
pData
=
pLogStore
->
data
;
SSyncRaftEntry
*
pEntry
=
NULL
;
taosThreadMutexLock
(
&
pData
->
mutex
);
pEntry
=
logStoreGetEntryWithoutLock
(
pLogStore
,
index
);
taosThreadMutexUnlock
(
&
pData
->
mutex
);
return
pEntry
;
}
int32_t
logStoreTruncate
(
SSyncLogStore
*
pLogStore
,
SyncIndex
fromIndex
)
{
int32_t
logStoreTruncate
(
SSyncLogStore
*
pLogStore
,
SyncIndex
fromIndex
)
{
SSyncLogStoreData
*
pData
=
pLogStore
->
data
;
SSyncLogStoreData
*
pData
=
pLogStore
->
data
;
SWal
*
pWal
=
pData
->
pWal
;
SWal
*
pWal
=
pData
->
pWal
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录