Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
89c1e823
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看板
提交
89c1e823
编写于
5月 23, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: sync integrate into mnode
上级
c38a8055
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
35 addition
and
21 deletion
+35
-21
source/dnode/mnode/impl/inc/mndInt.h
source/dnode/mnode/impl/inc/mndInt.h
+2
-1
source/dnode/mnode/impl/inc/mndSync.h
source/dnode/mnode/impl/inc/mndSync.h
+3
-0
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+23
-1
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+0
-10
source/dnode/mnode/impl/src/mnode.c
source/dnode/mnode/impl/src/mnode.c
+7
-9
未找到文件。
source/dnode/mnode/impl/inc/mndInt.h
浏览文件 @
89c1e823
...
...
@@ -75,9 +75,10 @@ typedef struct {
}
STelemMgmt
;
typedef
struct
{
SWal
*
pWal
;
int32_t
errCode
;
bool
restored
;
sem_t
syncSem
;
SWal
*
pWal
;
int64_t
sync
;
ESyncState
state
;
}
SSyncMgmt
;
...
...
source/dnode/mnode/impl/inc/mndSync.h
浏览文件 @
89c1e823
...
...
@@ -25,7 +25,10 @@ extern "C" {
int32_t
mndInitSync
(
SMnode
*
pMnode
);
void
mndCleanupSync
(
SMnode
*
pMnode
);
bool
mndIsMaster
(
SMnode
*
pMnode
);
bool
mndIsRestored
(
SMnode
*
pMnode
);
int32_t
mndSyncPropose
(
SMnode
*
pMnode
,
SSdbRaw
*
pRaw
);
void
mndSyncStart
(
SMnode
*
pMnode
);
void
mndSyncStop
(
SMnode
*
pMnode
);
#ifdef __cplusplus
}
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
89c1e823
...
...
@@ -68,7 +68,6 @@ SSyncFSM *mndSyncMakeFsm(SMnode *pMnode) {
int32_t
mndInitSync
(
SMnode
*
pMnode
)
{
SSyncMgmt
*
pMgmt
=
&
pMnode
->
syncMgmt
;
tsem_init
(
&
pMgmt
->
syncSem
,
0
,
0
);
char
path
[
PATH_MAX
+
20
]
=
{
0
};
snprintf
(
path
,
sizeof
(
path
),
"%s%swal"
,
pMnode
->
path
,
TD_DIRSEP
);
...
...
@@ -102,6 +101,7 @@ int32_t mndInitSync(SMnode *pMnode) {
pNode
->
nodePort
=
pMnode
->
replicas
[
i
].
port
;
}
tsem_init
(
&
pMgmt
->
syncSem
,
0
,
0
);
pMgmt
->
sync
=
syncOpen
(
&
syncInfo
);
if
(
pMgmt
->
sync
<=
0
)
{
mError
(
"failed to open sync since %s"
,
terrstr
());
...
...
@@ -146,8 +146,30 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw) {
return
pMgmt
->
errCode
;
}
void
mndSyncStart
(
SMnode
*
pMnode
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int64_t
lastApplyIndex
=
sdbGetApplyIndex
(
pSdb
);
syncSetMsgCb
(
pMnode
->
syncMgmt
.
sync
,
&
pMnode
->
msgCb
);
syncStart
(
pMnode
->
syncMgmt
.
sync
);
int64_t
applyIndex
=
sdbGetApplyIndex
(
pSdb
);
mndTransPullup
(
pMnode
);
mDebug
(
"pullup trans finished, applyIndex:%"
PRId64
,
applyIndex
);
if
(
applyIndex
!=
lastApplyIndex
)
{
mInfo
(
"sdb restored from %"
PRId64
" to %"
PRId64
", write file"
,
lastApplyIndex
,
applyIndex
);
sdbWriteFile
(
pSdb
);
}
pMnode
->
syncMgmt
.
restored
=
true
;
}
void
mndSyncStop
(
SMnode
*
pMnode
)
{
syncStop
(
pMnode
->
syncMgmt
.
sync
);
}
bool
mndIsMaster
(
SMnode
*
pMnode
)
{
SSyncMgmt
*
pMgmt
=
&
pMnode
->
syncMgmt
;
pMgmt
->
state
=
syncGetMyRole
(
pMgmt
->
sync
);
return
pMgmt
->
state
==
TAOS_SYNC_STATE_LEADER
;
}
bool
mndIsRestored
(
SMnode
*
pMnode
)
{
return
pMnode
->
syncMgmt
.
restored
;
}
\ No newline at end of file
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
89c1e823
...
...
@@ -682,16 +682,6 @@ static int32_t mndTransSync(SMnode *pMnode, STrans *pTrans) {
}
mDebug
(
"trans:%d, sync finished"
,
pTrans
->
id
);
// do it in state machine commit cb
#if 0
code = sdbWriteWithout(pMnode->pSdb, pRaw);
if (code != 0) {
mError("trans:%d, failed to write sdb since %s", pTrans->id, terrstr());
return -1;
}
#endif
return
0
;
}
...
...
source/dnode/mnode/impl/src/mnode.c
浏览文件 @
89c1e823
...
...
@@ -86,7 +86,7 @@ static void *mndThreadFp(void *param) {
lastTime
++
;
taosMsleep
(
100
);
if
(
pMnode
->
stopped
)
break
;
if
(
!
mndIsMaster
(
pMnode
))
continue
;
if
(
!
mndIsMaster
(
pMnode
)
||
!
mndIsRestored
(
pMnode
)
)
continue
;
if
(
lastTime
%
(
tsTransPullupInterval
*
10
)
==
0
)
{
mndPullupTrans
(
pMnode
);
...
...
@@ -337,13 +337,12 @@ int32_t mndAlter(SMnode *pMnode, const SMnodeOpt *pOption) {
}
int32_t
mndStart
(
SMnode
*
pMnode
)
{
syncSetMsgCb
(
pMnode
->
syncMgmt
.
sync
,
&
pMnode
->
msgCb
);
syncStart
(
pMnode
->
syncMgmt
.
sync
);
mndSyncStart
(
pMnode
);
return
mndInitTimer
(
pMnode
);
}
void
mndStop
(
SMnode
*
pMnode
)
{
syncStop
(
pMnode
->
syncMgmt
.
sync
);
void
mndStop
(
SMnode
*
pMnode
)
{
mndSyncStop
(
pMnode
);
return
mndCleanupTimer
(
pMnode
);
}
...
...
@@ -357,7 +356,7 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
void
*
ahandle
=
pMsg
->
info
.
ahandle
;
int32_t
ret
=
TAOS_SYNC_PROPOSE_OTHER_ERROR
;
if
(
syncEnvIsStart
())
{
SSyncNode
*
pSyncNode
=
syncNodeAcquire
(
pMnode
->
syncMgmt
.
sync
);
assert
(
pSyncNode
!=
NULL
);
...
...
@@ -444,7 +443,6 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
return
ret
;
return
0
;
}
...
...
@@ -454,7 +452,7 @@ int32_t mndProcessMsg(SRpcMsg *pMsg) {
mTrace
(
"msg:%p, will be processed, type:%s app:%p"
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
),
ahandle
);
if
(
IsReq
(
pMsg
))
{
if
(
!
mndIsMaster
(
pMnode
))
{
if
(
!
mndIsMaster
(
pMnode
)
||
!
mndIsRestored
(
pMnode
)
)
{
terrno
=
TSDB_CODE_APP_NOT_READY
;
mDebug
(
"msg:%p, failed to process since %s, app:%p"
,
pMsg
,
terrstr
(),
ahandle
);
return
-
1
;
...
...
@@ -514,7 +512,7 @@ int64_t mndGenerateUid(char *name, int32_t len) {
int32_t
mndGetMonitorInfo
(
SMnode
*
pMnode
,
SMonClusterInfo
*
pClusterInfo
,
SMonVgroupInfo
*
pVgroupInfo
,
SMonGrantInfo
*
pGrantInfo
)
{
if
(
!
mndIsMaster
(
pMnode
))
return
-
1
;
if
(
!
mndIsMaster
(
pMnode
)
||
!
mndIsRestored
(
pMnode
)
)
return
-
1
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int64_t
ms
=
taosGetTimestampMs
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录