Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4ddd25a2
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看板
提交
4ddd25a2
编写于
11月 07, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: adjust sync propose
上级
46e55ba9
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
29 addition
and
37 deletion
+29
-37
source/libs/sync/inc/syncTools.h
source/libs/sync/inc/syncTools.h
+2
-3
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+7
-12
source/libs/sync/src/syncMessage.c
source/libs/sync/src/syncMessage.c
+4
-6
source/libs/sync/test/syncApplyMsgTest.cpp
source/libs/sync/test/syncApplyMsgTest.cpp
+1
-1
source/libs/sync/test/syncClientRequestBatchTest.cpp
source/libs/sync/test/syncClientRequestBatchTest.cpp
+1
-1
source/libs/sync/test/syncClientRequestTest.cpp
source/libs/sync/test/syncClientRequestTest.cpp
+4
-4
source/libs/sync/test/syncEncodeTest.cpp
source/libs/sync/test/syncEncodeTest.cpp
+2
-2
source/libs/sync/test/syncEntryTest.cpp
source/libs/sync/test/syncEntryTest.cpp
+2
-2
source/libs/sync/test/syncRpcMsgTest.cpp
source/libs/sync/test/syncRpcMsgTest.cpp
+2
-2
source/libs/sync/test/syncSnapshotTest.cpp
source/libs/sync/test/syncSnapshotTest.cpp
+2
-2
source/libs/sync/test/syncWriteTest.cpp
source/libs/sync/test/syncWriteTest.cpp
+2
-2
未找到文件。
source/libs/sync/inc/syncTools.h
浏览文件 @
4ddd25a2
...
...
@@ -182,9 +182,8 @@ typedef struct SyncClientRequest {
char
data
[];
// origin RpcMsg.pCont
}
SyncClientRequest
;
SyncClientRequest
*
syncClientRequestBuild
(
uint32_t
dataLen
);
SyncClientRequest
*
syncClientRequestBuild2
(
const
SRpcMsg
*
pOriginalRpcMsg
,
uint64_t
seqNum
,
bool
isWeak
,
int32_t
vgId
);
// step 1
SyncClientRequest
*
syncClientRequestAlloc
(
uint32_t
dataLen
);
SyncClientRequest
*
syncClientRequestBuild
(
const
SRpcMsg
*
pMsg
,
uint64_t
seqNum
,
bool
isWeak
,
int32_t
vgId
);
// step 1
void
syncClientRequestDestroy
(
SyncClientRequest
*
pMsg
);
void
syncClientRequestSerialize
(
const
SyncClientRequest
*
pMsg
,
char
*
buf
,
uint32_t
bufLen
);
void
syncClientRequestDeserialize
(
const
char
*
buf
,
uint32_t
len
,
SyncClientRequest
*
pMsg
);
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
4ddd25a2
...
...
@@ -669,13 +669,11 @@ int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak) {
goto
_END
;
}
SRespStub
stub
;
stub
.
createTime
=
taosGetTimestampMs
();
stub
.
rpcMsg
=
*
pMsg
;
uint64_t
seqNum
=
syncRespMgrAdd
(
pSyncNode
->
pSyncRespMgr
,
&
stub
);
SRespStub
stub
=
{.
createTime
=
taosGetTimestampMs
(),
.
rpcMsg
=
*
pMsg
};
uint64_t
seqNum
=
syncRespMgrAdd
(
pSyncNode
->
pSyncRespMgr
,
&
stub
);
SyncClientRequest
*
pSyncMsg
=
syncClientRequestBuild
2
(
pMsg
,
seqNum
,
isWeak
,
pSyncNode
->
vgId
);
SRpcMsg
rpcMsg
;
SyncClientRequest
*
pSyncMsg
=
syncClientRequestBuild
(
pMsg
,
seqNum
,
isWeak
,
pSyncNode
->
vgId
);
SRpcMsg
rpcMsg
=
{
0
}
;
syncClientRequest2RpcMsg
(
pSyncMsg
,
&
rpcMsg
);
// optimized one replica
...
...
@@ -696,12 +694,9 @@ int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak) {
sError
(
"vgId:%d, failed to sync optimize index:%"
PRId64
", type:%s"
,
pSyncNode
->
vgId
,
retIndex
,
TMSG_INFO
(
pMsg
->
msgType
));
}
}
else
{
if
(
pSyncNode
->
syncEqMsg
!=
NULL
&&
(
*
pSyncNode
->
syncEqMsg
)(
pSyncNode
->
msgcb
,
&
rpcMsg
)
==
0
)
{
ret
=
0
;
}
else
{
ret
=
-
1
;
ret
=
(
*
pSyncNode
->
syncEqMsg
)(
pSyncNode
->
msgcb
,
&
rpcMsg
);
if
(
ret
!=
0
)
{
terrno
=
TSDB_CODE_SYN_INTERNAL_ERROR
;
sError
(
"vgId:%d, failed to enqueue msg since its null"
,
pSyncNode
->
vgId
);
}
...
...
@@ -2322,7 +2317,7 @@ static int32_t syncNodeEqNoop(SSyncNode* ths) {
uint32_t
entryLen
;
char
*
serialized
=
syncEntrySerialize
(
pEntry
,
&
entryLen
);
SyncClientRequest
*
pSyncMsg
=
syncClientRequest
Build
(
entryLen
);
SyncClientRequest
*
pSyncMsg
=
syncClientRequest
Alloc
(
entryLen
);
ASSERT
(
pSyncMsg
->
dataLen
==
entryLen
);
memcpy
(
pSyncMsg
->
data
,
serialized
,
entryLen
);
...
...
source/libs/sync/src/syncMessage.c
浏览文件 @
4ddd25a2
...
...
@@ -831,10 +831,9 @@ void syncPingReplyLog2(char* s, const SyncPingReply* pMsg) {
}
// ---- message process SyncClientRequest----
SyncClientRequest
*
syncClientRequest
Build
(
uint32_t
dataLen
)
{
SyncClientRequest
*
syncClientRequest
Alloc
(
uint32_t
dataLen
)
{
uint32_t
bytes
=
sizeof
(
SyncClientRequest
)
+
dataLen
;
SyncClientRequest
*
pMsg
=
taosMemoryMalloc
(
bytes
);
memset
(
pMsg
,
0
,
bytes
);
SyncClientRequest
*
pMsg
=
taosMemoryCalloc
(
1
,
bytes
);
pMsg
->
bytes
=
bytes
;
pMsg
->
msgType
=
TDMT_SYNC_CLIENT_REQUEST
;
pMsg
->
seqNum
=
0
;
...
...
@@ -844,8 +843,8 @@ SyncClientRequest* syncClientRequestBuild(uint32_t dataLen) {
}
// step 1. original SRpcMsg => SyncClientRequest, add seqNum, isWeak
SyncClientRequest
*
syncClientRequestBuild
2
(
const
SRpcMsg
*
pOriginalRpcMsg
,
uint64_t
seqNum
,
bool
isWeak
,
int32_t
vgId
)
{
SyncClientRequest
*
pMsg
=
syncClientRequest
Build
(
pOriginalRpcMsg
->
contLen
);
SyncClientRequest
*
syncClientRequestBuild
(
const
SRpcMsg
*
pOriginalRpcMsg
,
uint64_t
seqNum
,
bool
isWeak
,
int32_t
vgId
)
{
SyncClientRequest
*
pMsg
=
syncClientRequest
Alloc
(
pOriginalRpcMsg
->
contLen
);
pMsg
->
vgId
=
vgId
;
pMsg
->
originalRpcType
=
pOriginalRpcMsg
->
msgType
;
pMsg
->
seqNum
=
seqNum
;
...
...
@@ -891,7 +890,6 @@ SyncClientRequest* syncClientRequestDeserialize2(const char* buf, uint32_t len)
// step 2. SyncClientRequest => RpcMsg, to queue
void
syncClientRequest2RpcMsg
(
const
SyncClientRequest
*
pMsg
,
SRpcMsg
*
pRpcMsg
)
{
memset
(
pRpcMsg
,
0
,
sizeof
(
*
pRpcMsg
));
pRpcMsg
->
msgType
=
pMsg
->
msgType
;
pRpcMsg
->
contLen
=
pMsg
->
bytes
;
pRpcMsg
->
pCont
=
rpcMallocCont
(
pRpcMsg
->
contLen
);
...
...
source/libs/sync/test/syncApplyMsgTest.cpp
浏览文件 @
4ddd25a2
...
...
@@ -81,7 +81,7 @@ void test4() {
void
test5
()
{
SyncApplyMsg
*
pMsg
=
createMsg
();
SRpcMsg
rpcMsg
;
SRpcMsg
rpcMsg
=
{
0
}
;
syncApplyMsg2RpcMsg
(
pMsg
,
&
rpcMsg
);
SyncApplyMsg
*
pMsg2
=
syncApplyMsgFromRpcMsg2
(
&
rpcMsg
);
syncApplyMsgLog2
((
char
*
)
"test5: syncClientRequest2RpcMsg -> syncApplyMsgFromRpcMsg2 "
,
pMsg2
);
...
...
source/libs/sync/test/syncClientRequestBatchTest.cpp
浏览文件 @
4ddd25a2
...
...
@@ -59,7 +59,7 @@ void test2() {
uint32_t len = pMsg->bytes;
char * serialized = (char *)taosMemoryMalloc(len);
syncClientRequestSerialize(pMsg, serialized, len);
SyncClientRequest *pMsg2 = syncClientRequest
Build
(pMsg->dataLen);
SyncClientRequest *pMsg2 = syncClientRequest
Alloc
(pMsg->dataLen);
syncClientRequestDeserialize(serialized, len, pMsg2);
syncClientRequestLog2((char *)"test2: syncClientRequestSerialize -> syncClientRequestDeserialize ", pMsg2);
...
...
source/libs/sync/test/syncClientRequestTest.cpp
浏览文件 @
4ddd25a2
...
...
@@ -21,7 +21,7 @@ SyncClientRequest *createMsg() {
rpcMsg
.
contLen
=
20
;
rpcMsg
.
pCont
=
rpcMallocCont
(
rpcMsg
.
contLen
);
strcpy
((
char
*
)
rpcMsg
.
pCont
,
"hello rpc"
);
SyncClientRequest
*
pMsg
=
syncClientRequestBuild
2
(
&
rpcMsg
,
123
,
true
,
1000
);
SyncClientRequest
*
pMsg
=
syncClientRequestBuild
(
&
rpcMsg
,
123
,
true
,
1000
);
rpcFreeCont
(
rpcMsg
.
pCont
);
return
pMsg
;
}
...
...
@@ -37,7 +37,7 @@ void test2() {
uint32_t
len
=
pMsg
->
bytes
;
char
*
serialized
=
(
char
*
)
taosMemoryMalloc
(
len
);
syncClientRequestSerialize
(
pMsg
,
serialized
,
len
);
SyncClientRequest
*
pMsg2
=
syncClientRequest
Build
(
pMsg
->
dataLen
);
SyncClientRequest
*
pMsg2
=
syncClientRequest
Alloc
(
pMsg
->
dataLen
);
syncClientRequestDeserialize
(
serialized
,
len
,
pMsg2
);
syncClientRequestLog2
((
char
*
)
"test2: syncClientRequestSerialize -> syncClientRequestDeserialize "
,
pMsg2
);
...
...
@@ -60,7 +60,7 @@ void test3() {
void
test4
()
{
SyncClientRequest
*
pMsg
=
createMsg
();
SRpcMsg
rpcMsg
;
SRpcMsg
rpcMsg
=
{
0
}
;
syncClientRequest2RpcMsg
(
pMsg
,
&
rpcMsg
);
SyncClientRequest
*
pMsg2
=
(
SyncClientRequest
*
)
taosMemoryMalloc
(
rpcMsg
.
contLen
);
syncClientRequestFromRpcMsg
(
&
rpcMsg
,
pMsg2
);
...
...
@@ -73,7 +73,7 @@ void test4() {
void
test5
()
{
SyncClientRequest
*
pMsg
=
createMsg
();
SRpcMsg
rpcMsg
;
SRpcMsg
rpcMsg
=
{
0
}
;
syncClientRequest2RpcMsg
(
pMsg
,
&
rpcMsg
);
SyncClientRequest
*
pMsg2
=
syncClientRequestFromRpcMsg2
(
&
rpcMsg
);
syncClientRequestLog2
((
char
*
)
"test5: syncClientRequest2RpcMsg -> syncClientRequestFromRpcMsg2 "
,
pMsg2
);
...
...
source/libs/sync/test/syncEncodeTest.cpp
浏览文件 @
4ddd25a2
...
...
@@ -102,12 +102,12 @@ SRpcMsg *step0() {
}
SyncClientRequest
*
step1
(
const
SRpcMsg
*
pMsg
)
{
SyncClientRequest
*
pRetMsg
=
syncClientRequestBuild
2
(
pMsg
,
123
,
true
,
1000
);
SyncClientRequest
*
pRetMsg
=
syncClientRequestBuild
(
pMsg
,
123
,
true
,
1000
);
return
pRetMsg
;
}
SRpcMsg
*
step2
(
const
SyncClientRequest
*
pMsg
)
{
SRpcMsg
*
pRetMsg
=
(
SRpcMsg
*
)
taosMemory
Malloc
(
sizeof
(
SRpcMsg
)
);
SRpcMsg
*
pRetMsg
=
(
SRpcMsg
*
)
taosMemory
Calloc
(
sizeof
(
SRpcMsg
),
1
);
syncClientRequest2RpcMsg
(
pMsg
,
pRetMsg
);
return
pRetMsg
;
}
...
...
source/libs/sync/test/syncEntryTest.cpp
浏览文件 @
4ddd25a2
...
...
@@ -32,7 +32,7 @@ void test1() {
}
void
test2
()
{
SyncClientRequest
*
pSyncMsg
=
syncClientRequest
Build
(
10
);
SyncClientRequest
*
pSyncMsg
=
syncClientRequest
Alloc
(
10
);
pSyncMsg
->
originalRpcType
=
33
;
pSyncMsg
->
seqNum
=
11
;
pSyncMsg
->
isWeak
=
1
;
...
...
@@ -46,7 +46,7 @@ void test2() {
}
void
test3
()
{
SyncClientRequest
*
pSyncMsg
=
syncClientRequest
Build
(
10
);
SyncClientRequest
*
pSyncMsg
=
syncClientRequest
Alloc
(
10
);
pSyncMsg
->
originalRpcType
=
33
;
pSyncMsg
->
seqNum
=
11
;
pSyncMsg
->
isWeak
=
1
;
...
...
source/libs/sync/test/syncRpcMsgTest.cpp
浏览文件 @
4ddd25a2
...
...
@@ -47,7 +47,7 @@ SyncClientRequest *createSyncClientRequest() {
rpcMsg
.
contLen
=
20
;
rpcMsg
.
pCont
=
rpcMallocCont
(
rpcMsg
.
contLen
);
strcpy
((
char
*
)
rpcMsg
.
pCont
,
"hello rpc"
);
SyncClientRequest
*
pMsg
=
syncClientRequestBuild
2
(
&
rpcMsg
,
123
,
true
,
1000
);
SyncClientRequest
*
pMsg
=
syncClientRequestBuild
(
&
rpcMsg
,
123
,
true
,
1000
);
return
pMsg
;
}
...
...
@@ -156,7 +156,7 @@ void test7() {
void
test8
()
{
SyncClientRequest
*
pMsg
=
createSyncClientRequest
();
SRpcMsg
rpcMsg
;
SRpcMsg
rpcMsg
=
{
0
}
;
syncClientRequest2RpcMsg
(
pMsg
,
&
rpcMsg
);
syncRpcMsgLog2
((
char
*
)
"test8"
,
&
rpcMsg
);
syncClientRequestDestroy
(
pMsg
);
...
...
source/libs/sync/test/syncSnapshotTest.cpp
浏览文件 @
4ddd25a2
...
...
@@ -162,7 +162,7 @@ SRpcMsg *step0() {
}
SyncClientRequest
*
step1
(
const
SRpcMsg
*
pMsg
)
{
SyncClientRequest
*
pRetMsg
=
syncClientRequestBuild
2
(
pMsg
,
123
,
true
,
1000
);
SyncClientRequest
*
pRetMsg
=
syncClientRequestBuild
(
pMsg
,
123
,
true
,
1000
);
return
pRetMsg
;
}
...
...
@@ -206,7 +206,7 @@ int main(int argc, char **argv) {
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
SyncClientRequest
*
pSyncClientRequest
=
pMsg1
;
SRpcMsg
rpcMsg
;
SRpcMsg
rpcMsg
=
{
0
}
;
syncClientRequest2RpcMsg
(
pSyncClientRequest
,
&
rpcMsg
);
gSyncNode
->
syncEqMsg
(
gSyncNode
->
msgcb
,
&
rpcMsg
);
...
...
source/libs/sync/test/syncWriteTest.cpp
浏览文件 @
4ddd25a2
...
...
@@ -140,7 +140,7 @@ SRpcMsg *step0() {
}
SyncClientRequest
*
step1
(
const
SRpcMsg
*
pMsg
)
{
SyncClientRequest
*
pRetMsg
=
syncClientRequestBuild
2
(
pMsg
,
123
,
true
,
1000
);
SyncClientRequest
*
pRetMsg
=
syncClientRequestBuild
(
pMsg
,
123
,
true
,
1000
);
return
pRetMsg
;
}
...
...
@@ -181,7 +181,7 @@ int main(int argc, char **argv) {
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
SyncClientRequest
*
pSyncClientRequest
=
pMsg1
;
SRpcMsg
rpcMsg
;
SRpcMsg
rpcMsg
=
{
0
}
;
syncClientRequest2RpcMsg
(
pSyncClientRequest
,
&
rpcMsg
);
gSyncNode
->
syncEqMsg
(
gSyncNode
->
msgcb
,
&
rpcMsg
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录