Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
a84e2aa4
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
a84e2aa4
编写于
12月 22, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
12月 22, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4657 from taosdata/feature/wal
TD-2270
上级
490da52c
cb32f467
变更
13
显示空白变更内容
内联
并排
Showing
13 changed file
with
108 addition
and
149 deletion
+108
-149
src/balance/src/bnMain.c
src/balance/src/bnMain.c
+47
-103
src/balance/src/bnScore.c
src/balance/src/bnScore.c
+1
-1
src/dnode/src/dnodeVMgmt.c
src/dnode/src/dnodeVMgmt.c
+2
-1
src/inc/taosmsg.h
src/inc/taosmsg.h
+6
-4
src/mnode/inc/mnodeDef.h
src/mnode/inc/mnodeDef.h
+3
-2
src/mnode/inc/mnodeDnode.h
src/mnode/inc/mnodeDnode.h
+3
-3
src/mnode/src/mnodeDb.c
src/mnode/src/mnodeDb.c
+1
-1
src/mnode/src/mnodeDnode.c
src/mnode/src/mnodeDnode.c
+17
-21
src/mnode/src/mnodeVgroup.c
src/mnode/src/mnodeVgroup.c
+9
-5
src/vnode/inc/vnodeInt.h
src/vnode/inc/vnodeInt.h
+2
-1
src/vnode/src/vnodeCfg.c
src/vnode/src/vnodeCfg.c
+14
-5
src/vnode/src/vnodeMain.c
src/vnode/src/vnodeMain.c
+1
-1
src/vnode/src/vnodeMgmt.c
src/vnode/src/vnodeMgmt.c
+2
-1
未找到文件。
src/balance/src/bnMain.c
浏览文件 @
a84e2aa4
...
...
@@ -44,7 +44,7 @@ static void bnUnLock() {
static
bool
bnCheckFree
(
SDnodeObj
*
pDnode
)
{
if
(
pDnode
->
status
==
TAOS_DN_STATUS_DROPPING
||
pDnode
->
status
==
TAOS_DN_STATUS_OFFLINE
)
{
mError
(
"dnode:%d, status:%s not available"
,
pDnode
->
dnodeId
,
mnodeGetDnodeStatusStr
(
pDnode
->
status
)
);
mError
(
"dnode:%d, status:%s not available"
,
pDnode
->
dnodeId
,
dnodeStatus
[
pDnode
->
status
]
);
return
false
;
}
...
...
@@ -92,13 +92,12 @@ static void bnDiscardVnode(SVgObj *pVgroup, SVnodeGid *pVnodeGid) {
}
static
void
bnSwapVnodeGid
(
SVnodeGid
*
pVnodeGid1
,
SVnodeGid
*
pVnodeGid2
)
{
//
SVnodeGid tmp = *pVnodeGid1;
//
*pVnodeGid1 = *pVnodeGid2;
//
*pVnodeGid2 = tmp;
SVnodeGid
tmp
=
*
pVnodeGid1
;
*
pVnodeGid1
=
*
pVnodeGid2
;
*
pVnodeGid2
=
tmp
;
}
int32_t
bnAllocVnodes
(
SVgObj
*
pVgroup
)
{
static
int32_t
randIndex
=
0
;
int32_t
dnode
=
0
;
int32_t
vnodes
=
0
;
...
...
@@ -120,8 +119,7 @@ int32_t bnAllocVnodes(SVgObj *pVgroup) {
break
;
}
else
{
mDebug
(
"dnode:%d, is not selected, status:%s vnodes:%d disk:%fGB role:%d"
,
pDnode
->
dnodeId
,
mnodeGetDnodeStatusStr
(
pDnode
->
status
),
pDnode
->
openVnodes
,
pDnode
->
diskAvailable
,
pDnode
->
alternativeRole
);
dnodeStatus
[
pDnode
->
status
],
pDnode
->
openVnodes
,
pDnode
->
diskAvailable
,
pDnode
->
alternativeRole
);
}
}
}
...
...
@@ -137,7 +135,7 @@ int32_t bnAllocVnodes(SVgObj *pVgroup) {
while
(
1
)
{
pIter
=
mnodeGetNextDnode
(
pIter
,
&
pDnode
);
if
(
pDnode
==
NULL
)
break
;
mDebug
(
"dnode:%d, status:%s vnodes:%d disk:%fGB role:%d"
,
pDnode
->
dnodeId
,
mnodeGetDnodeStatusStr
(
pDnode
->
status
)
,
mDebug
(
"dnode:%d, status:%s vnodes:%d disk:%fGB role:%d"
,
pDnode
->
dnodeId
,
dnodeStatus
[
pDnode
->
status
]
,
pDnode
->
openVnodes
,
pDnode
->
diskAvailable
,
pDnode
->
alternativeRole
);
mnodeDecDnodeRef
(
pDnode
);
}
...
...
@@ -149,36 +147,6 @@ int32_t bnAllocVnodes(SVgObj *pVgroup) {
}
}
/*
* make the choice more random.
* replica 1: no choice
* replica 2: there are 2 combinations
* replica 3 or larger: there are 6 combinations
*/
if
(
pVgroup
->
numOfVnodes
==
1
)
{
}
else
if
(
pVgroup
->
numOfVnodes
==
2
)
{
if
(
randIndex
++
%
2
==
0
)
{
bnSwapVnodeGid
(
pVgroup
->
vnodeGid
,
pVgroup
->
vnodeGid
+
1
);
}
}
else
{
int32_t
randVal
=
randIndex
++
%
6
;
if
(
randVal
==
1
)
{
// 1, 0, 2
bnSwapVnodeGid
(
pVgroup
->
vnodeGid
+
0
,
pVgroup
->
vnodeGid
+
1
);
}
else
if
(
randVal
==
2
)
{
// 1, 2, 0
bnSwapVnodeGid
(
pVgroup
->
vnodeGid
+
0
,
pVgroup
->
vnodeGid
+
1
);
bnSwapVnodeGid
(
pVgroup
->
vnodeGid
+
1
,
pVgroup
->
vnodeGid
+
2
);
}
else
if
(
randVal
==
3
)
{
// 2, 1, 0
bnSwapVnodeGid
(
pVgroup
->
vnodeGid
+
0
,
pVgroup
->
vnodeGid
+
2
);
}
else
if
(
randVal
==
4
)
{
// 2, 0, 1
bnSwapVnodeGid
(
pVgroup
->
vnodeGid
+
0
,
pVgroup
->
vnodeGid
+
2
);
bnSwapVnodeGid
(
pVgroup
->
vnodeGid
+
1
,
pVgroup
->
vnodeGid
+
2
);
}
if
(
randVal
==
5
)
{
// 0, 2, 1
bnSwapVnodeGid
(
pVgroup
->
vnodeGid
+
1
,
pVgroup
->
vnodeGid
+
2
);
}
else
{
}
// 0, 1, 2
}
bnReleaseDnodes
();
bnUnLock
();
return
TSDB_CODE_SUCCESS
;
...
...
@@ -214,44 +182,8 @@ static bool bnCheckVgroupReady(SVgObj *pVgroup, SVnodeGid *pRmVnode) {
static
int32_t
bnRemoveVnode
(
SVgObj
*
pVgroup
)
{
if
(
pVgroup
->
numOfVnodes
<=
1
)
return
-
1
;
SVnodeGid
*
pRmVnode
=
NULL
;
SVnodeGid
*
pSelVnode
=
NULL
;
int32_t
maxScore
=
0
;
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
SVnodeGid
*
pVnode
=
&
(
pVgroup
->
vnodeGid
[
i
]);
SDnodeObj
*
pDnode
=
mnodeGetDnode
(
pVnode
->
dnodeId
);
if
(
pDnode
==
NULL
)
{
mError
(
"vgId:%d, dnode:%d not exist, remove it"
,
pVgroup
->
vgId
,
pVnode
->
dnodeId
);
pRmVnode
=
pVnode
;
break
;
}
if
(
pDnode
->
status
==
TAOS_DN_STATUS_DROPPING
)
{
mDebug
(
"vgId:%d, dnode:%d in dropping state"
,
pVgroup
->
vgId
,
pVnode
->
dnodeId
);
pRmVnode
=
pVnode
;
}
else
if
(
pVnode
->
dnodeId
==
pVgroup
->
lbDnodeId
)
{
mDebug
(
"vgId:%d, dnode:%d in updating state"
,
pVgroup
->
vgId
,
pVnode
->
dnodeId
);
pRmVnode
=
pVnode
;
}
else
{
if
(
pSelVnode
==
NULL
)
{
pSelVnode
=
pVnode
;
maxScore
=
pDnode
->
score
;
}
else
{
if
(
maxScore
<
pDnode
->
score
)
{
pSelVnode
=
pVnode
;
maxScore
=
pDnode
->
score
;
}
}
}
mnodeDecDnodeRef
(
pDnode
);
}
if
(
pRmVnode
!=
NULL
)
{
pSelVnode
=
pRmVnode
;
}
SVnodeGid
*
pSelVnode
=
&
pVgroup
->
vnodeGid
[
pVgroup
->
numOfVnodes
-
1
];
mDebug
(
"vgId:%d, vnode in dnode:%d will be dropped"
,
pVgroup
->
vgId
,
pSelVnode
->
dnodeId
);
if
(
!
bnCheckVgroupReady
(
pVgroup
,
pSelVnode
))
{
mDebug
(
"vgId:%d, is not ready"
,
pVgroup
->
vgId
);
...
...
@@ -275,36 +207,42 @@ static bool bnCheckDnodeInVgroup(SDnodeObj *pDnode, SVgObj *pVgroup) {
return
false
;
}
/**
* desc: add vnode to vgroup, find a new one if dest dnode is null
**/
static
int32_t
bnAddVnode
(
SVgObj
*
pVgroup
,
SDnodeObj
*
pSrcDnode
,
SDnodeObj
*
pDestDnode
)
{
if
(
pDestDnode
==
NULL
)
{
static
SDnodeObj
*
bnGetAvailDnode
(
SVgObj
*
pVgroup
)
{
for
(
int32_t
i
=
0
;
i
<
tsBnDnodes
.
size
;
++
i
)
{
SDnodeObj
*
pDnode
=
tsBnDnodes
.
list
[
i
];
if
(
pDnode
==
pSrcDnode
)
continue
;
if
(
bnCheckDnodeInVgroup
(
pDnode
,
pVgroup
))
continue
;
if
(
!
bnCheckFree
(
pDnode
))
continue
;
pDestDnode
=
pDnode
;
mDebug
(
"vgId:%d, add vnode to dnode:%d"
,
pVgroup
->
vgId
,
pDnode
->
dnodeId
);
break
;
}
return
pDnode
;
}
if
(
pDestDnode
==
NULL
)
{
return
NULL
;
}
static
int32_t
bnAddVnode
(
SVgObj
*
pVgroup
,
SDnodeObj
*
pSrcDnode
,
SDnodeObj
*
pDestDnode
)
{
if
(
pDestDnode
==
NULL
||
pSrcDnode
==
pDestDnode
)
{
return
TSDB_CODE_MND_DNODE_NOT_EXIST
;
}
SVnodeGid
*
pVnodeGid
=
pVgroup
->
vnodeGid
+
pVgroup
->
numOfVnodes
;
pVnodeGid
->
dnodeId
=
pDestDnode
->
dnodeId
;
pVnodeGid
->
pDnode
=
pDestDnode
;
pVgroup
->
numOfVnodes
++
;
SVnodeGid
vnodeGids
[
TSDB_MAX_REPLICA
];
memcpy
(
&
vnodeGids
,
&
pVgroup
->
vnodeGid
,
sizeof
(
SVnodeGid
)
*
TSDB_MAX_REPLICA
);
if
(
pSrcDnode
!=
NULL
)
{
int32_t
numOfVnodes
=
pVgroup
->
numOfVnodes
;
vnodeGids
[
numOfVnodes
].
dnodeId
=
pDestDnode
->
dnodeId
;
vnodeGids
[
numOfVnodes
].
pDnode
=
pDestDnode
;
numOfVnodes
++
;
for
(
int32_t
v
=
0
;
v
<
numOfVnodes
;
++
v
)
{
if
(
pSrcDnode
!=
NULL
&&
pSrcDnode
->
dnodeId
==
vnodeGids
[
v
].
dnodeId
)
{
bnSwapVnodeGid
(
&
vnodeGids
[
v
],
&
vnodeGids
[
numOfVnodes
-
1
]);
pVgroup
->
lbDnodeId
=
pSrcDnode
->
dnodeId
;
break
;
}
}
memcpy
(
&
pVgroup
->
vnodeGid
,
&
vnodeGids
,
sizeof
(
SVnodeGid
)
*
TSDB_MAX_REPLICA
);
pVgroup
->
numOfVnodes
=
numOfVnodes
;
atomic_add_fetch_32
(
&
pDestDnode
->
openVnodes
,
1
);
mnodeUpdateVgroup
(
pVgroup
);
...
...
@@ -315,16 +253,16 @@ static int32_t bnAddVnode(SVgObj *pVgroup, SDnodeObj *pSrcDnode, SDnodeObj *pDes
static
bool
bnMonitorBalance
()
{
if
(
tsBnDnodes
.
size
<
2
)
return
false
;
mDebug
(
"monitor dnodes for balance, avail:%d"
,
tsBnDnodes
.
size
);
for
(
int32_t
src
=
tsBnDnodes
.
size
-
1
;
src
>=
0
;
--
src
)
{
SDnodeObj
*
pDnode
=
tsBnDnodes
.
list
[
src
];
mDebug
(
"%d-dnode:%d, state:%s, score:%.1f, numOfCores:%d, openVnodes:%d"
,
tsBnDnodes
.
size
-
src
-
1
,
pDnode
->
dnodeId
,
mnodeGetDnodeStatusStr
(
pDnode
->
status
),
pDnode
->
score
,
pDnode
->
numOfCores
,
pDnode
->
openVnodes
);
mDebug
(
"%d-dnode:%d, state:%s, score:%.1f, cores:%d, vnodes:%d"
,
tsBnDnodes
.
size
-
src
-
1
,
pDnode
->
dnodeId
,
dnodeStatus
[
pDnode
->
status
],
pDnode
->
score
,
pDnode
->
numOfCores
,
pDnode
->
openVnodes
);
}
float
scoresDiff
=
tsBnDnodes
.
list
[
tsBnDnodes
.
size
-
1
]
->
score
-
tsBnDnodes
.
list
[
0
]
->
score
;
if
(
scoresDiff
<
0
.
01
)
{
mDebug
(
"all dnodes:%d is already balanced, score
sDiff:%
f"
,
tsBnDnodes
.
size
,
scoresDiff
);
mDebug
(
"all dnodes:%d is already balanced, score
Diff:%.1
f"
,
tsBnDnodes
.
size
,
scoresDiff
);
return
false
;
}
...
...
@@ -412,7 +350,13 @@ static int32_t bnMonitorVgroups() {
}
else
if
(
vgReplica
<
dbReplica
)
{
mInfo
(
"vgId:%d, replica:%d numOfVnodes:%d, try add one vnode"
,
pVgroup
->
vgId
,
dbReplica
,
vgReplica
);
hasUpdatingVgroup
=
true
;
code
=
bnAddVnode
(
pVgroup
,
NULL
,
NULL
);
SDnodeObj
*
pAvailDnode
=
bnGetAvailDnode
(
pVgroup
);
if
(
pAvailDnode
==
NULL
)
{
code
=
TSDB_CODE_MND_DNODE_NOT_EXIST
;
}
else
{
code
=
bnAddVnode
(
pVgroup
,
NULL
,
pAvailDnode
);
}
}
mnodeDecVgroupRef
(
pVgroup
);
...
...
src/balance/src/bnScore.c
浏览文件 @
a84e2aa4
...
...
@@ -299,7 +299,7 @@ static int32_t bnRetrieveScores(SShowObj *pShow, char *data, int32_t rows, void
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
STR_TO_VARSTR
(
pWrite
,
mnodeGetDnodeStatusStr
(
pDnode
->
status
)
);
STR_TO_VARSTR
(
pWrite
,
dnodeStatus
[
pDnode
->
status
]
);
cols
++
;
numOfRows
++
;
...
...
src/dnode/src/dnodeVMgmt.c
浏览文件 @
a84e2aa4
...
...
@@ -129,7 +129,8 @@ static void *dnodeProcessMgmtQueue(void *wparam) {
static
SCreateVnodeMsg
*
dnodeParseVnodeMsg
(
SRpcMsg
*
rpcMsg
)
{
SCreateVnodeMsg
*
pCreate
=
rpcMsg
->
pCont
;
pCreate
->
cfg
.
vgId
=
htonl
(
pCreate
->
cfg
.
vgId
);
pCreate
->
cfg
.
cfgVersion
=
htonl
(
pCreate
->
cfg
.
cfgVersion
);
pCreate
->
cfg
.
dbCfgVersion
=
htonl
(
pCreate
->
cfg
.
dbCfgVersion
);
pCreate
->
cfg
.
vgCfgVersion
=
htonl
(
pCreate
->
cfg
.
vgCfgVersion
);
pCreate
->
cfg
.
maxTables
=
htonl
(
pCreate
->
cfg
.
maxTables
);
pCreate
->
cfg
.
cacheBlockSize
=
htonl
(
pCreate
->
cfg
.
cacheBlockSize
);
pCreate
->
cfg
.
totalBlocks
=
htonl
(
pCreate
->
cfg
.
totalBlocks
);
...
...
src/inc/taosmsg.h
浏览文件 @
a84e2aa4
...
...
@@ -518,14 +518,15 @@ typedef struct SRetrieveTableRsp {
typedef
struct
{
int32_t
vgId
;
int32_t
c
fgVersion
;
int32_t
dbC
fgVersion
;
int64_t
totalStorage
;
int64_t
compStorage
;
int64_t
pointsWritten
;
uint8_t
status
;
uint8_t
role
;
uint8_t
replica
;
uint8_t
reserved
[
5
];
uint8_t
reserved
;
int32_t
vgCfgVersion
;
}
SVnodeLoad
;
typedef
struct
{
...
...
@@ -641,7 +642,7 @@ typedef struct {
typedef
struct
{
uint32_t
vgId
;
int32_t
c
fgVersion
;
int32_t
dbC
fgVersion
;
int32_t
maxTables
;
int32_t
cacheBlockSize
;
int32_t
totalBlocks
;
...
...
@@ -660,7 +661,8 @@ typedef struct {
int8_t
wals
;
int8_t
quorum
;
int8_t
update
;
int8_t
reserved
[
15
];
int8_t
reserved
[
11
];
int32_t
vgCfgVersion
;
}
SVnodeCfg
;
typedef
struct
{
...
...
src/mnode/inc/mnodeDef.h
浏览文件 @
a84e2aa4
...
...
@@ -144,7 +144,8 @@ typedef struct SVgObj {
int8_t
status
;
int8_t
reserved0
[
4
];
SVnodeGid
vnodeGid
[
TSDB_MAX_REPLICA
];
int8_t
reserved1
[
12
];
int32_t
vgCfgVersion
;
int8_t
reserved1
[
8
];
int8_t
updateEnd
[
4
];
int32_t
refCount
;
int32_t
numOfTables
;
...
...
@@ -181,7 +182,7 @@ typedef struct SDbObj {
int8_t
reserved0
[
4
];
char
acct
[
TSDB_USER_LEN
];
int64_t
createdTime
;
int32_t
c
fgVersion
;
int32_t
dbC
fgVersion
;
SDbCfg
cfg
;
int8_t
status
;
int8_t
reserved1
[
11
];
...
...
src/mnode/inc/mnodeDnode.h
浏览文件 @
a84e2aa4
...
...
@@ -55,12 +55,12 @@ typedef enum EDnodeOfflineReason {
TAOS_DN_OFF_OTHERS
}
EDnodeOfflineReason
;
extern
char
*
dnodeStatus
[];
extern
char
*
dnodeRoles
[];
int32_t
mnodeInitDnodes
();
void
mnodeCleanupDnodes
();
char
*
mnodeGetDnodeStatusStr
(
int32_t
dnodeStatus
);
void
mgmtMonitorDnodeModule
();
int32_t
mnodeGetDnodesNum
();
int32_t
mnodeGetOnlinDnodesCpuCoreNum
();
int32_t
mnodeGetOnlineDnodesNum
();
...
...
src/mnode/src/mnodeDb.c
浏览文件 @
a84e2aa4
...
...
@@ -1015,7 +1015,7 @@ static int32_t mnodeAlterDb(SDbObj *pDb, SAlterDbMsg *pAlter, void *pMsg) {
if
(
memcmp
(
&
newCfg
,
&
pDb
->
cfg
,
sizeof
(
SDbCfg
))
!=
0
)
{
pDb
->
cfg
=
newCfg
;
pDb
->
c
fgVersion
++
;
pDb
->
dbC
fgVersion
++
;
SSdbRow
row
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsDbSdb
,
...
...
src/mnode/src/mnodeDnode.c
浏览文件 @
a84e2aa4
...
...
@@ -63,7 +63,6 @@ static int32_t mnodeGetVnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC
static
int32_t
mnodeRetrieveVnodes
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mnodeGetDnodeMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mnodeRetrieveDnodes
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
char
*
mnodeGetDnodeAlternativeRoleStr
(
int32_t
alternativeRole
);
static
void
mnodeUpdateDnodeEps
();
static
char
*
offlineReason
[]
=
{
...
...
@@ -557,7 +556,8 @@ static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) {
for
(
int32_t
j
=
0
;
j
<
openVnodes
;
++
j
)
{
SVnodeLoad
*
pVload
=
&
pStatus
->
load
[
j
];
pVload
->
vgId
=
htonl
(
pVload
->
vgId
);
pVload
->
cfgVersion
=
htonl
(
pVload
->
cfgVersion
);
pVload
->
dbCfgVersion
=
htonl
(
pVload
->
dbCfgVersion
);
pVload
->
vgCfgVersion
=
htonl
(
pVload
->
vgCfgVersion
);
SVgObj
*
pVgroup
=
mnodeGetVgroup
(
pVload
->
vgId
);
if
(
pVgroup
==
NULL
)
{
...
...
@@ -833,12 +833,12 @@ static int32_t mnodeRetrieveDnodes(SShowObj *pShow, char *data, int32_t rows, vo
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
char
*
status
=
mnodeGetDnodeStatusStr
(
pDnode
->
status
)
;
char
*
status
=
dnodeStatus
[
pDnode
->
status
]
;
STR_TO_VARSTR
(
pWrite
,
status
);
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
char
*
role
=
mnodeGetDnodeAlternativeRoleStr
(
pDnode
->
alternativeRole
)
;
char
*
role
=
dnodeRoles
[
pDnode
->
alternativeRole
]
;
STR_TO_VARSTR
(
pWrite
,
role
);
cols
++
;
...
...
@@ -1154,21 +1154,17 @@ static int32_t mnodeRetrieveVnodes(SShowObj *pShow, char *data, int32_t rows, vo
return
numOfRows
;
}
char
*
mnodeGetDnodeStatusStr
(
int32_t
dnodeStatus
)
{
switch
(
dnodeStatus
)
{
case
TAOS_DN_STATUS_OFFLINE
:
return
"offline"
;
case
TAOS_DN_STATUS_DROPPING
:
return
"dropping"
;
case
TAOS_DN_STATUS_BALANCING
:
return
"balancing"
;
case
TAOS_DN_STATUS_READY
:
return
"ready"
;
default:
return
"undefined"
;
}
}
char
*
dnodeStatus
[]
=
{
"offline"
,
"dropping"
,
"balancing"
,
"ready"
,
"undefined"
};
static
char
*
mnodeGetDnodeAlternativeRoleStr
(
int32_t
alternativeRole
)
{
switch
(
alternativeRole
)
{
case
TAOS_DN_ALTERNATIVE_ROLE_ANY
:
return
"any"
;
case
TAOS_DN_ALTERNATIVE_ROLE_MNODE
:
return
"mnode"
;
case
TAOS_DN_ALTERNATIVE_ROLE_VNODE
:
return
"vnode"
;
default:
return
"any"
;
}
}
char
*
dnodeRoles
[]
=
{
"any"
,
"mnode"
,
"vnode"
,
"any"
};
src/mnode/src/mnodeVgroup.c
浏览文件 @
a84e2aa4
...
...
@@ -256,6 +256,8 @@ SVgObj *mnodeGetVgroup(int32_t vgId) {
}
void
mnodeUpdateVgroup
(
SVgObj
*
pVgroup
)
{
pVgroup
->
vgCfgVersion
++
;
SSdbRow
row
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsVgroupSdb
,
...
...
@@ -339,10 +341,11 @@ void mnodeUpdateVgroupStatus(SVgObj *pVgroup, SDnodeObj *pDnode, SVnodeLoad *pVl
pVgroup
->
pointsWritten
=
htobe64
(
pVload
->
pointsWritten
);
}
if
(
pVload
->
cfgVersion
!=
pVgroup
->
pDb
->
cfgVersion
||
pVload
->
replica
!=
pVgroup
->
numOfVnodes
)
{
mError
(
"dnode:%d, vgId:%d, vnode cfgVersion:%d repica:%d not match with mnode cfgVersion:%d replica:%d"
,
pDnode
->
dnodeId
,
pVload
->
vgId
,
pVload
->
cfgVersion
,
pVload
->
replica
,
pVgroup
->
pDb
->
cfgVersion
,
pVgroup
->
numOfVnodes
);
if
(
pVload
->
dbCfgVersion
!=
pVgroup
->
pDb
->
dbCfgVersion
||
pVload
->
replica
!=
pVgroup
->
numOfVnodes
||
pVload
->
vgCfgVersion
!=
pVgroup
->
vgCfgVersion
)
{
mError
(
"dnode:%d, vgId:%d, vnode cfgVersion:%d:%d repica:%d not match with mnode cfgVersion:%d:%d replica:%d"
,
pDnode
->
dnodeId
,
pVload
->
vgId
,
pVload
->
dbCfgVersion
,
pVload
->
vgCfgVersion
,
pVload
->
replica
,
pVgroup
->
pDb
->
dbCfgVersion
,
pVgroup
->
vgCfgVersion
,
pVgroup
->
numOfVnodes
);
mnodeSendAlterVgroupMsg
(
pVgroup
);
}
}
...
...
@@ -840,7 +843,8 @@ static SCreateVnodeMsg *mnodeBuildVnodeMsg(SVgObj *pVgroup) {
SVnodeCfg
*
pCfg
=
&
pVnode
->
cfg
;
pCfg
->
vgId
=
htonl
(
pVgroup
->
vgId
);
pCfg
->
cfgVersion
=
htonl
(
pDb
->
cfgVersion
);
pCfg
->
dbCfgVersion
=
htonl
(
pDb
->
dbCfgVersion
);
pCfg
->
vgCfgVersion
=
htonl
(
pVgroup
->
vgCfgVersion
);
pCfg
->
cacheBlockSize
=
htonl
(
pDb
->
cfg
.
cacheBlockSize
);
pCfg
->
totalBlocks
=
htonl
(
pDb
->
cfg
.
totalBlocks
);
pCfg
->
maxTables
=
htonl
(
maxTables
+
1
);
...
...
src/vnode/inc/vnodeInt.h
浏览文件 @
a84e2aa4
...
...
@@ -56,7 +56,8 @@ typedef struct {
int64_t
sync
;
void
*
events
;
void
*
cq
;
// continuous query
int32_t
cfgVersion
;
int32_t
dbCfgVersion
;
int32_t
vgCfgVersion
;
STsdbCfg
tsdbCfg
;
SSyncCfg
syncCfg
;
SWalCfg
walCfg
;
...
...
src/vnode/src/vnodeCfg.c
浏览文件 @
a84e2aa4
...
...
@@ -22,7 +22,8 @@
static
void
vnodeLoadCfg
(
SVnodeObj
*
pVnode
,
SCreateVnodeMsg
*
vnodeMsg
)
{
tstrncpy
(
pVnode
->
db
,
vnodeMsg
->
db
,
sizeof
(
pVnode
->
db
));
pVnode
->
cfgVersion
=
vnodeMsg
->
cfg
.
cfgVersion
;
pVnode
->
dbCfgVersion
=
vnodeMsg
->
cfg
.
dbCfgVersion
;
pVnode
->
vgCfgVersion
=
vnodeMsg
->
cfg
.
vgCfgVersion
;
pVnode
->
tsdbCfg
.
cacheBlockSize
=
vnodeMsg
->
cfg
.
cacheBlockSize
;
pVnode
->
tsdbCfg
.
totalBlocks
=
vnodeMsg
->
cfg
.
totalBlocks
;
pVnode
->
tsdbCfg
.
daysPerFile
=
vnodeMsg
->
cfg
.
daysPerFile
;
...
...
@@ -95,12 +96,19 @@ int32_t vnodeReadCfg(SVnodeObj *pVnode) {
}
tstrncpy
(
vnodeMsg
.
db
,
db
->
valuestring
,
sizeof
(
vnodeMsg
.
db
));
cJSON
*
c
fgVersion
=
cJSON_GetObjectItem
(
root
,
"cfgVersion"
);
if
(
!
cfgVersion
||
c
fgVersion
->
type
!=
cJSON_Number
)
{
cJSON
*
dbC
fgVersion
=
cJSON_GetObjectItem
(
root
,
"cfgVersion"
);
if
(
!
dbCfgVersion
||
dbC
fgVersion
->
type
!=
cJSON_Number
)
{
vError
(
"vgId:%d, failed to read %s, cfgVersion not found"
,
pVnode
->
vgId
,
file
);
goto
PARSE_VCFG_ERROR
;
}
vnodeMsg
.
cfg
.
cfgVersion
=
cfgVersion
->
valueint
;
vnodeMsg
.
cfg
.
dbCfgVersion
=
dbCfgVersion
->
valueint
;
cJSON
*
vgCfgVersion
=
cJSON_GetObjectItem
(
root
,
"vgCfgVersion"
);
if
(
!
vgCfgVersion
||
vgCfgVersion
->
type
!=
cJSON_Number
)
{
vError
(
"vgId:%d, failed to read %s, vgCfgVersion not found"
,
pVnode
->
vgId
,
file
);
goto
PARSE_VCFG_ERROR
;
}
vnodeMsg
.
cfg
.
vgCfgVersion
=
vgCfgVersion
->
valueint
;
cJSON
*
cacheBlockSize
=
cJSON_GetObjectItem
(
root
,
"cacheBlockSize"
);
if
(
!
cacheBlockSize
||
cacheBlockSize
->
type
!=
cJSON_Number
)
{
...
...
@@ -278,7 +286,8 @@ int32_t vnodeWriteCfg(SCreateVnodeMsg *pMsg) {
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"{
\n
"
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
db
\"
:
\"
%s
\"
,
\n
"
,
pMsg
->
db
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
cfgVersion
\"
: %d,
\n
"
,
pMsg
->
cfg
.
cfgVersion
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
cfgVersion
\"
: %d,
\n
"
,
pMsg
->
cfg
.
dbCfgVersion
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
vgCfgVersion
\"
: %d,
\n
"
,
pMsg
->
cfg
.
vgCfgVersion
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
cacheBlockSize
\"
: %d,
\n
"
,
pMsg
->
cfg
.
cacheBlockSize
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
totalBlocks
\"
: %d,
\n
"
,
pMsg
->
cfg
.
totalBlocks
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
daysPerFile
\"
: %d,
\n
"
,
pMsg
->
cfg
.
daysPerFile
);
...
...
src/vnode/src/vnodeMain.c
浏览文件 @
a84e2aa4
...
...
@@ -154,7 +154,7 @@ int32_t vnodeAlter(void *vparam, SCreateVnodeMsg *pVnodeCfg) {
SVnodeObj
*
pVnode
=
vparam
;
// vnode in non-ready state and still needs to return success instead of TSDB_CODE_VND_INVALID_STATUS
//
c
fgVersion can be corrected by status msg
//
dbC
fgVersion can be corrected by status msg
if
(
!
vnodeSetUpdatingStatus
(
pVnode
))
{
vDebug
(
"vgId:%d, vnode is not ready, do alter operation later"
,
pVnode
->
vgId
);
return
TSDB_CODE_SUCCESS
;
...
...
src/vnode/src/vnodeMgmt.c
浏览文件 @
a84e2aa4
...
...
@@ -134,7 +134,8 @@ static void vnodeBuildVloadMsg(SVnodeObj *pVnode, SStatusMsg *pStatus) {
SVnodeLoad
*
pLoad
=
&
pStatus
->
load
[
pStatus
->
openVnodes
++
];
pLoad
->
vgId
=
htonl
(
pVnode
->
vgId
);
pLoad
->
cfgVersion
=
htonl
(
pVnode
->
cfgVersion
);
pLoad
->
dbCfgVersion
=
htonl
(
pVnode
->
dbCfgVersion
);
pLoad
->
vgCfgVersion
=
htonl
(
pVnode
->
vgCfgVersion
);
pLoad
->
totalStorage
=
htobe64
(
totalStorage
);
pLoad
->
compStorage
=
htobe64
(
compStorage
);
pLoad
->
pointsWritten
=
htobe64
(
pointsWritten
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录