Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e06f9fd0
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看板
提交
e06f9fd0
编写于
5月 22, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: sync integrate into mnode
上级
c4428ba5
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
25 addition
and
71 deletion
+25
-71
include/common/tmsgdef.h
include/common/tmsgdef.h
+0
-1
include/dnode/mnode/mnode.h
include/dnode/mnode/mnode.h
+0
-2
source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
+2
-17
source/dnode/mnode/impl/inc/mndInt.h
source/dnode/mnode/impl/inc/mndInt.h
+4
-3
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+16
-37
source/dnode/mnode/impl/src/mnode.c
source/dnode/mnode/impl/src/mnode.c
+3
-10
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+0
-1
未找到文件。
include/common/tmsgdef.h
浏览文件 @
e06f9fd0
...
...
@@ -158,7 +158,6 @@ enum {
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_INDEX
,
"mnode-drop-index"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_GET_DB_CFG
,
"mnode-get-db-cfg"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_GET_INDEX
,
"mnode-get-index"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_APPLY_MSG
,
"mnode-apply-msg"
,
NULL
,
NULL
)
// Requests handled by VNODE
...
...
include/dnode/mnode/mnode.h
浏览文件 @
e06f9fd0
...
...
@@ -89,9 +89,7 @@ int32_t mndGetLoad(SMnode *pMnode, SMnodeLoad *pLoad);
* @return int32_t 0 for success, -1 for failure.
*/
int32_t
mndProcessMsg
(
SRpcMsg
*
pMsg
);
int32_t
mndProcessSyncMsg
(
SRpcMsg
*
pMsg
);
int32_t
mndProcessApplyMsg
(
SRpcMsg
*
pMsg
);
/**
...
...
source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
浏览文件 @
e06f9fd0
...
...
@@ -59,32 +59,17 @@ static void mmProcessQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
static
void
mmProcessSyncQueue
(
SQueueInfo
*
pInfo
,
SRpcMsg
*
pMsg
)
{
SMnodeMgmt
*
pMgmt
=
pInfo
->
ahandle
;
pMsg
->
info
.
node
=
pMgmt
->
pMnode
;
mndProcessSyncMsg
(
pMsg
);
return
;
}
static
void
mmProcessApplyQueue
(
SQueueInfo
*
pInfo
,
SRpcMsg
*
pMsg
)
{
SMnodeMgmt
*
pMgmt
=
pInfo
->
ahandle
;
int32_t
code
=
-
1
;
tmsg_t
msgType
=
pMsg
->
msgType
;
bool
isRequest
=
msgType
&
1U
;
dTrace
(
"msg:%p, get from mnode-query queue"
,
pMsg
);
dTrace
(
"msg:%p, get from mnode-apply queue"
,
pMsg
);
pMsg
->
info
.
node
=
pMgmt
->
pMnode
;
mndProcessApplyMsg
(
pMsg
);
/*
if (isRequest) {
if (pMsg->info.handle != NULL && code != 0) {
if (code != 0 && terrno != 0) code = terrno;
mmSendRsp(pMsg, code);
}
}
*/
dTrace
(
"msg:%p, is freed, code:0x%x"
,
pMsg
,
code
);
dTrace
(
"msg:%p, is freed"
,
pMsg
);
rpcFreeCont
(
pMsg
->
pCont
);
taosFreeQitem
(
pMsg
);
}
...
...
source/dnode/mnode/impl/inc/mndInt.h
浏览文件 @
e06f9fd0
...
...
@@ -19,6 +19,7 @@
#include "mndDef.h"
#include "sdb.h"
#include "syncTools.h"
#include "tcache.h"
#include "tdatablock.h"
#include "tglobal.h"
...
...
@@ -31,12 +32,14 @@
extern
"C"
{
#endif
// clang-format off
#define mFatal(...) { if (mDebugFlag & DEBUG_FATAL) { taosPrintLog("MND FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }}
#define mError(...) { if (mDebugFlag & DEBUG_ERROR) { taosPrintLog("MND ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }}
#define mWarn(...) { if (mDebugFlag & DEBUG_WARN) { taosPrintLog("MND WARN ", DEBUG_WARN, 255, __VA_ARGS__); }}
#define mInfo(...) { if (mDebugFlag & DEBUG_INFO) { taosPrintLog("MND ", DEBUG_INFO, 255, __VA_ARGS__); }}
#define mDebug(...) { if (mDebugFlag & DEBUG_DEBUG) { taosPrintLog("MND ", DEBUG_DEBUG, mDebugFlag, __VA_ARGS__); }}
#define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", DEBUG_TRACE, mDebugFlag, __VA_ARGS__); }}
// clang-format on
#define SYSTABLE_SCH_TABLE_NAME_LEN ((TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
#define SYSTABLE_SCH_DB_NAME_LEN ((TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
...
...
@@ -75,9 +78,7 @@ typedef struct {
int32_t
errCode
;
sem_t
syncSem
;
SWal
*
pWal
;
//SSyncNode *pSyncNode;
int64_t
sync
;
int64_t
sync
;
ESyncState
state
;
}
SSyncMgmt
;
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
e06f9fd0
...
...
@@ -125,24 +125,11 @@ _OVER:
}
int32_t
mndSyncEqMsg
(
const
SMsgCb
*
msgcb
,
SRpcMsg
*
pMsg
)
{
int32_t
ret
=
0
;
if
(
msgcb
->
queueFps
[
SYNC_QUEUE
]
!=
NULL
)
{
tmsgPutToQueue
(
msgcb
,
SYNC_QUEUE
,
pMsg
);
}
else
{
mError
(
"mndSyncEqMsg queue is NULL, SYNC_QUEUE:%d"
,
SYNC_QUEUE
);
}
return
ret
;
}
int32_t
mndSyncEqMsg
(
const
SMsgCb
*
msgcb
,
SRpcMsg
*
pMsg
)
{
return
tmsgPutToQueue
(
msgcb
,
SYNC_QUEUE
,
pMsg
);
}
int32_t
mndSendMsg
(
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
)
{
int32_t
ret
=
0
;
pMsg
->
info
.
noResp
=
1
;
tmsgSendReq
(
pEpSet
,
pMsg
);
return
ret
;
}
int32_t
mndSyncSendMsg
(
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
)
{
return
tmsgSendReq
(
pEpSet
,
pMsg
);
}
void
mndSyncCommit
Cb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
void
mndSyncCommit
Msg
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
SyncIndex
beginIndex
=
SYNC_INDEX_INVALID
;
if
(
pFsm
->
FpGetSnapshot
!=
NULL
)
{
SSnapshot
snapshot
;
...
...
@@ -163,26 +150,26 @@ void mndSyncCommitCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMe
}
}
void
mndSyncPreCommit
Cb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
void
mndSyncPreCommit
Msg
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
// strict consistent, do nothing
}
void
mndSyncRollBack
Cb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
void
mndSyncRollBack
Msg
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
// strict consistent, do nothing
}
int32_t
mndSyncGetSnapshot
Cb
(
struct
SSyncFSM
*
pFsm
,
SSnapshot
*
pSnapshot
)
{
int32_t
mndSyncGetSnapshot
(
struct
SSyncFSM
*
pFsm
,
SSnapshot
*
pSnapshot
)
{
// snapshot
return
0
;
}
SSyncFSM
*
syncMnode
MakeFsm
(
SMnode
*
pMnode
)
{
SSyncFSM
*
pFsm
=
(
SSyncFSM
*
)
taosMemoryMalloc
(
sizeof
(
SSyncFSM
));
SSyncFSM
*
mndSync
MakeFsm
(
SMnode
*
pMnode
)
{
SSyncFSM
*
pFsm
=
taosMemoryCalloc
(
1
,
sizeof
(
SSyncFSM
));
pFsm
->
data
=
pMnode
;
pFsm
->
FpCommitCb
=
mndSyncCommit
Cb
;
pFsm
->
FpPreCommitCb
=
mndSyncPreCommit
Cb
;
pFsm
->
FpRollBackCb
=
mndSyncRollBack
Cb
;
pFsm
->
FpGetSnapshot
=
mndSyncGetSnapshot
Cb
;
pFsm
->
FpCommitCb
=
mndSyncCommit
Msg
;
pFsm
->
FpPreCommitCb
=
mndSyncPreCommit
Msg
;
pFsm
->
FpRollBackCb
=
mndSyncRollBack
Msg
;
pFsm
->
FpGetSnapshot
=
mndSyncGetSnapshot
;
return
pFsm
;
}
...
...
@@ -195,18 +182,11 @@ int32_t mndInitSync(SMnode *pMnode) {
return
-
1
;
}
if
(
mndRestoreWal
(
pMnode
)
<
0
)
{
mError
(
"failed to restore wal since %s"
,
terrstr
());
return
-
1
;
}
if
(
pMnode
->
selfId
==
1
)
{
pMgmt
->
state
=
TAOS_SYNC_STATE_LEADER
;
}
// pMgmt->pSyncNode = NULL;
SSyncInfo
syncInfo
;
syncInfo
.
vgId
=
1
;
SSyncInfo
syncInfo
=
{.
vgId
=
1
};
SSyncCfg
*
pCfg
=
&
(
syncInfo
.
syncCfg
);
pCfg
->
replicaNum
=
pMnode
->
replica
;
pCfg
->
myIndex
=
pMnode
->
selfIndex
;
...
...
@@ -216,9 +196,8 @@ int32_t mndInitSync(SMnode *pMnode) {
}
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s/sync"
,
pMnode
->
path
);
syncInfo
.
pWal
=
pMnode
->
syncMgmt
.
pWal
;
syncInfo
.
pFsm
=
syncMnodeMakeFsm
(
pMnode
);
syncInfo
.
FpSendMsg
=
mndSendMsg
;
syncInfo
.
pFsm
=
mndSyncMakeFsm
(
pMnode
);
syncInfo
.
FpSendMsg
=
mndSyncSendMsg
;
syncInfo
.
FpEqMsg
=
mndSyncEqMsg
;
pMnode
->
syncMgmt
.
sync
=
syncOpen
(
&
syncInfo
);
...
...
source/dnode/mnode/impl/src/mnode.c
浏览文件 @
e06f9fd0
...
...
@@ -343,25 +343,18 @@ int32_t mndStart(SMnode *pMnode) {
void
mndStop
(
SMnode
*
pMnode
)
{
syncStop
(
pMnode
->
syncMgmt
.
sync
);
return
mndCleanupTimer
(
pMnode
);
return
mndCleanupTimer
(
pMnode
);
}
int32_t
mndProcessApplyMsg
(
SRpcMsg
*
pMsg
)
{
SSdbRaw
*
pRaw
=
pMsg
->
pCont
;
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
int32_t
code
=
sdbWriteWithoutFree
(
pMnode
->
pSdb
,
pRaw
);
rpcFreeCont
(
pMsg
->
pCont
);
return
code
;
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
return
sdbWriteWithoutFree
(
pMnode
->
pSdb
,
pRaw
);
}
#include "syncTools.h"
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
())
{
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
e06f9fd0
...
...
@@ -13,7 +13,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include "sync.h"
#include "syncAppendEntries.h"
#include "syncAppendEntriesReply.h"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录