Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f7cd02a9
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看板
未验证
提交
f7cd02a9
编写于
4月 26, 2022
作者:
L
Li Minghao
提交者:
GitHub
4月 26, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #11886 from taosdata/feature/3.0_mhli
enh: add flag in syncEnv, to deal with expired timer
上级
e15d78e2
16d60bf3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
75 addition
and
55 deletion
+75
-55
include/libs/sync/sync.h
include/libs/sync/sync.h
+2
-0
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+60
-55
source/libs/sync/inc/syncEnv.h
source/libs/sync/inc/syncEnv.h
+2
-0
source/libs/sync/src/syncEnv.c
source/libs/sync/src/syncEnv.c
+11
-0
未找到文件。
include/libs/sync/sync.h
浏览文件 @
f7cd02a9
...
...
@@ -158,6 +158,8 @@ typedef enum {
int32_t
syncPropose
(
int64_t
rid
,
const
SRpcMsg
*
pMsg
,
bool
isWeak
);
bool
syncEnvIsStart
();
extern
int32_t
sDebugFlag
;
//-----------------------------------------
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
f7cd02a9
...
...
@@ -193,84 +193,89 @@ void smaHandleRes(void *pVnode, int64_t smaId, const SArray *data) {
// sync integration
int
vnodeProcessSyncReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
)
{
SSyncNode
*
pSyncNode
=
syncNodeAcquire
(
pVnode
->
sync
);
assert
(
pSyncNode
!=
NULL
);
ESyncState
state
=
syncGetMyRole
(
pVnode
->
sync
);
SyncTerm
currentTerm
=
syncGetMyTerm
(
pVnode
->
sync
);
if
(
syncEnvIsStart
())
{
SMsgHead
*
pHead
=
pMsg
->
pCont
;
SSyncNode
*
pSyncNode
=
syncNodeAcquire
(
pVnode
->
sync
);
assert
(
pSyncNode
!=
NULL
);
char
logBuf
[
512
];
char
*
syncNodeStr
=
sync2SimpleStr
(
pVnode
->
sync
);
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==vnodeProcessSyncReq== msgType:%d, syncNode: %s"
,
pMsg
->
msgType
,
syncNodeStr
);
syncRpcMsgLog2
(
logBuf
,
pMsg
);
taosMemoryFree
(
syncNodeStr
);
ESyncState
state
=
syncGetMyRole
(
pVnode
->
sync
);
SyncTerm
currentTerm
=
syncGetMyTerm
(
pVnode
->
sync
);
SRpcMsg
*
pRpcMsg
=
pMsg
;
SMsgHead
*
pHead
=
pMsg
->
pCont
;
if
(
pRpcMsg
->
msgType
==
TDMT_VND_SYNC_TIMEOUT
)
{
SyncTimeout
*
pSyncMsg
=
syncTimeoutFromRpcMsg2
(
pRpcMsg
);
assert
(
pSyncMsg
!=
NULL
);
char
logBuf
[
512
];
char
*
syncNodeStr
=
sync2SimpleStr
(
pVnode
->
sync
);
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==vnodeProcessSyncReq== msgType:%d, syncNode: %s"
,
pMsg
->
msgType
,
syncNodeStr
);
syncRpcMsgLog2
(
logBuf
,
pMsg
);
taosMemoryFree
(
syncNodeStr
);
syncNodeOnTimeoutCb
(
pSyncNode
,
pSyncMsg
);
syncTimeoutDestroy
(
pSyncMsg
);
SRpcMsg
*
pRpcMsg
=
pMsg
;
}
else
if
(
pRpcMsg
->
msgType
==
TDMT_VND_SYNC_PING
)
{
SyncPing
*
pSyncMsg
=
syncPing
FromRpcMsg2
(
pRpcMsg
);
assert
(
pSyncMsg
!=
NULL
);
if
(
pRpcMsg
->
msgType
==
TDMT_VND_SYNC_TIMEOUT
)
{
SyncTimeout
*
pSyncMsg
=
syncTimeout
FromRpcMsg2
(
pRpcMsg
);
assert
(
pSyncMsg
!=
NULL
);
syncNodeOnPing
Cb
(
pSyncNode
,
pSyncMsg
);
syncPing
Destroy
(
pSyncMsg
);
syncNodeOnTimeout
Cb
(
pSyncNode
,
pSyncMsg
);
syncTimeout
Destroy
(
pSyncMsg
);
}
else
if
(
pRpcMsg
->
msgType
==
TDMT_VND_SYNC_PING_REPLY
)
{
SyncPingReply
*
pSyncMsg
=
syncPingReply
FromRpcMsg2
(
pRpcMsg
);
assert
(
pSyncMsg
!=
NULL
);
}
else
if
(
pRpcMsg
->
msgType
==
TDMT_VND_SYNC_PING
)
{
SyncPing
*
pSyncMsg
=
syncPing
FromRpcMsg2
(
pRpcMsg
);
assert
(
pSyncMsg
!=
NULL
);
syncNodeOnPingReply
Cb
(
pSyncNode
,
pSyncMsg
);
syncPingReply
Destroy
(
pSyncMsg
);
syncNodeOnPing
Cb
(
pSyncNode
,
pSyncMsg
);
syncPing
Destroy
(
pSyncMsg
);
}
else
if
(
pRpcMsg
->
msgType
==
TDMT_VND_SYNC_CLIENT_REQUEST
)
{
SyncClientRequest
*
pSyncMsg
=
syncClientRequest
FromRpcMsg2
(
pRpcMsg
);
assert
(
pSyncMsg
!=
NULL
);
}
else
if
(
pRpcMsg
->
msgType
==
TDMT_VND_SYNC_PING_REPLY
)
{
SyncPingReply
*
pSyncMsg
=
syncPingReply
FromRpcMsg2
(
pRpcMsg
);
assert
(
pSyncMsg
!=
NULL
);
syncNodeOnClientRequest
Cb
(
pSyncNode
,
pSyncMsg
);
syncClientRequest
Destroy
(
pSyncMsg
);
syncNodeOnPingReply
Cb
(
pSyncNode
,
pSyncMsg
);
syncPingReply
Destroy
(
pSyncMsg
);
}
else
if
(
pRpcMsg
->
msgType
==
TDMT_VND_SYNC_REQUEST_VOTE
)
{
SyncRequestVote
*
pSyncMsg
=
syncRequestVote
FromRpcMsg2
(
pRpcMsg
);
assert
(
pSyncMsg
!=
NULL
);
}
else
if
(
pRpcMsg
->
msgType
==
TDMT_VND_SYNC_CLIENT_REQUEST
)
{
SyncClientRequest
*
pSyncMsg
=
syncClientRequest
FromRpcMsg2
(
pRpcMsg
);
assert
(
pSyncMsg
!=
NULL
);
syncNodeOnRequestVote
Cb
(
pSyncNode
,
pSyncMsg
);
syncRequestVote
Destroy
(
pSyncMsg
);
syncNodeOnClientRequest
Cb
(
pSyncNode
,
pSyncMsg
);
syncClientRequest
Destroy
(
pSyncMsg
);
}
else
if
(
pRpcMsg
->
msgType
==
TDMT_VND_SYNC_REQUEST_VOTE_REPLY
)
{
SyncRequestVoteReply
*
pSyncMsg
=
syncRequestVoteReply
FromRpcMsg2
(
pRpcMsg
);
assert
(
pSyncMsg
!=
NULL
);
}
else
if
(
pRpcMsg
->
msgType
==
TDMT_VND_SYNC_REQUEST_VOTE
)
{
SyncRequestVote
*
pSyncMsg
=
syncRequestVote
FromRpcMsg2
(
pRpcMsg
);
assert
(
pSyncMsg
!=
NULL
);
syncNodeOnRequestVoteReply
Cb
(
pSyncNode
,
pSyncMsg
);
syncRequestVoteReply
Destroy
(
pSyncMsg
);
syncNodeOnRequestVote
Cb
(
pSyncNode
,
pSyncMsg
);
syncRequestVote
Destroy
(
pSyncMsg
);
}
else
if
(
pRpcMsg
->
msgType
==
TDMT_VND_SYNC_APPEND_ENTRIES
)
{
SyncAppendEntries
*
pSyncMsg
=
syncAppendEntries
FromRpcMsg2
(
pRpcMsg
);
assert
(
pSyncMsg
!=
NULL
);
}
else
if
(
pRpcMsg
->
msgType
==
TDMT_VND_SYNC_REQUEST_VOTE_REPLY
)
{
SyncRequestVoteReply
*
pSyncMsg
=
syncRequestVoteReply
FromRpcMsg2
(
pRpcMsg
);
assert
(
pSyncMsg
!=
NULL
);
syncNodeOnAppendEntries
Cb
(
pSyncNode
,
pSyncMsg
);
syncAppendEntries
Destroy
(
pSyncMsg
);
syncNodeOnRequestVoteReply
Cb
(
pSyncNode
,
pSyncMsg
);
syncRequestVoteReply
Destroy
(
pSyncMsg
);
}
else
if
(
pRpcMsg
->
msgType
==
TDMT_VND_SYNC_APPEND_ENTRIES_REPLY
)
{
SyncAppendEntriesReply
*
pSyncMsg
=
syncAppendEntriesReply
FromRpcMsg2
(
pRpcMsg
);
assert
(
pSyncMsg
!=
NULL
);
}
else
if
(
pRpcMsg
->
msgType
==
TDMT_VND_SYNC_APPEND_ENTRIES
)
{
SyncAppendEntries
*
pSyncMsg
=
syncAppendEntries
FromRpcMsg2
(
pRpcMsg
);
assert
(
pSyncMsg
!=
NULL
);
syncNodeOnAppendEntriesReply
Cb
(
pSyncNode
,
pSyncMsg
);
syncAppendEntriesReply
Destroy
(
pSyncMsg
);
syncNodeOnAppendEntries
Cb
(
pSyncNode
,
pSyncMsg
);
syncAppendEntries
Destroy
(
pSyncMsg
);
}
else
{
vError
(
"==vnodeProcessSyncReq== error msg type:%d"
,
pRpcMsg
->
msgType
);
}
}
else
if
(
pRpcMsg
->
msgType
==
TDMT_VND_SYNC_APPEND_ENTRIES_REPLY
)
{
SyncAppendEntriesReply
*
pSyncMsg
=
syncAppendEntriesReplyFromRpcMsg2
(
pRpcMsg
);
assert
(
pSyncMsg
!=
NULL
);
syncNodeRelease
(
pSyncNode
);
syncNodeOnAppendEntriesReplyCb
(
pSyncNode
,
pSyncMsg
);
syncAppendEntriesReplyDestroy
(
pSyncMsg
);
}
else
{
vError
(
"==vnodeProcessSyncReq== error msg type:%d"
,
pRpcMsg
->
msgType
);
}
syncNodeRelease
(
pSyncNode
);
}
else
{
vError
(
"==vnodeProcessSyncReq== error syncEnv stop"
);
}
return
0
;
}
...
...
source/libs/sync/inc/syncEnv.h
浏览文件 @
f7cd02a9
...
...
@@ -39,6 +39,8 @@ extern "C" {
#define EMPTY_RAFT_ID ((SRaftId){.addr = 0, .vgId = 0})
typedef
struct
SSyncEnv
{
uint8_t
isStart
;
// tick timer
tmr_h
pEnvTickTimer
;
int32_t
envTickTimerMS
;
...
...
source/libs/sync/src/syncEnv.c
浏览文件 @
f7cd02a9
...
...
@@ -26,6 +26,14 @@ static int32_t doSyncEnvStopTimer(SSyncEnv *pSyncEnv);
static
void
syncEnvTick
(
void
*
param
,
void
*
tmrId
);
// --------------------------------
bool
syncEnvIsStart
()
{
if
(
gSyncEnv
==
NULL
)
{
return
false
;
}
return
atomic_load_8
(
&
(
gSyncEnv
->
isStart
));
}
int32_t
syncEnvStart
()
{
int32_t
ret
=
0
;
taosSeedRand
(
taosGetTimestampSec
());
...
...
@@ -88,12 +96,15 @@ static SSyncEnv *doSyncEnvStart() {
// start tmr thread
pSyncEnv
->
pTimerManager
=
taosTmrInit
(
1000
,
50
,
10000
,
"SYNC-ENV"
);
atomic_store_8
(
&
(
pSyncEnv
->
isStart
),
1
);
return
pSyncEnv
;
}
static
int32_t
doSyncEnvStop
(
SSyncEnv
*
pSyncEnv
)
{
assert
(
pSyncEnv
==
gSyncEnv
);
if
(
pSyncEnv
!=
NULL
)
{
atomic_store_8
(
&
(
pSyncEnv
->
isStart
),
0
);
taosTmrCleanUp
(
pSyncEnv
->
pTimerManager
);
taosMemoryFree
(
pSyncEnv
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录