Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f76261dc
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
f76261dc
编写于
10月 18, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: become leader if replica num is 1
上级
a609f0ef
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
32 addition
and
8 deletion
+32
-8
source/dnode/mnode/impl/src/mndMain.c
source/dnode/mnode/impl/src/mndMain.c
+12
-7
source/dnode/mnode/impl/src/mndMnode.c
source/dnode/mnode/impl/src/mndMnode.c
+6
-0
source/libs/sync/src/syncElection.c
source/libs/sync/src/syncElection.c
+13
-0
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+1
-1
未找到文件。
source/dnode/mnode/impl/src/mndMain.c
浏览文件 @
f76261dc
...
...
@@ -603,22 +603,27 @@ static int32_t mndCheckMnodeState(SRpcMsg *pMsg) {
return
0
;
}
if
(
mndAcquireRpc
(
pMsg
->
info
.
node
)
==
0
)
return
0
;
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
const
char
*
role
=
syncGetMyRoleStr
(
pMnode
->
syncMgmt
.
sync
);
bool
restored
=
syncIsRestoreFinish
(
pMnode
->
syncMgmt
.
sync
);
if
(
pMsg
->
msgType
==
TDMT_MND_MQ_TIMER
||
pMsg
->
msgType
==
TDMT_MND_TELEM_TIMER
||
pMsg
->
msgType
==
TDMT_MND_TRANS_TIMER
||
pMsg
->
msgType
==
TDMT_MND_TTL_TIMER
||
pMsg
->
msgType
==
TDMT_MND_UPTIME_TIMER
)
{
mTrace
(
"timer not process since mnode restored:%d stopped:%d, sync restored:%d role:%s "
,
pMnode
->
restored
,
pMnode
->
stopped
,
restored
,
role
);
return
-
1
;
}
SEpSet
epSet
=
{
0
}
;
S
Mnode
*
pMnode
=
pMsg
->
info
.
node
;
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
S
EpSet
epSet
=
{
0
}
;
mndGetMnodeEpSet
(
pMnode
,
&
epSet
);
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
mDebug
(
"msg:%p,
failed to check mnode state since %s, mnode restored:%d stopped:%d, sync restored:%d role:%s type:%s
"
"numOfEps:%d inUse:%d"
,
pMsg
,
terrstr
(),
pMnode
->
restored
,
pMnode
->
stopped
,
syncIsRestoreFinish
(
pMnode
->
syncMgmt
.
sync
)
,
syncGetMyRoleStr
(
pMnode
->
syncMgmt
.
sync
),
TMSG_INFO
(
pMsg
->
msgType
),
epSet
.
numOfEps
,
epSet
.
inUse
);
"msg:%p,
type:%s failed to process since %s, mnode restored:%d stopped:%d, sync restored:%d
"
"
role:%s, redirect
numOfEps:%d inUse:%d"
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
),
terrstr
(),
pMnode
->
restored
,
pMnode
->
stopped
,
restored
,
role
,
epSet
.
numOfEps
,
epSet
.
inUse
);
if
(
epSet
.
numOfEps
>
0
)
{
for
(
int32_t
i
=
0
;
i
<
epSet
.
numOfEps
;
++
i
)
{
...
...
source/dnode/mnode/impl/src/mndMnode.c
浏览文件 @
f76261dc
...
...
@@ -747,7 +747,13 @@ static void mndReloadSyncConfig(SMnode *pMnode) {
}
if
(
cfg
.
myIndex
==
-
1
)
{
#if 1
mInfo
(
"vgId:1, mnode sync not reconfig since selfIndex is -1"
);
#else
// cannot reconfig because the leader may fail to elect after reboot
mInfo
(
"vgId:1, mnode sync not reconfig since selfIndex is -1, do sync stop oper"
);
syncStop
(
pMnode
->
syncMgmt
.
sync
);
#endif
return
;
}
...
...
source/libs/sync/src/syncElection.c
浏览文件 @
f76261dc
...
...
@@ -96,6 +96,19 @@ int32_t syncNodeElect(SSyncNode* pSyncNode) {
syncNodeCandidate2Leader
(
pSyncNode
);
pSyncNode
->
pVotesGranted
->
toLeader
=
true
;
return
ret
;
}
if
(
pSyncNode
->
replicaNum
==
1
)
{
// only myself, to leader
voteGrantedUpdate
(
pSyncNode
->
pVotesGranted
,
pSyncNode
);
votesRespondUpdate
(
pSyncNode
->
pVotesRespond
,
pSyncNode
);
pSyncNode
->
quorum
=
syncUtilQuorum
(
pSyncNode
->
pRaftCfg
->
cfg
.
replicaNum
);
syncNodeCandidate2Leader
(
pSyncNode
);
pSyncNode
->
pVotesGranted
->
toLeader
=
true
;
return
ret
;
}
switch
(
pSyncNode
->
pRaftCfg
->
snapshotStrategy
)
{
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
f76261dc
...
...
@@ -2282,7 +2282,7 @@ void syncNodeBecomeLeader(SSyncNode* pSyncNode, const char* debugStr) {
void
syncNodeCandidate2Leader
(
SSyncNode
*
pSyncNode
)
{
ASSERT
(
pSyncNode
->
state
==
TAOS_SYNC_STATE_CANDIDATE
);
ASSERT
(
voteGrantedMajority
(
pSyncNode
->
pVotesGranted
));
//
ASSERT(voteGrantedMajority(pSyncNode->pVotesGranted));
syncNodeBecomeLeader
(
pSyncNode
,
"candidate to leader"
);
syncNodeLog2
(
"==state change syncNodeCandidate2Leader=="
,
pSyncNode
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录