Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5a4cc360
T
TDengine
项目概览
taosdata
/
TDengine
11 个月 前同步成功
通知
1179
Star
22014
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5a4cc360
编写于
1月 11, 2023
作者:
B
Benguang Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: skip WAL forceSync for single replica vgroup
上级
6af99d75
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
15 addition
and
13 deletion
+15
-13
include/libs/sync/sync.h
include/libs/sync/sync.h
+1
-1
source/libs/sync/src/syncAppendEntries.c
source/libs/sync/src/syncAppendEntries.c
+2
-2
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+2
-2
source/libs/sync/src/syncPipeline.c
source/libs/sync/src/syncPipeline.c
+8
-3
source/libs/sync/src/syncRaftLog.c
source/libs/sync/src/syncRaftLog.c
+2
-5
未找到文件。
include/libs/sync/sync.h
浏览文件 @
5a4cc360
...
...
@@ -193,7 +193,7 @@ typedef struct SSyncLogStore {
SyncIndex
(
*
syncLogLastIndex
)(
struct
SSyncLogStore
*
pLogStore
);
SyncTerm
(
*
syncLogLastTerm
)(
struct
SSyncLogStore
*
pLogStore
);
int32_t
(
*
syncLogAppendEntry
)(
struct
SSyncLogStore
*
pLogStore
,
SSyncRaftEntry
*
pEntry
);
int32_t
(
*
syncLogAppendEntry
)(
struct
SSyncLogStore
*
pLogStore
,
SSyncRaftEntry
*
pEntry
,
bool
forcSync
);
int32_t
(
*
syncLogGetEntry
)(
struct
SSyncLogStore
*
pLogStore
,
SyncIndex
index
,
SSyncRaftEntry
**
ppEntry
);
int32_t
(
*
syncLogTruncate
)(
struct
SSyncLogStore
*
pLogStore
,
SyncIndex
fromIndex
);
...
...
source/libs/sync/src/syncAppendEntries.c
浏览文件 @
5a4cc360
...
...
@@ -357,7 +357,7 @@ int32_t syncNodeOnAppendEntriesOld(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
ASSERT
(
pAppendEntry
->
index
==
appendIndex
);
// append
code
=
ths
->
pLogStore
->
syncLogAppendEntry
(
ths
->
pLogStore
,
pAppendEntry
);
code
=
ths
->
pLogStore
->
syncLogAppendEntry
(
ths
->
pLogStore
,
pAppendEntry
,
false
);
if
(
code
!=
0
)
{
char
logBuf
[
128
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"ignore, append error, append-index:%"
PRId64
,
appendIndex
);
...
...
@@ -398,7 +398,7 @@ int32_t syncNodeOnAppendEntriesOld(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
}
// append
code
=
ths
->
pLogStore
->
syncLogAppendEntry
(
ths
->
pLogStore
,
pAppendEntry
);
code
=
ths
->
pLogStore
->
syncLogAppendEntry
(
ths
->
pLogStore
,
pAppendEntry
,
false
);
if
(
code
!=
0
)
{
char
logBuf
[
128
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"ignore, log not exist, append error, append-index:%"
PRId64
,
appendIndex
);
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
5a4cc360
...
...
@@ -2478,7 +2478,7 @@ static int32_t syncNodeAppendNoopOld(SSyncNode* ths) {
LRUHandle
*
h
=
NULL
;
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
,
false
);
if
(
code
!=
0
)
{
sError
(
"append noop error"
);
return
-
1
;
...
...
@@ -2721,7 +2721,7 @@ int32_t syncNodeOnClientRequestOld(SSyncNode* ths, SRpcMsg* pMsg, SyncIndex* pRe
if
(
ths
->
state
==
TAOS_SYNC_STATE_LEADER
)
{
// append entry
code
=
ths
->
pLogStore
->
syncLogAppendEntry
(
ths
->
pLogStore
,
pEntry
);
code
=
ths
->
pLogStore
->
syncLogAppendEntry
(
ths
->
pLogStore
,
pEntry
,
false
);
if
(
code
!=
0
)
{
if
(
ths
->
replicaNum
==
1
)
{
if
(
h
)
{
...
...
source/libs/sync/src/syncPipeline.c
浏览文件 @
5a4cc360
...
...
@@ -364,7 +364,11 @@ _out:
return
ret
;
}
int32_t
syncLogStorePersist
(
SSyncLogStore
*
pLogStore
,
SSyncRaftEntry
*
pEntry
)
{
static
inline
bool
syncLogStoreNeedFlush
(
SSyncRaftEntry
*
pEntry
,
int32_t
replicaNum
)
{
return
(
replicaNum
>
1
)
&&
(
pEntry
->
originalRpcType
==
TDMT_VND_COMMIT
);
}
int32_t
syncLogStorePersist
(
SSyncLogStore
*
pLogStore
,
SSyncNode
*
pNode
,
SSyncRaftEntry
*
pEntry
)
{
ASSERT
(
pEntry
->
index
>=
0
);
SyncIndex
lastVer
=
pLogStore
->
syncLogLastIndex
(
pLogStore
);
if
(
lastVer
>=
pEntry
->
index
&&
pLogStore
->
syncLogTruncate
(
pLogStore
,
pEntry
->
index
)
<
0
)
{
...
...
@@ -374,7 +378,8 @@ int32_t syncLogStorePersist(SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry) {
lastVer
=
pLogStore
->
syncLogLastIndex
(
pLogStore
);
ASSERT
(
pEntry
->
index
==
lastVer
+
1
);
if
(
pLogStore
->
syncLogAppendEntry
(
pLogStore
,
pEntry
)
<
0
)
{
bool
doFsync
=
syncLogStoreNeedFlush
(
pEntry
,
pNode
->
replicaNum
);
if
(
pLogStore
->
syncLogAppendEntry
(
pLogStore
,
pEntry
,
doFsync
)
<
0
)
{
sError
(
"failed to append sync log entry since %s. index:%"
PRId64
", term:%"
PRId64
""
,
terrstr
(),
pEntry
->
index
,
pEntry
->
term
);
return
-
1
;
...
...
@@ -436,7 +441,7 @@ int64_t syncLogBufferProceed(SSyncLogBuffer* pBuf, SSyncNode* pNode, SyncTerm* p
(
void
)
syncNodeReplicateWithoutLock
(
pNode
);
// persist
if
(
syncLogStorePersist
(
pLogStore
,
pEntry
)
<
0
)
{
if
(
syncLogStorePersist
(
pLogStore
,
p
Node
,
p
Entry
)
<
0
)
{
sError
(
"vgId:%d, failed to persist sync log entry from buffer since %s. index:%"
PRId64
,
pNode
->
vgId
,
terrstr
(),
pEntry
->
index
);
goto
_out
;
...
...
source/libs/sync/src/syncRaftLog.c
浏览文件 @
5a4cc360
...
...
@@ -23,7 +23,7 @@
// public function
static
int32_t
raftLogRestoreFromSnapshot
(
struct
SSyncLogStore
*
pLogStore
,
SyncIndex
snapshotIndex
);
static
int32_t
raftLogAppendEntry
(
struct
SSyncLogStore
*
pLogStore
,
SSyncRaftEntry
*
pEntry
);
static
int32_t
raftLogAppendEntry
(
struct
SSyncLogStore
*
pLogStore
,
SSyncRaftEntry
*
pEntry
,
bool
forceSync
);
static
int32_t
raftLogTruncate
(
struct
SSyncLogStore
*
pLogStore
,
SyncIndex
fromIndex
);
static
bool
raftLogExist
(
struct
SSyncLogStore
*
pLogStore
,
SyncIndex
index
);
static
int32_t
raftLogUpdateCommitIndex
(
SSyncLogStore
*
pLogStore
,
SyncIndex
index
);
...
...
@@ -192,9 +192,7 @@ SyncTerm raftLogLastTerm(struct SSyncLogStore* pLogStore) {
return
SYNC_TERM_INVALID
;
}
static
inline
bool
raftLogForceSync
(
SSyncRaftEntry
*
pEntry
)
{
return
(
pEntry
->
originalRpcType
==
TDMT_VND_COMMIT
);
}
static
int32_t
raftLogAppendEntry
(
struct
SSyncLogStore
*
pLogStore
,
SSyncRaftEntry
*
pEntry
)
{
static
int32_t
raftLogAppendEntry
(
struct
SSyncLogStore
*
pLogStore
,
SSyncRaftEntry
*
pEntry
,
bool
forceSync
)
{
SSyncLogStoreData
*
pData
=
pLogStore
->
data
;
SWal
*
pWal
=
pData
->
pWal
;
...
...
@@ -221,7 +219,6 @@ static int32_t raftLogAppendEntry(struct SSyncLogStore* pLogStore, SSyncRaftEntr
ASSERT
(
pEntry
->
index
==
index
);
bool
forceSync
=
raftLogForceSync
(
pEntry
);
walFsync
(
pWal
,
forceSync
);
sNTrace
(
pData
->
pSyncNode
,
"write index:%"
PRId64
", type:%s, origin type:%s, elapsed:%"
PRId64
,
pEntry
->
index
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录