Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6e9b5d1b
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
未验证
提交
6e9b5d1b
编写于
12月 29, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
12月 29, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #19219 from taosdata/fix/TD-21566
fix: support_vnodes and the max supported vgroups mis-match
上级
80d3c27a
bffe45c7
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
46 addition
and
28 deletion
+46
-28
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+1
-0
source/dnode/mnode/impl/src/mndVgroup.c
source/dnode/mnode/impl/src/mndVgroup.c
+27
-10
tests/script/tsim/dnode/balance1.sim
tests/script/tsim/dnode/balance1.sim
+2
-2
tests/script/tsim/dnode/balance2.sim
tests/script/tsim/dnode/balance2.sim
+2
-2
tests/script/tsim/dnode/balance3.sim
tests/script/tsim/dnode/balance3.sim
+4
-4
tests/script/tsim/dnode/balancex.sim
tests/script/tsim/dnode/balancex.sim
+2
-2
tests/script/tsim/dnode/vnode_clean.sim
tests/script/tsim/dnode/vnode_clean.sim
+8
-8
未找到文件。
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
6e9b5d1b
...
...
@@ -193,6 +193,7 @@ typedef struct {
int64_t
lastAccessTime
;
int32_t
accessTimes
;
int32_t
numOfVnodes
;
int32_t
numOfOtherNodes
;
int32_t
numOfSupportVnodes
;
float
numOfCores
;
int64_t
memTotal
;
...
...
source/dnode/mnode/impl/src/mndVgroup.c
浏览文件 @
6e9b5d1b
...
...
@@ -425,6 +425,7 @@ void *mndBuildDropVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgOb
static
bool
mndResetDnodesArrayFp
(
SMnode
*
pMnode
,
void
*
pObj
,
void
*
p1
,
void
*
p2
,
void
*
p3
)
{
SDnodeObj
*
pDnode
=
pObj
;
pDnode
->
numOfVnodes
=
0
;
pDnode
->
numOfOtherNodes
=
0
;
return
true
;
}
...
...
@@ -447,7 +448,7 @@ static bool mndBuildDnodesArrayFp(SMnode *pMnode, void *pObj, void *p1, void *p2
pDnode
->
numOfVnodes
,
pDnode
->
numOfSupportVnodes
,
isMnode
,
online
,
pDnode
->
memAvail
,
pDnode
->
memUsed
);
if
(
isMnode
)
{
pDnode
->
numOf
Vn
odes
++
;
pDnode
->
numOf
OtherN
odes
++
;
}
if
(
online
&&
pDnode
->
numOfSupportVnodes
>
0
)
{
...
...
@@ -468,14 +469,25 @@ SArray *mndBuildDnodesArray(SMnode *pMnode, int32_t exceptDnodeId) {
sdbTraverse
(
pSdb
,
SDB_DNODE
,
mndResetDnodesArrayFp
,
NULL
,
NULL
,
NULL
);
sdbTraverse
(
pSdb
,
SDB_DNODE
,
mndBuildDnodesArrayFp
,
pArray
,
&
exceptDnodeId
,
NULL
);
mDebug
(
"build %d dnodes array"
,
(
int32_t
)
taosArrayGetSize
(
pArray
));
for
(
int32_t
i
=
0
;
i
<
(
int32_t
)
taosArrayGetSize
(
pArray
);
++
i
)
{
SDnodeObj
*
pDnode
=
taosArrayGet
(
pArray
,
i
);
mDebug
(
"dnode:%d, vnodes:%d others:%d"
,
pDnode
->
id
,
pDnode
->
numOfVnodes
,
pDnode
->
numOfOtherNodes
);
}
return
pArray
;
}
static
int32_t
mndCompareDnodeId
(
int32_t
*
dnode1Id
,
int32_t
*
dnode2Id
)
{
return
*
dnode1Id
>=
*
dnode2Id
?
1
:
0
;
}
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
=
(
float
)
pDnode1
->
numOfVnodes
/
pDnode1
->
numOfSupportVnodes
;
float
d2Score
=
(
float
)
pDnode2
->
numOfVnodes
/
pDnode2
->
numOfSupportVnodes
;
float
d1Score
=
mndGetDnodeScore
(
pDnode1
,
0
,
0
.
9
)
;
float
d2Score
=
mndGetDnodeScore
(
pDnode2
,
0
,
0
.
9
)
;
return
d1Score
>=
d2Score
?
1
:
0
;
}
...
...
@@ -494,7 +506,12 @@ static int32_t mndGetAvailableDnode(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgroup
int32_t
allocedVnodes
=
0
;
void
*
pIter
=
NULL
;
mDebug
(
"start to sort %d dnodes"
,
(
int32_t
)
taosArrayGetSize
(
pArray
));
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
,
0
,
0
.
9
));
}
int32_t
size
=
taosArrayGetSize
(
pArray
);
if
(
size
<
pVgroup
->
replica
)
{
...
...
@@ -875,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
];
...
...
@@ -935,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
;
...
...
@@ -1970,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
)
{
...
...
tests/script/tsim/dnode/balance1.sim
浏览文件 @
6e9b5d1b
...
...
@@ -74,10 +74,10 @@ sql insert into d2.t2 values(now+5s, 21)
sql select * from information_schema.ins_dnodes
print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data(2)[2]
if $data(1)[2] !=
0
then
if $data(1)[2] !=
1
then
return -1
endi
if $data(2)[2] !=
2
then
if $data(2)[2] !=
1
then
return -1
endi
...
...
tests/script/tsim/dnode/balance2.sim
浏览文件 @
6e9b5d1b
...
...
@@ -161,13 +161,13 @@ print dnode1 openVnodes $data(1)[2]
print dnode3 openVnodes $data(3)[2]
print dnode4 openVnodes $data(4)[2]
print dnode5 openVnodes $data(5)[2]
if $data(1)[2] !=
2
then
if $data(1)[2] !=
3
then
return -1
endi
if $data(3)[2] != 3 then
return -1
endi
if $data(4)[2] !=
4
then
if $data(4)[2] !=
3
then
return -1
endi
if $data(5)[2] != 3 then
...
...
tests/script/tsim/dnode/balance3.sim
浏览文件 @
6e9b5d1b
...
...
@@ -127,10 +127,10 @@ print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data(2)[2]
print dnode3 openVnodes $data(3)[2]
print dnode4 openVnodes $data(4)[2]
if $data(1)[2] !=
0
then
if $data(1)[2] !=
1
then
return -1
endi
if $data(2)[2] !=
2
then
if $data(2)[2] !=
1
then
return -1
endi
if $data(3)[2] != 2 then
...
...
@@ -228,10 +228,10 @@ print dnode1 openVnodes $data(1)[2]
print dnode3 openVnodes $data(3)[2]
print dnode4 openVnodes $data(4)[2]
print dnode5 openVnodes $data(5)[2]
if $data(1)[2] !=
1
then
if $data(1)[2] !=
2
then
return -1
endi
if $data(3)[2] !=
3
then
if $data(3)[2] !=
2
then
return -1
endi
if $data(4)[2] != 3 then
...
...
tests/script/tsim/dnode/balancex.sim
浏览文件 @
6e9b5d1b
...
...
@@ -142,10 +142,10 @@ print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data(2)[2]
print dnode2 openVnodes $data(3)[2]
print dnode2 openVnodes $data(4)[2]
if $data(1)[2] !=
0
then
if $data(1)[2] !=
1
then
return -1
endi
if $data(2)[2] !=
2
then
if $data(2)[2] !=
1
then
return -1
endi
if $data(3)[2] != 2 then
...
...
tests/script/tsim/dnode/vnode_clean.sim
浏览文件 @
6e9b5d1b
...
...
@@ -71,10 +71,10 @@ sql insert into d2.t2 values(now+5s, 21)
sql select * from information_schema.ins_dnodes
print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data(2)[2]
if $data(1)[2] !=
0
then
if $data(1)[2] !=
1
then
return -1
endi
if $data(2)[2] !=
2
then
if $data(2)[2] !=
1
then
return -1
endi
...
...
@@ -181,10 +181,10 @@ sql select * from information_schema.ins_dnodes
print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data(3)[2]
print dnode2 openVnodes $data(4)[2]
if $data(1)[2] !=
0
then
if $data(1)[2] !=
1
then
return -1
endi
if $data(3)[2] !=
2
then
if $data(3)[2] !=
1
then
return -1
endi
if $data(4)[2] != 1 then
...
...
@@ -204,10 +204,10 @@ sql select * from information_schema.ins_dnodes
print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data(3)[2]
print dnode2 openVnodes $data(4)[2]
if $data(1)[2] !=
0
then
if $data(1)[2] !=
1
then
return -1
endi
if $data(3)[2] !=
2
then
if $data(3)[2] !=
1
then
return -1
endi
if $data(4)[2] != 2 then
...
...
@@ -220,13 +220,13 @@ sql select * from information_schema.ins_dnodes
print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data(3)[2]
print dnode2 openVnodes $data(4)[2]
if $data(1)[2] !=
1
then
if $data(1)[2] !=
2
then
return -1
endi
if $data(3)[2] != null then
return -1
endi
if $data(4)[2] !=
3
then
if $data(4)[2] !=
2
then
return -1
endi
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录