Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1392711e
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看板
提交
1392711e
编写于
3月 09, 2023
作者:
B
Benguang Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: add fsm FpAppliedIndexCb to get the current applied index
上级
9d107399
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
24 addition
and
2 deletion
+24
-2
include/libs/sync/sync.h
include/libs/sync/sync.h
+1
-0
source/dnode/mnode/impl/inc/mndInt.h
source/dnode/mnode/impl/inc/mndInt.h
+1
-0
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+14
-0
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+2
-2
source/dnode/vnode/src/vnd/vnodeSync.c
source/dnode/vnode/src/vnd/vnodeSync.c
+6
-0
未找到文件。
include/libs/sync/sync.h
浏览文件 @
1392711e
...
...
@@ -143,6 +143,7 @@ typedef struct SSyncFSM {
void
*
data
;
int32_t
(
*
FpCommitCb
)(
const
struct
SSyncFSM
*
pFsm
,
SRpcMsg
*
pMsg
,
const
SFsmCbMeta
*
pMeta
);
SyncIndex
(
*
FpAppliedIndexCb
)(
const
struct
SSyncFSM
*
pFsm
);
int32_t
(
*
FpPreCommitCb
)(
const
struct
SSyncFSM
*
pFsm
,
SRpcMsg
*
pMsg
,
const
SFsmCbMeta
*
pMeta
);
void
(
*
FpRollBackCb
)(
const
struct
SSyncFSM
*
pFsm
,
SRpcMsg
*
pMsg
,
const
SFsmCbMeta
*
pMeta
);
...
...
source/dnode/mnode/impl/inc/mndInt.h
浏览文件 @
1392711e
...
...
@@ -113,6 +113,7 @@ typedef struct SMnode {
bool
deploy
;
char
*
path
;
int64_t
checkTime
;
SyncIndex
applied
;
SSdb
*
pSdb
;
SArray
*
pSteps
;
SQHandle
*
pQuery
;
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
1392711e
...
...
@@ -129,9 +129,13 @@ int32_t mndProcessWriteMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta
int32_t
mndSyncCommitMsg
(
const
SSyncFSM
*
pFsm
,
SRpcMsg
*
pMsg
,
const
SFsmCbMeta
*
pMeta
)
{
int32_t
code
=
0
;
SMnode
*
pMnode
=
pFsm
->
data
;
atomic_store_64
(
&
pMnode
->
applied
,
pMsg
->
info
.
conn
.
applyIndex
);
if
(
!
syncUtilUserCommit
(
pMsg
->
msgType
))
{
goto
_out
;
}
code
=
mndProcessWriteMsg
(
pFsm
,
pMsg
,
pMeta
);
_out:
...
...
@@ -140,6 +144,11 @@ _out:
return
code
;
}
SyncIndex
mndSyncAppliedIndex
(
const
SSyncFSM
*
pFSM
)
{
SMnode
*
pMnode
=
pFSM
->
data
;
return
atomic_load_64
(
&
pMnode
->
applied
);
}
int32_t
mndSyncGetSnapshot
(
const
SSyncFSM
*
pFsm
,
SSnapshot
*
pSnapshot
,
void
*
pReaderParam
,
void
**
ppReader
)
{
mInfo
(
"start to read snapshot from sdb in atomic way"
);
SMnode
*
pMnode
=
pFsm
->
data
;
...
...
@@ -253,6 +262,7 @@ SSyncFSM *mndSyncMakeFsm(SMnode *pMnode) {
SSyncFSM
*
pFsm
=
taosMemoryCalloc
(
1
,
sizeof
(
SSyncFSM
));
pFsm
->
data
=
pMnode
;
pFsm
->
FpCommitCb
=
mndSyncCommitMsg
;
pFsm
->
FpAppliedIndexCb
=
mndSyncAppliedIndex
;
pFsm
->
FpPreCommitCb
=
NULL
;
pFsm
->
FpRollBackCb
=
NULL
;
pFsm
->
FpRestoreFinishCb
=
mndRestoreFinish
;
...
...
@@ -321,6 +331,10 @@ int32_t mndInitSync(SMnode *pMnode) {
}
pMnode
->
pSdb
->
sync
=
pMgmt
->
sync
;
SSnapshot
snap
=
{
0
};
sdbGetCommitInfo
(
pMnode
->
pSdb
,
&
snap
.
lastApplyIndex
,
&
snap
.
lastApplyTerm
,
&
snap
.
lastConfigIndex
);
atomic_store_64
(
&
pMnode
->
applied
,
snap
.
lastApplyIndex
);
mInfo
(
"mnode-sync is opened, id:%"
PRId64
,
pMgmt
->
sync
);
return
0
;
}
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
1392711e
...
...
@@ -320,8 +320,8 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
ASSERT
(
pVnode
->
state
.
applyTerm
<=
pMsg
->
info
.
conn
.
applyTerm
);
ASSERT
(
pVnode
->
state
.
applied
+
1
==
version
);
pVnode
->
state
.
applied
=
version
;
pVnode
->
state
.
applyTerm
=
pMsg
->
info
.
conn
.
applyTerm
;
atomic_store_64
(
&
pVnode
->
state
.
applied
,
version
)
;
atomic_store_64
(
&
pVnode
->
state
.
applyTerm
,
pMsg
->
info
.
conn
.
applyTerm
)
;
if
(
!
syncUtilUserCommit
(
pMsg
->
msgType
))
goto
_exit
;
...
...
source/dnode/vnode/src/vnd/vnodeSync.c
浏览文件 @
1392711e
...
...
@@ -454,6 +454,11 @@ static int32_t vnodeSyncPreCommitMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const
return
0
;
}
static
SyncIndex
vnodeSyncAppliedIndex
(
const
SSyncFSM
*
pFSM
)
{
SVnode
*
pVnode
=
pFSM
->
data
;
return
atomic_load_64
(
&
pVnode
->
state
.
applied
);
}
static
void
vnodeSyncRollBackMsg
(
const
SSyncFSM
*
pFsm
,
SRpcMsg
*
pMsg
,
const
SFsmCbMeta
*
pMeta
)
{
SVnode
*
pVnode
=
pFsm
->
data
;
vTrace
(
"vgId:%d, rollback-cb is excuted, fsm:%p, index:%"
PRId64
", weak:%d, code:%d, state:%d %s, type:%s"
,
...
...
@@ -580,6 +585,7 @@ static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) {
SSyncFSM
*
pFsm
=
taosMemoryCalloc
(
1
,
sizeof
(
SSyncFSM
));
pFsm
->
data
=
pVnode
;
pFsm
->
FpCommitCb
=
vnodeSyncCommitMsg
;
pFsm
->
FpAppliedIndexCb
=
vnodeSyncAppliedIndex
;
pFsm
->
FpPreCommitCb
=
vnodeSyncPreCommitMsg
;
pFsm
->
FpRollBackCb
=
vnodeSyncRollBackMsg
;
pFsm
->
FpGetSnapshotInfo
=
vnodeSyncGetSnapshotInfo
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录