Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
64f4325b
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看板
提交
64f4325b
编写于
7月 28, 2022
作者:
M
Minghao Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(sync): modify propose batch interface
上级
a75745de
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
23 addition
and
22 deletion
+23
-22
include/libs/sync/sync.h
include/libs/sync/sync.h
+1
-1
include/libs/sync/syncTools.h
include/libs/sync/syncTools.h
+1
-1
source/libs/sync/inc/syncInt.h
source/libs/sync/inc/syncInt.h
+1
-1
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+12
-11
source/libs/sync/src/syncMessage.c
source/libs/sync/src/syncMessage.c
+3
-3
source/libs/sync/test/syncClientRequestBatchTest.cpp
source/libs/sync/test/syncClientRequestBatchTest.cpp
+5
-5
未找到文件。
include/libs/sync/sync.h
浏览文件 @
64f4325b
...
...
@@ -210,7 +210,7 @@ SyncGroupId syncGetVgId(int64_t rid);
void
syncGetEpSet
(
int64_t
rid
,
SEpSet
*
pEpSet
);
void
syncGetRetryEpSet
(
int64_t
rid
,
SEpSet
*
pEpSet
);
int32_t
syncPropose
(
int64_t
rid
,
SRpcMsg
*
pMsg
,
bool
isWeak
);
int32_t
syncProposeBatch
(
int64_t
rid
,
SRpcMsg
*
pMsg
Arr
,
bool
*
pIsWeakArr
,
int32_t
arrSize
);
int32_t
syncProposeBatch
(
int64_t
rid
,
SRpcMsg
*
*
pMsgP
Arr
,
bool
*
pIsWeakArr
,
int32_t
arrSize
);
bool
syncEnvIsStart
();
const
char
*
syncStr
(
ESyncState
state
);
bool
syncIsRestoreFinish
(
int64_t
rid
);
...
...
include/libs/sync/syncTools.h
浏览文件 @
64f4325b
...
...
@@ -238,7 +238,7 @@ typedef struct SyncClientRequestBatch {
char
data
[];
// block2, block3
}
SyncClientRequestBatch
;
SyncClientRequestBatch
*
syncClientRequestBatchBuild
(
SRpcMsg
*
rpcMsg
Arr
,
SRaftMeta
*
raftArr
,
int32_t
arrSize
,
SyncClientRequestBatch
*
syncClientRequestBatchBuild
(
SRpcMsg
*
*
rpcMsgP
Arr
,
SRaftMeta
*
raftArr
,
int32_t
arrSize
,
int32_t
vgId
);
void
syncClientRequestBatch2RpcMsg
(
const
SyncClientRequestBatch
*
pSyncMsg
,
SRpcMsg
*
pRpcMsg
);
void
syncClientRequestBatchDestroy
(
SyncClientRequestBatch
*
pMsg
);
...
...
source/libs/sync/inc/syncInt.h
浏览文件 @
64f4325b
...
...
@@ -170,7 +170,7 @@ void syncNodeStart(SSyncNode* pSyncNode);
void
syncNodeStartStandBy
(
SSyncNode
*
pSyncNode
);
void
syncNodeClose
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodePropose
(
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
,
bool
isWeak
);
int32_t
syncNodeProposeBatch
(
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
Arr
,
bool
*
pIsWeakArr
,
int32_t
arrSize
);
int32_t
syncNodeProposeBatch
(
SSyncNode
*
pSyncNode
,
SRpcMsg
*
*
pMsgP
Arr
,
bool
*
pIsWeakArr
,
int32_t
arrSize
);
// option
bool
syncNodeSnapshotEnable
(
SSyncNode
*
pSyncNode
);
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
64f4325b
...
...
@@ -677,7 +677,7 @@ int32_t syncPropose(int64_t rid, SRpcMsg* pMsg, bool isWeak) {
return
ret
;
}
int32_t
syncProposeBatch
(
int64_t
rid
,
SRpcMsg
*
pMsg
Arr
,
bool
*
pIsWeakArr
,
int32_t
arrSize
)
{
int32_t
syncProposeBatch
(
int64_t
rid
,
SRpcMsg
*
*
pMsgP
Arr
,
bool
*
pIsWeakArr
,
int32_t
arrSize
)
{
if
(
arrSize
<
0
)
{
terrno
=
TSDB_CODE_SYN_INTERNAL_ERROR
;
return
-
1
;
...
...
@@ -690,18 +690,18 @@ int32_t syncProposeBatch(int64_t rid, SRpcMsg* pMsgArr, bool* pIsWeakArr, int32_
}
ASSERT
(
rid
==
pSyncNode
->
rid
);
int32_t
ret
=
syncNodeProposeBatch
(
pSyncNode
,
pMsgArr
,
pIsWeakArr
,
arrSize
);
int32_t
ret
=
syncNodeProposeBatch
(
pSyncNode
,
pMsg
P
Arr
,
pIsWeakArr
,
arrSize
);
taosReleaseRef
(
tsNodeRefId
,
pSyncNode
->
rid
);
return
ret
;
}
static
bool
syncNodeBatchOK
(
SRpcMsg
*
pMsg
Arr
,
int32_t
arrSize
)
{
static
bool
syncNodeBatchOK
(
SRpcMsg
*
*
pMsgP
Arr
,
int32_t
arrSize
)
{
for
(
int32_t
i
=
0
;
i
<
arrSize
;
++
i
)
{
if
(
pMsg
Arr
[
i
].
msgType
==
TDMT_SYNC_CONFIG_CHANGE
)
{
if
(
pMsg
PArr
[
i
]
->
msgType
==
TDMT_SYNC_CONFIG_CHANGE
)
{
return
false
;
}
if
(
pMsg
Arr
[
i
].
msgType
==
TDMT_SYNC_CONFIG_CHANGE_FINISH
)
{
if
(
pMsg
PArr
[
i
]
->
msgType
==
TDMT_SYNC_CONFIG_CHANGE_FINISH
)
{
return
false
;
}
}
...
...
@@ -709,8 +709,8 @@ static bool syncNodeBatchOK(SRpcMsg* pMsgArr, int32_t arrSize) {
return
true
;
}
int32_t
syncNodeProposeBatch
(
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
Arr
,
bool
*
pIsWeakArr
,
int32_t
arrSize
)
{
if
(
!
syncNodeBatchOK
(
pMsgArr
,
arrSize
))
{
int32_t
syncNodeProposeBatch
(
SSyncNode
*
pSyncNode
,
SRpcMsg
*
*
pMsgP
Arr
,
bool
*
pIsWeakArr
,
int32_t
arrSize
)
{
if
(
!
syncNodeBatchOK
(
pMsg
P
Arr
,
arrSize
))
{
syncNodeErrorLog
(
pSyncNode
,
"sync propose batch error"
);
terrno
=
TSDB_CODE_SYN_BATCH_ERROR
;
return
-
1
;
...
...
@@ -738,14 +738,14 @@ int32_t syncNodeProposeBatch(SSyncNode* pSyncNode, SRpcMsg* pMsgArr, bool* pIsWe
for
(
int
i
=
0
;
i
<
arrSize
;
++
i
)
{
SRespStub
stub
;
stub
.
createTime
=
taosGetTimestampMs
();
stub
.
rpcMsg
=
pMsgArr
[
i
]
;
stub
.
rpcMsg
=
*
(
pMsgPArr
[
i
])
;
uint64_t
seqNum
=
syncRespMgrAdd
(
pSyncNode
->
pSyncRespMgr
,
&
stub
);
raftArr
[
i
].
isWeak
=
pIsWeakArr
[
i
];
raftArr
[
i
].
seqNum
=
seqNum
;
}
SyncClientRequestBatch
*
pSyncMsg
=
syncClientRequestBatchBuild
(
pMsgArr
,
raftArr
,
arrSize
,
pSyncNode
->
vgId
);
SyncClientRequestBatch
*
pSyncMsg
=
syncClientRequestBatchBuild
(
pMsg
P
Arr
,
raftArr
,
arrSize
,
pSyncNode
->
vgId
);
ASSERT
(
pSyncMsg
!=
NULL
);
SRpcMsg
rpcMsg
;
...
...
@@ -759,7 +759,7 @@ int32_t syncNodeProposeBatch(SSyncNode* pSyncNode, SRpcMsg* pMsgArr, bool* pIsWe
SRpcMsg
*
msgArr
=
syncClientRequestBatchRpcMsgArr
(
pSyncMsg
);
ASSERT
(
arrSize
==
pSyncMsg
->
dataCount
);
for
(
int
i
=
0
;
i
<
arrSize
;
++
i
)
{
pMsg
Arr
[
i
].
info
.
conn
.
applyIndex
=
msgArr
[
i
].
info
.
conn
.
applyIndex
;
pMsg
PArr
[
i
]
->
info
.
conn
.
applyIndex
=
msgArr
[
i
].
info
.
conn
.
applyIndex
;
syncRespMgrDel
(
pSyncNode
->
pSyncRespMgr
,
raftArr
[
i
].
seqNum
);
}
...
...
@@ -860,7 +860,8 @@ int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak) {
}
else
{
ret
=
-
1
;
terrno
=
TSDB_CODE_SYN_NOT_LEADER
;
sError
(
"vgId:%d, sync propose not leader, %s"
,
pSyncNode
->
vgId
,
syncUtilState2String
(
pSyncNode
->
state
));
sError
(
"vgId:%d, sync propose not leader, %s, msgtype:%s,%d"
,
pSyncNode
->
vgId
,
syncUtilState2String
(
pSyncNode
->
state
),
TMSG_INFO
(
pMsg
->
msgType
),
pMsg
->
msgType
);
goto
_END
;
}
...
...
source/libs/sync/src/syncMessage.c
浏览文件 @
64f4325b
...
...
@@ -963,9 +963,9 @@ void syncClientRequestLog2(char* s, const SyncClientRequest* pMsg) {
// block2: SRaftMeta array
// block3: rpc msg array (with pCont)
SyncClientRequestBatch
*
syncClientRequestBatchBuild
(
SRpcMsg
*
rpcMsg
Arr
,
SRaftMeta
*
raftArr
,
int32_t
arrSize
,
SyncClientRequestBatch
*
syncClientRequestBatchBuild
(
SRpcMsg
*
*
rpcMsgP
Arr
,
SRaftMeta
*
raftArr
,
int32_t
arrSize
,
int32_t
vgId
)
{
ASSERT
(
rpcMsgArr
!=
NULL
);
ASSERT
(
rpcMsg
P
Arr
!=
NULL
);
ASSERT
(
arrSize
>
0
);
int32_t
dataLen
=
0
;
...
...
@@ -991,7 +991,7 @@ SyncClientRequestBatch* syncClientRequestBatchBuild(SRpcMsg* rpcMsgArr, SRaftMet
raftMetaArr
[
i
].
seqNum
=
raftArr
[
i
].
seqNum
;
// init msgArr
msgArr
[
i
]
=
rpcMsgArr
[
i
]
;
msgArr
[
i
]
=
*
(
rpcMsgPArr
[
i
])
;
}
return
pMsg
;
...
...
source/libs/sync/test/syncClientRequestBatchTest.cpp
浏览文件 @
64f4325b
...
...
@@ -28,12 +28,12 @@ SRpcMsg *createRpcMsg(int32_t i, int32_t dataLen) {
}
SyncClientRequestBatch
*
createMsg
()
{
SRpcMsg
rpcMsg
Arr
[
5
];
memset
(
rpcMsg
Arr
,
0
,
sizeof
(
rpcMsg
Arr
));
SRpcMsg
*
rpcMsgP
Arr
[
5
];
memset
(
rpcMsg
PArr
,
0
,
sizeof
(
rpcMsgP
Arr
));
for
(
int32_t
i
=
0
;
i
<
5
;
++
i
)
{
SRpcMsg
*
pRpcMsg
=
createRpcMsg
(
i
,
20
);
rpcMsg
Arr
[
i
]
=
*
pRpcMsg
;
taosMemoryFree
(
pRpcMsg
);
rpcMsg
PArr
[
i
]
=
pRpcMsg
;
//
taosMemoryFree(pRpcMsg);
}
SRaftMeta
raftArr
[
5
];
...
...
@@ -43,7 +43,7 @@ SyncClientRequestBatch *createMsg() {
raftArr
[
i
].
isWeak
=
i
%
2
;
}
SyncClientRequestBatch
*
pMsg
=
syncClientRequestBatchBuild
(
rpcMsgArr
,
raftArr
,
5
,
1234
);
SyncClientRequestBatch
*
pMsg
=
syncClientRequestBatchBuild
(
rpcMsg
P
Arr
,
raftArr
,
5
,
1234
);
return
pMsg
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录