Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b0f469ad
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看板
未验证
提交
b0f469ad
编写于
11月 07, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
11月 07, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #17931 from taosdata/feature/3.0_mhli
fix(sync): when apply queue not empty, can not read
上级
3e335478
b6aea6ae
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
31 addition
and
9 deletion
+31
-9
include/libs/sync/sync.h
include/libs/sync/sync.h
+1
-0
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+8
-0
source/dnode/vnode/src/vnd/vnodeSync.c
source/dnode/vnode/src/vnd/vnodeSync.c
+7
-0
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+15
-9
未找到文件。
include/libs/sync/sync.h
浏览文件 @
b0f469ad
...
...
@@ -138,6 +138,7 @@ typedef struct SSyncFSM {
void
(
*
FpRestoreFinishCb
)(
const
struct
SSyncFSM
*
pFsm
);
void
(
*
FpReConfigCb
)(
const
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
const
SReConfigCbMeta
*
pMeta
);
void
(
*
FpLeaderTransferCb
)(
const
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
const
SFsmCbMeta
*
pMeta
);
bool
(
*
FpApplyQueueEmptyCb
)(
const
struct
SSyncFSM
*
pFsm
);
void
(
*
FpBecomeLeaderCb
)(
const
struct
SSyncFSM
*
pFsm
);
void
(
*
FpBecomeFollowerCb
)(
const
struct
SSyncFSM
*
pFsm
);
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
b0f469ad
...
...
@@ -202,6 +202,13 @@ static void mndBecomeLeader(const SSyncFSM *pFsm) {
SMnode
*
pMnode
=
pFsm
->
data
;
}
static
bool
mndApplyQueueEmpty
(
const
SSyncFSM
*
pFsm
)
{
SMnode
*
pMnode
=
pFsm
->
data
;
int32_t
itemSize
=
tmsgGetQueueSize
(
&
pMnode
->
msgCb
,
1
,
APPLY_QUEUE
);
return
(
itemSize
==
0
);
}
SSyncFSM
*
mndSyncMakeFsm
(
SMnode
*
pMnode
)
{
SSyncFSM
*
pFsm
=
taosMemoryCalloc
(
1
,
sizeof
(
SSyncFSM
));
pFsm
->
data
=
pMnode
;
...
...
@@ -210,6 +217,7 @@ SSyncFSM *mndSyncMakeFsm(SMnode *pMnode) {
pFsm
->
FpRollBackCb
=
NULL
;
pFsm
->
FpRestoreFinishCb
=
mndRestoreFinish
;
pFsm
->
FpLeaderTransferCb
=
NULL
;
pFsm
->
FpApplyQueueEmptyCb
=
mndApplyQueueEmpty
;
pFsm
->
FpReConfigCb
=
NULL
;
pFsm
->
FpBecomeLeaderCb
=
mndBecomeLeader
;
pFsm
->
FpBecomeFollowerCb
=
mndBecomeFollower
;
...
...
source/dnode/vnode/src/vnd/vnodeSync.c
浏览文件 @
b0f469ad
...
...
@@ -436,6 +436,12 @@ static void vnodeBecomeLeader(const SSyncFSM *pFsm) {
vDebug
(
"vgId:%d, become leader"
,
pVnode
->
config
.
vgId
);
}
static
bool
vnodeApplyQueueEmpty
(
const
SSyncFSM
*
pFsm
)
{
SVnode
*
pVnode
=
pFsm
->
data
;
int32_t
itemSize
=
tmsgGetQueueSize
(
&
pVnode
->
msgCb
,
pVnode
->
config
.
vgId
,
APPLY_QUEUE
);
return
(
itemSize
==
0
);
}
static
SSyncFSM
*
vnodeSyncMakeFsm
(
SVnode
*
pVnode
)
{
SSyncFSM
*
pFsm
=
taosMemoryCalloc
(
1
,
sizeof
(
SSyncFSM
));
pFsm
->
data
=
pVnode
;
...
...
@@ -445,6 +451,7 @@ static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) {
pFsm
->
FpGetSnapshotInfo
=
vnodeSyncGetSnapshot
;
pFsm
->
FpRestoreFinishCb
=
vnodeRestoreFinish
;
pFsm
->
FpLeaderTransferCb
=
NULL
;
pFsm
->
FpApplyQueueEmptyCb
=
vnodeApplyQueueEmpty
;
pFsm
->
FpBecomeLeaderCb
=
vnodeBecomeLeader
;
pFsm
->
FpBecomeFollowerCb
=
vnodeBecomeFollower
;
pFsm
->
FpReConfigCb
=
NULL
;
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
b0f469ad
...
...
@@ -452,16 +452,22 @@ bool syncIsReadyForRead(int64_t rid) {
bool
ready
=
false
;
if
(
pSyncNode
->
state
==
TAOS_SYNC_STATE_LEADER
&&
!
pSyncNode
->
restoreFinish
)
{
if
(
!
pSyncNode
->
pLogStore
->
syncLogIsEmpty
(
pSyncNode
->
pLogStore
))
{
SSyncRaftEntry
*
pEntry
=
NULL
;
int32_t
code
=
pSyncNode
->
pLogStore
->
syncLogGetEntry
(
pSyncNode
->
pLogStore
,
pSyncNode
->
pLogStore
->
syncLogLastIndex
(
pSyncNode
->
pLogStore
),
&
pEntry
);
if
(
code
==
0
&&
pEntry
!=
NULL
)
{
if
(
pEntry
->
originalRpcType
==
TDMT_SYNC_NOOP
&&
pEntry
->
term
==
pSyncNode
->
pRaftStore
->
currentTerm
)
{
ready
=
true
;
}
if
(
!
pSyncNode
->
pFsm
->
FpApplyQueueEmptyCb
(
pSyncNode
->
pFsm
))
{
// apply queue not empty
ready
=
false
;
}
else
{
if
(
!
pSyncNode
->
pLogStore
->
syncLogIsEmpty
(
pSyncNode
->
pLogStore
))
{
SSyncRaftEntry
*
pEntry
=
NULL
;
int32_t
code
=
pSyncNode
->
pLogStore
->
syncLogGetEntry
(
pSyncNode
->
pLogStore
,
pSyncNode
->
pLogStore
->
syncLogLastIndex
(
pSyncNode
->
pLogStore
),
&
pEntry
);
if
(
code
==
0
&&
pEntry
!=
NULL
)
{
if
(
pEntry
->
originalRpcType
==
TDMT_SYNC_NOOP
&&
pEntry
->
term
==
pSyncNode
->
pRaftStore
->
currentTerm
)
{
ready
=
true
;
}
syncEntryDestory
(
pEntry
);
syncEntryDestory
(
pEntry
);
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录