Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ded46160
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看板
提交
ded46160
编写于
7月 04, 2022
作者:
M
Minghao Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(sync): add sync strategy
上级
a5d3b703
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
32 addition
and
25 deletion
+32
-25
include/libs/sync/sync.h
include/libs/sync/sync.h
+15
-9
source/dnode/mnode/impl/src/mndMain.c
source/dnode/mnode/impl/src/mndMain.c
+9
-9
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+1
-1
source/dnode/vnode/src/vnd/vnodeSync.c
source/dnode/vnode/src/vnd/vnodeSync.c
+2
-1
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+1
-1
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
+1
-1
source/libs/sync/test/syncTestTool.cpp
source/libs/sync/test/syncTestTool.cpp
+3
-3
未找到文件。
include/libs/sync/sync.h
浏览文件 @
ded46160
...
...
@@ -31,6 +31,12 @@ extern bool gRaftDetailLog;
#define SYNC_INDEX_INVALID -1
#define SYNC_TERM_INVALID 0xFFFFFFFFFFFFFFFF
typedef
enum
{
SYNC_STRATEGY_NO_SNAPSHOT
=
0
,
SYNC_STRATEGY_STANDARD_SNAPSHOT
=
1
,
SYNC_STRATEGY_WAL_FIRST
=
2
,
}
ESyncStrategy
;
typedef
uint64_t
SyncNodeId
;
typedef
int32_t
SyncGroupId
;
typedef
int64_t
SyncIndex
;
...
...
@@ -183,15 +189,15 @@ typedef struct SSyncLogStore {
}
SSyncLogStore
;
typedef
struct
SSyncInfo
{
bool
isStandBy
;
bool
snapshotEnable
;
SyncGroupId
vgId
;
int32_t
batchSize
;
SSyncCfg
syncCfg
;
char
path
[
TSDB_FILENAME_LEN
];
SWal
*
pWal
;
SSyncFSM
*
pFsm
;
SMsgCb
*
msgcb
;
bool
isStandBy
;
ESyncStrategy
snapshotStrategy
;
SyncGroupId
vgId
;
int32_t
batchSize
;
SSyncCfg
syncCfg
;
char
path
[
TSDB_FILENAME_LEN
];
SWal
*
pWal
;
SSyncFSM
*
pFsm
;
SMsgCb
*
msgcb
;
int32_t
(
*
FpSendMsg
)(
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
);
int32_t
(
*
FpEqMsg
)(
const
SMsgCb
*
msgcb
,
SRpcMsg
*
pMsg
);
}
SSyncInfo
;
...
...
source/dnode/mnode/impl/src/mndMain.c
浏览文件 @
ded46160
...
...
@@ -58,7 +58,7 @@ static void *mndBuildTimerMsg(int32_t *pContLen) {
static
void
mndPullupTrans
(
SMnode
*
pMnode
)
{
int32_t
contLen
=
0
;
void
*
pReq
=
mndBuildTimerMsg
(
&
contLen
);
void
*
pReq
=
mndBuildTimerMsg
(
&
contLen
);
if
(
pReq
!=
NULL
)
{
SRpcMsg
rpcMsg
=
{.
msgType
=
TDMT_MND_TRANS_TIMER
,
.
pCont
=
pReq
,
.
contLen
=
contLen
};
tmsgPutToQueue
(
&
pMnode
->
msgCb
,
WRITE_QUEUE
,
&
rpcMsg
);
...
...
@@ -67,14 +67,14 @@ static void mndPullupTrans(SMnode *pMnode) {
static
void
mndTtlTimer
(
SMnode
*
pMnode
)
{
int32_t
contLen
=
0
;
void
*
pReq
=
mndBuildTimerMsg
(
&
contLen
);
void
*
pReq
=
mndBuildTimerMsg
(
&
contLen
);
SRpcMsg
rpcMsg
=
{.
msgType
=
TDMT_MND_TTL_TIMER
,
.
pCont
=
pReq
,
.
contLen
=
contLen
};
tmsgPutToQueue
(
&
pMnode
->
msgCb
,
WRITE_QUEUE
,
&
rpcMsg
);
}
static
void
mndCalMqRebalance
(
SMnode
*
pMnode
)
{
int32_t
contLen
=
0
;
void
*
pReq
=
mndBuildTimerMsg
(
&
contLen
);
void
*
pReq
=
mndBuildTimerMsg
(
&
contLen
);
if
(
pReq
!=
NULL
)
{
SRpcMsg
rpcMsg
=
{.
msgType
=
TDMT_MND_MQ_TIMER
,
.
pCont
=
pReq
,
.
contLen
=
contLen
};
tmsgPutToQueue
(
&
pMnode
->
msgCb
,
READ_QUEUE
,
&
rpcMsg
);
...
...
@@ -83,7 +83,7 @@ static void mndCalMqRebalance(SMnode *pMnode) {
static
void
mndPullupTelem
(
SMnode
*
pMnode
)
{
int32_t
contLen
=
0
;
void
*
pReq
=
mndBuildTimerMsg
(
&
contLen
);
void
*
pReq
=
mndBuildTimerMsg
(
&
contLen
);
if
(
pReq
!=
NULL
)
{
SRpcMsg
rpcMsg
=
{.
msgType
=
TDMT_MND_TELEM_TIMER
,
.
pCont
=
pReq
,
.
contLen
=
contLen
};
tmsgPutToQueue
(
&
pMnode
->
msgCb
,
READ_QUEUE
,
&
rpcMsg
);
...
...
@@ -395,7 +395,7 @@ void mndStop(SMnode *pMnode) {
}
int32_t
mndProcessSyncMsg
(
SRpcMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
SSyncMgmt
*
pMgmt
=
&
pMnode
->
syncMgmt
;
int32_t
code
=
0
;
...
...
@@ -413,7 +413,7 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
}
do
{
char
*
syncNodeStr
=
sync2SimpleStr
(
pMgmt
->
sync
);
char
*
syncNodeStr
=
sync2SimpleStr
(
pMgmt
->
sync
);
static
int64_t
mndTick
=
0
;
if
(
++
mndTick
%
10
==
1
)
{
mTrace
(
"vgId:%d, sync trace msg:%s, %s"
,
syncGetVgId
(
pMgmt
->
sync
),
TMSG_INFO
(
pMsg
->
msgType
),
syncNodeStr
);
...
...
@@ -579,7 +579,7 @@ static int32_t mndCheckMsgContent(SRpcMsg *pMsg) {
}
int32_t
mndProcessRpcMsg
(
SRpcMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
MndMsgFp
fp
=
pMnode
->
msgFp
[
TMSG_INDEX
(
pMsg
->
msgType
)];
...
...
@@ -632,7 +632,7 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
SMonStbInfo
*
pStbInfo
,
SMonGrantInfo
*
pGrantInfo
)
{
if
(
mndAcquireRpcRef
(
pMnode
)
!=
0
)
return
-
1
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int64_t
ms
=
taosGetTimestampMs
();
pClusterInfo
->
dnodes
=
taosArrayInit
(
sdbGetSize
(
pSdb
,
SDB_DNODE
),
sizeof
(
SMonDnodeDesc
));
...
...
@@ -713,7 +713,7 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
pGrantInfo
->
timeseries_used
+=
pVgroup
->
numOfTimeSeries
;
tstrncpy
(
desc
.
status
,
"unsynced"
,
sizeof
(
desc
.
status
));
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
replica
;
++
i
)
{
SVnodeGid
*
pVgid
=
&
pVgroup
->
vnodeGid
[
i
];
SVnodeGid
*
pVgid
=
&
pVgroup
->
vnodeGid
[
i
];
SMonVnodeDesc
*
pVnDesc
=
&
desc
.
vnodes
[
i
];
pVnDesc
->
dnode_id
=
pVgid
->
dnodeId
;
tstrncpy
(
pVnDesc
->
vnode_role
,
syncStr
(
pVgid
->
role
),
sizeof
(
pVnDesc
->
vnode_role
));
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
ded46160
...
...
@@ -178,7 +178,7 @@ int32_t mndInitSync(SMnode *pMnode) {
syncInfo
.
pWal
=
pMnode
->
pWal
;
syncInfo
.
pFsm
=
mndSyncMakeFsm
(
pMnode
);
syncInfo
.
isStandBy
=
pMgmt
->
standby
;
syncInfo
.
snapshot
Enable
=
true
;
syncInfo
.
snapshot
Strategy
=
SYNC_STRATEGY_STANDARD_SNAPSHOT
;
mInfo
(
"start to open mnode sync, standby:%d"
,
pMgmt
->
standby
);
if
(
pMgmt
->
standby
||
pMgmt
->
replica
.
id
>
0
)
{
...
...
source/dnode/vnode/src/vnd/vnodeSync.c
浏览文件 @
ded46160
...
...
@@ -442,7 +442,8 @@ static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) {
int32_t
vnodeSyncOpen
(
SVnode
*
pVnode
,
char
*
path
)
{
SSyncInfo
syncInfo
=
{
.
snapshotEnable
=
false
,
.
snapshotStrategy
=
SYNC_STRATEGY_NO_SNAPSHOT
,
.
batchSize
=
10
,
.
vgId
=
pVnode
->
config
.
vgId
,
.
isStandBy
=
pVnode
->
config
.
standby
,
.
syncCfg
=
pVnode
->
config
.
syncCfg
,
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
ded46160
...
...
@@ -815,7 +815,7 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pOldSyncInfo) {
// create a new raft config file
SRaftCfgMeta
meta
;
meta
.
isStandBy
=
pSyncInfo
->
isStandBy
;
meta
.
snapshotEnable
=
pSyncInfo
->
snapshot
Enable
;
meta
.
snapshotEnable
=
pSyncInfo
->
snapshot
Strategy
;
meta
.
lastConfigIndex
=
SYNC_INDEX_INVALID
;
ret
=
raftCfgCreateFile
((
SSyncCfg
*
)
&
(
pSyncInfo
->
syncCfg
),
meta
,
pSyncNode
->
configPath
);
ASSERT
(
ret
==
0
);
...
...
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
浏览文件 @
ded46160
...
...
@@ -198,7 +198,7 @@ int64_t createSyncNode(int32_t replicaNum, int32_t myIndex, int32_t vgId, SWal*
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s_sync_replica%d_index%d"
,
path
,
replicaNum
,
myIndex
);
syncInfo
.
pWal
=
pWal
;
syncInfo
.
isStandBy
=
isStandBy
;
syncInfo
.
snapshot
Enable
=
true
;
syncInfo
.
snapshot
Strategy
=
SYNC_STRATEGY_STANDARD_SNAPSHOT
;
SSyncCfg
*
pCfg
=
&
syncInfo
.
syncCfg
;
...
...
source/libs/sync/test/syncTestTool.cpp
浏览文件 @
ded46160
...
...
@@ -203,7 +203,7 @@ SWal* createWal(char* path, int32_t vgId) {
}
int64_t
createSyncNode
(
int32_t
replicaNum
,
int32_t
myIndex
,
int32_t
vgId
,
SWal
*
pWal
,
char
*
path
,
bool
isStandBy
,
bool
enableSnapshot
)
{
ESyncStrategy
enableSnapshot
)
{
SSyncInfo
syncInfo
;
syncInfo
.
vgId
=
vgId
;
syncInfo
.
msgcb
=
&
gSyncIO
->
msgcb
;
...
...
@@ -213,7 +213,7 @@ int64_t createSyncNode(int32_t replicaNum, int32_t myIndex, int32_t vgId, SWal*
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s_sync_replica%d_index%d"
,
path
,
replicaNum
,
myIndex
);
syncInfo
.
pWal
=
pWal
;
syncInfo
.
isStandBy
=
isStandBy
;
syncInfo
.
snapshot
Enable
=
enableSnapshot
;
syncInfo
.
snapshot
Strategy
=
enableSnapshot
;
SSyncCfg
*
pCfg
=
&
syncInfo
.
syncCfg
;
...
...
@@ -316,7 +316,7 @@ int main(int argc, char** argv) {
int32_t
replicaNum
=
atoi
(
argv
[
1
]);
int32_t
myIndex
=
atoi
(
argv
[
2
]);
bool
enableSnapshot
=
atoi
(
argv
[
3
]);
ESyncStrategy
enableSnapshot
=
(
ESyncStrategy
)
atoi
(
argv
[
3
]);
int32_t
lastApplyIndex
=
atoi
(
argv
[
4
]);
int32_t
lastApplyTerm
=
atoi
(
argv
[
5
]);
int32_t
writeRecordNum
=
atoi
(
argv
[
6
]);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录