Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
cc29662b
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看板
提交
cc29662b
编写于
12月 28, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: adjust weight of mnode while balance
上级
c9b81efc
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
13 addition
and
12 deletion
+13
-12
source/dnode/mnode/impl/src/mndVgroup.c
source/dnode/mnode/impl/src/mndVgroup.c
+13
-12
未找到文件。
source/dnode/mnode/impl/src/mndVgroup.c
浏览文件 @
cc29662b
...
...
@@ -480,13 +480,14 @@ SArray *mndBuildDnodesArray(SMnode *pMnode, int32_t exceptDnodeId) {
static
int32_t
mndCompareDnodeId
(
int32_t
*
dnode1Id
,
int32_t
*
dnode2Id
)
{
return
*
dnode1Id
>=
*
dnode2Id
?
1
:
0
;
}
static
float
mndGetDnodeScore
(
SDnodeObj
*
pDnode
)
{
return
((
float
)
pDnode
->
numOfVnodes
+
(
float
)
pDnode
->
numOfOtherNodes
*
0
.
9
)
/
pDnode
->
numOfSupportVnodes
;
static
float
mndGetDnodeScore
(
SDnodeObj
*
pDnode
,
int32_t
additionDnodes
,
float
ratio
)
{
float
totalDnodes
=
pDnode
->
numOfVnodes
+
(
float
)
pDnode
->
numOfOtherNodes
*
ratio
+
additionDnodes
;
return
totalDnodes
/
pDnode
->
numOfSupportVnodes
;
}
static
int32_t
mndCompareDnodeVnodes
(
SDnodeObj
*
pDnode1
,
SDnodeObj
*
pDnode2
)
{
float
d1Score
=
mndGetDnodeScore
(
pDnode1
);
float
d2Score
=
mndGetDnodeScore
(
pDnode2
);
float
d1Score
=
mndGetDnodeScore
(
pDnode1
,
0
,
0
.
9
);
float
d2Score
=
mndGetDnodeScore
(
pDnode2
,
0
,
0
.
9
);
return
d1Score
>=
d2Score
?
1
:
0
;
}
...
...
@@ -509,7 +510,7 @@ static int32_t mndGetAvailableDnode(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgroup
taosArraySort
(
pArray
,
(
__compar_fn_t
)
mndCompareDnodeVnodes
);
for
(
int32_t
i
=
0
;
i
<
(
int32_t
)
taosArrayGetSize
(
pArray
);
++
i
)
{
SDnodeObj
*
pDnode
=
taosArrayGet
(
pArray
,
i
);
mDebug
(
"dnode:%d, score:%f"
,
pDnode
->
id
,
mndGetDnodeScore
(
pDnode
));
mDebug
(
"dnode:%d, score:%f"
,
pDnode
->
id
,
mndGetDnodeScore
(
pDnode
,
0
,
0
.
9
));
}
int32_t
size
=
taosArrayGetSize
(
pArray
);
...
...
@@ -891,7 +892,7 @@ static int32_t mndAddVnodeToVgroup(SMnode *pMnode, STrans *pTrans, SVgObj *pVgro
taosArraySort
(
pArray
,
(
__compar_fn_t
)
mndCompareDnodeVnodes
);
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pArray
);
++
i
)
{
SDnodeObj
*
pDnode
=
taosArrayGet
(
pArray
,
i
);
mInfo
(
"dnode:%d, equivalent vnodes:%d
"
,
pDnode
->
id
,
pDnode
->
numOfVn
odes
);
mInfo
(
"dnode:%d, equivalent vnodes:%d
others:%d"
,
pDnode
->
id
,
pDnode
->
numOfVnodes
,
pDnode
->
numOfOtherN
odes
);
}
SVnodeGid
*
pVgid
=
&
pVgroup
->
vnodeGid
[
pVgroup
->
replica
];
...
...
@@ -951,7 +952,7 @@ static int32_t mndRemoveVnodeFromVgroup(SMnode *pMnode, STrans *pTrans, SVgObj *
taosArraySort
(
pArray
,
(
__compar_fn_t
)
mndCompareDnodeVnodes
);
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pArray
);
++
i
)
{
SDnodeObj
*
pDnode
=
taosArrayGet
(
pArray
,
i
);
mInfo
(
"dnode:%d, equivalent vnodes:%d
"
,
pDnode
->
id
,
pDnode
->
numOfVn
odes
);
mInfo
(
"dnode:%d, equivalent vnodes:%d
others:%d"
,
pDnode
->
id
,
pDnode
->
numOfVnodes
,
pDnode
->
numOfOtherN
odes
);
}
int32_t
code
=
-
1
;
...
...
@@ -1986,16 +1987,16 @@ static int32_t mndBalanceVgroup(SMnode *pMnode, SRpcMsg *pReq, SArray *pArray) {
taosArraySort
(
pArray
,
(
__compar_fn_t
)
mndCompareDnodeVnodes
);
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pArray
);
++
i
)
{
SDnodeObj
*
pDnode
=
taosArrayGet
(
pArray
,
i
);
mInfo
(
"dnode:%d, equivalent vnodes:%d support:%d, score:%f"
,
pDnode
->
id
,
pDnode
->
numOfVnodes
,
pDnode
->
numOfSupportVnodes
,
(
float
)
pDnode
->
numOfVnodes
/
pDnode
->
numOfSupportVnodes
);
mInfo
(
"dnode:%d, equivalent vnodes:%d
others:%d
support:%d, score:%f"
,
pDnode
->
id
,
pDnode
->
numOfVnodes
,
pDnode
->
numOfSupportVnodes
,
pDnode
->
numOfOtherNodes
,
mndGetDnodeScore
(
pDnode
,
0
,
1
)
);
}
SDnodeObj
*
pSrc
=
taosArrayGet
(
pArray
,
taosArrayGetSize
(
pArray
)
-
1
);
SDnodeObj
*
pDst
=
taosArrayGet
(
pArray
,
0
);
float
srcScore
=
(
float
)(
pSrc
->
numOfVnodes
-
1
)
/
pSrc
->
numOfSupportVnodes
;
float
dstScore
=
(
float
)(
pDst
->
numOfVnodes
+
1
)
/
pDst
->
numOfSupportVnodes
;
mInfo
(
"trans:%d, after balance, src dnode:%d score:%f, dst dnode:%d score:%f"
,
pTrans
->
id
,
pSrc
->
id
,
src
Score
,
float
srcScore
=
mndGetDnodeScore
(
pSrc
,
-
1
,
1
)
;
float
dstScore
=
mndGetDnodeScore
(
pDst
,
1
,
1
)
;
mInfo
(
"trans:%d, after balance, src dnode:%d score:%f, dst dnode:%d score:%f"
,
pTrans
->
id
,
pSrc
->
id
,
dst
Score
,
pDst
->
id
,
dstScore
);
if
(
srcScore
>
dstScore
-
0
.
000001
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录