Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
acacf74b
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看板
提交
acacf74b
编写于
12月 20, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
minor changes
上级
55f2efc6
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
51 addition
and
47 deletion
+51
-47
include/common/taosmsg.h
include/common/taosmsg.h
+1
-1
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+3
-4
source/dnode/mnode/impl/src/mndDnode.c
source/dnode/mnode/impl/src/mndDnode.c
+8
-24
source/dnode/mnode/impl/src/mndVgroup.c
source/dnode/mnode/impl/src/mndVgroup.c
+36
-18
source/dnode/mnode/impl/src/mnode.c
source/dnode/mnode/impl/src/mnode.c
+3
-0
未找到文件。
include/common/taosmsg.h
浏览文件 @
acacf74b
...
...
@@ -704,7 +704,7 @@ typedef struct {
SVnodeLoad
data
[];
}
SVnodeLoads
;
typedef
struct
SStatusMsg
{
typedef
struct
{
int32_t
sver
;
int32_t
dnodeId
;
int32_t
clusterId
;
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
acacf74b
...
...
@@ -16,13 +16,12 @@
#define _DEFAULT_SOURCE
#include "mndDb.h"
#include "mndDnode.h"
#include "mndMnode.h"
#include "mndShow.h"
#include "mndTrans.h"
#include "mndUser.h"
#include "mndVgroup.h"
#define TSDB_DB_VER_NUM 1
#define TSDB_DB_VER_NUM
BER
1
#define TSDB_DB_RESERVE_SIZE 64
static
SSdbRaw
*
mndDbActionEncode
(
SDbObj
*
pDb
);
...
...
@@ -66,7 +65,7 @@ int32_t mndInitDb(SMnode *pMnode) {
void
mndCleanupDb
(
SMnode
*
pMnode
)
{}
static
SSdbRaw
*
mndDbActionEncode
(
SDbObj
*
pDb
)
{
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_DB
,
TSDB_DB_VER_NUM
,
sizeof
(
SDbObj
)
+
TSDB_DB_RESERVE_SIZE
);
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_DB
,
TSDB_DB_VER_NUM
BER
,
sizeof
(
SDbObj
)
+
TSDB_DB_RESERVE_SIZE
);
if
(
pRaw
==
NULL
)
return
NULL
;
int32_t
dataPos
=
0
;
...
...
@@ -106,7 +105,7 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) {
int8_t
sver
=
0
;
if
(
sdbGetRawSoftVer
(
pRaw
,
&
sver
)
!=
0
)
return
NULL
;
if
(
sver
!=
TSDB_DB_VER_NUM
)
{
if
(
sver
!=
TSDB_DB_VER_NUM
BER
)
{
mError
(
"failed to decode db since %s"
,
terrstr
());
terrno
=
TSDB_CODE_SDB_INVALID_DATA_VER
;
return
NULL
;
...
...
source/dnode/mnode/impl/src/mndDnode.c
浏览文件 @
acacf74b
...
...
@@ -18,10 +18,10 @@
#include "mndMnode.h"
#include "mndShow.h"
#include "mndTrans.h"
#include "ttime.h"
#include "tep.h"
#include "ttime.h"
#define TSDB_DNODE_VER 1
#define TSDB_DNODE_VER
_NUMBER
1
#define TSDB_DNODE_RESERVE_SIZE 64
#define TSDB_CONFIG_OPTION_LEN 16
#define TSDB_CONIIG_VALUE_LEN 48
...
...
@@ -101,14 +101,14 @@ static int32_t mndCreateDefaultDnode(SMnode *pMnode) {
SSdbRaw
*
pRaw
=
mndDnodeActionEncode
(
&
dnodeObj
);
if
(
pRaw
==
NULL
)
return
-
1
;
sdbSetRawStatus
(
pRaw
,
SDB_STATUS_READY
)
;
if
(
sdbSetRawStatus
(
pRaw
,
SDB_STATUS_READY
)
!=
0
)
return
-
1
;
mDebug
(
"dnode:%d, will be created while deploy sdb"
,
dnodeObj
.
id
);
return
sdbWrite
(
pMnode
->
pSdb
,
pRaw
);
}
static
SSdbRaw
*
mndDnodeActionEncode
(
SDnodeObj
*
pDnode
)
{
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_DNODE
,
TSDB_DNODE_VER
,
sizeof
(
SDnodeObj
)
+
TSDB_DNODE_RESERVE_SIZE
);
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_DNODE
,
TSDB_DNODE_VER
_NUMBER
,
sizeof
(
SDnodeObj
)
+
TSDB_DNODE_RESERVE_SIZE
);
if
(
pRaw
==
NULL
)
return
NULL
;
int32_t
dataPos
=
0
;
...
...
@@ -127,7 +127,7 @@ static SSdbRow *mndDnodeActionDecode(SSdbRaw *pRaw) {
int8_t
sver
=
0
;
if
(
sdbGetRawSoftVer
(
pRaw
,
&
sver
)
!=
0
)
return
NULL
;
if
(
sver
!=
TSDB_DNODE_VER
)
{
if
(
sver
!=
TSDB_DNODE_VER
_NUMBER
)
{
terrno
=
TSDB_CODE_SDB_INVALID_DATA_VER
;
mError
(
"failed to decode dnode since %s"
,
terrstr
());
return
NULL
;
...
...
@@ -150,21 +150,8 @@ static SSdbRow *mndDnodeActionDecode(SSdbRaw *pRaw) {
static
int32_t
mndDnodeActionInsert
(
SSdb
*
pSdb
,
SDnodeObj
*
pDnode
)
{
mTrace
(
"dnode:%d, perform insert action"
,
pDnode
->
id
);
pDnode
->
rebootTime
=
0
;
pDnode
->
lastAccessTime
=
0
;
pDnode
->
accessTimes
=
0
;
pDnode
->
numOfMnodes
=
0
;
pDnode
->
numOfVnodes
=
0
;
pDnode
->
numOfQnodes
=
0
;
pDnode
->
numOfSupportMnodes
=
0
;
pDnode
->
numOfSupportVnodes
=
0
;
pDnode
->
numOfSupportQnodes
=
0
;
pDnode
->
numOfCores
=
0
;
pDnode
->
status
=
DND_STATUS_OFFLINE
;
pDnode
->
offlineReason
=
DND_REASON_STATUS_NOT_RECEIVED
;
snprintf
(
pDnode
->
ep
,
TSDB_EP_LEN
,
"%s:%u"
,
pDnode
->
fqdn
,
pDnode
->
port
);
return
0
;
}
...
...
@@ -225,7 +212,7 @@ int32_t mndGetDnodeSize(SMnode *pMnode) {
bool
mndIsDnodeInReadyStatus
(
SMnode
*
pMnode
,
SDnodeObj
*
pDnode
)
{
int64_t
ms
=
taosGetTimestampMs
();
int64_t
interval
=
ABS
(
pDnode
->
lastAccessTime
-
ms
);
if
(
interval
>
3
0
00
*
pMnode
->
cfg
.
statusInterval
)
{
if
(
interval
>
3
5
00
*
pMnode
->
cfg
.
statusInterval
)
{
return
false
;
}
return
true
;
...
...
@@ -267,12 +254,9 @@ static int32_t mndCheckClusterCfgPara(SMnode *pMnode, const SClusterCfg *pCfg) {
return
DND_REASON_STATUS_INTERVAL_NOT_MATCH
;
}
int64_t
checkTime
=
0
;
char
timestr
[
32
]
=
"1970-01-01 00:00:00.00"
;
(
void
)
taosParseTime
(
timestr
,
&
checkTime
,
(
int32_t
)
strlen
(
timestr
),
TSDB_TIME_PRECISION_MILLI
,
0
);
if
((
0
!=
strcasecmp
(
pCfg
->
timezone
,
pMnode
->
cfg
.
timezone
))
&&
(
checkTime
!=
pCfg
->
checkTime
))
{
if
((
0
!=
strcasecmp
(
pCfg
->
timezone
,
pMnode
->
cfg
.
timezone
))
&&
(
pMnode
->
checkTime
!=
pCfg
->
checkTime
))
{
mError
(
"timezone [%s - %s] [%"
PRId64
" - %"
PRId64
"] cfg inconsistent"
,
pCfg
->
timezone
,
pMnode
->
cfg
.
timezone
,
pCfg
->
checkTime
,
checkTime
);
pCfg
->
checkTime
,
pMnode
->
checkTime
);
return
DND_REASON_TIME_ZONE_NOT_MATCH
;
}
...
...
source/dnode/mnode/impl/src/mndVgroup.c
浏览文件 @
acacf74b
...
...
@@ -21,7 +21,7 @@
#include "mndShow.h"
#include "mndTrans.h"
#define TSDB_VGROUP_VER_NUM 1
#define TSDB_VGROUP_VER_NUM
BER
1
#define TSDB_VGROUP_RESERVE_SIZE 64
static
SSdbRow
*
mndVgroupActionDecode
(
SSdbRaw
*
pRaw
);
...
...
@@ -70,7 +70,7 @@ int32_t mndInitVgroup(SMnode *pMnode) {
void
mndCleanupVgroup
(
SMnode
*
pMnode
)
{}
SSdbRaw
*
mndVgroupActionEncode
(
SVgObj
*
pVgroup
)
{
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_VGROUP
,
TSDB_VGROUP_VER_NUM
,
sizeof
(
SVgObj
)
+
TSDB_VGROUP_RESERVE_SIZE
);
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_VGROUP
,
TSDB_VGROUP_VER_NUM
BER
,
sizeof
(
SVgObj
)
+
TSDB_VGROUP_RESERVE_SIZE
);
if
(
pRaw
==
NULL
)
return
NULL
;
int32_t
dataPos
=
0
;
...
...
@@ -98,7 +98,7 @@ SSdbRow *mndVgroupActionDecode(SSdbRaw *pRaw) {
int8_t
sver
=
0
;
if
(
sdbGetRawSoftVer
(
pRaw
,
&
sver
)
!=
0
)
return
NULL
;
if
(
sver
!=
TSDB_VGROUP_VER_NUM
)
{
if
(
sver
!=
TSDB_VGROUP_VER_NUM
BER
)
{
mError
(
"failed to decode vgroup since %s"
,
terrstr
());
terrno
=
TSDB_CODE_SDB_INVALID_DATA_VER
;
return
NULL
;
...
...
@@ -142,14 +142,20 @@ static int32_t mndVgroupActionUpdate(SSdb *pSdb, SVgObj *pOldVgroup, SVgObj *pNe
mTrace
(
"vgId:%d, perform update action"
,
pOldVgroup
->
vgId
);
pOldVgroup
->
updateTime
=
pNewVgroup
->
updateTime
;
pOldVgroup
->
version
=
pNewVgroup
->
version
;
pOldVgroup
->
hashBegin
=
pNewVgroup
->
hashBegin
;
pOldVgroup
->
hashEnd
=
pNewVgroup
->
hashEnd
;
pOldVgroup
->
replica
=
pNewVgroup
->
replica
;
memcpy
(
pOldVgroup
->
vnodeGid
,
pNewVgroup
->
vnodeGid
,
TSDB_MAX_REPLICA
*
sizeof
(
SVnodeGid
));
return
0
;
}
SVgObj
*
mndAcquireVgroup
(
SMnode
*
pMnode
,
int32_t
vgId
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
return
sdbAcquire
(
pSdb
,
SDB_VGROUP
,
&
vgId
);
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SVgObj
*
pVgroup
=
sdbAcquire
(
pSdb
,
SDB_VGROUP
,
&
vgId
);
if
(
pVgroup
==
NULL
)
{
terrno
=
TSDB_CODE_MND_VGROUP_NOT_EXIST
;
}
return
pVgroup
;
}
void
mndReleaseVgroup
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
)
{
...
...
@@ -158,14 +164,14 @@ void mndReleaseVgroup(SMnode *pMnode, SVgObj *pVgroup) {
}
SCreateVnodeMsg
*
mndBuildCreateVnodeMsg
(
SMnode
*
pMnode
,
SDnodeObj
*
pDnode
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
)
{
SCreateVnodeMsg
*
pCreate
=
malloc
(
sizeof
(
SCreateVnodeMsg
));
SCreateVnodeMsg
*
pCreate
=
calloc
(
1
,
sizeof
(
SCreateVnodeMsg
));
if
(
pCreate
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
pCreate
->
dnodeId
=
htonl
(
pDnode
->
id
);
pCreate
->
vgId
=
htonl
(
pVgroup
->
vgId
);
pCreate
->
dnodeId
=
htonl
(
pDnode
->
id
);
memcpy
(
pCreate
->
db
,
pDb
->
name
,
TSDB_FULL_DB_NAME_LEN
);
pCreate
->
dbUid
=
htobe64
(
pDb
->
uid
);
pCreate
->
vgVersion
=
htonl
(
pVgroup
->
version
);
...
...
@@ -194,7 +200,6 @@ SCreateVnodeMsg *mndBuildCreateVnodeMsg(SMnode *pMnode, SDnodeObj *pDnode, SDbOb
SDnodeObj
*
pVgidDnode
=
mndAcquireDnode
(
pMnode
,
pVgid
->
dnodeId
);
if
(
pVgidDnode
==
NULL
)
{
free
(
pCreate
);
terrno
=
TSDB_CODE_MND_APP_ERROR
;
return
NULL
;
}
...
...
@@ -218,7 +223,7 @@ SCreateVnodeMsg *mndBuildCreateVnodeMsg(SMnode *pMnode, SDnodeObj *pDnode, SDbOb
}
SDropVnodeMsg
*
mndBuildDropVnodeMsg
(
SMnode
*
pMnode
,
SDnodeObj
*
pDnode
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
)
{
SDropVnodeMsg
*
pDrop
=
malloc
(
sizeof
(
SDropVnodeMsg
));
SDropVnodeMsg
*
pDrop
=
calloc
(
1
,
sizeof
(
SDropVnodeMsg
));
if
(
pDrop
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
...
...
@@ -270,7 +275,7 @@ int32_t mndAllocVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj **ppVgroups) {
return
-
1
;
}
int32_t
alloceVgroups
=
0
;
int32_t
alloce
d
Vgroups
=
0
;
int32_t
maxVgId
=
sdbGetMaxId
(
pMnode
->
pSdb
,
SDB_VGROUP
);
uint32_t
hashMin
=
0
;
uint32_t
hashMax
=
UINT32_MAX
;
...
...
@@ -282,7 +287,6 @@ int32_t mndAllocVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj **ppVgroups) {
pVgroup
->
createdTime
=
taosGetTimestampMs
();
pVgroup
->
updateTime
=
pVgroups
->
createdTime
;
pVgroup
->
version
=
1
;
pVgroup
->
dbUid
=
pDb
->
uid
;
pVgroup
->
hashBegin
=
hashMin
+
hashInterval
*
v
;
if
(
v
==
pDb
->
cfg
.
numOfVgroups
-
1
)
{
pVgroup
->
hashEnd
=
hashMax
;
...
...
@@ -291,6 +295,7 @@ int32_t mndAllocVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj **ppVgroups) {
}
memcpy
(
pVgroup
->
dbName
,
pDb
->
name
,
TSDB_FULL_DB_NAME_LEN
);
pVgroup
->
dbUid
=
pDb
->
uid
;
pVgroup
->
replica
=
pDb
->
cfg
.
replications
;
if
(
mndGetAvailableDnode
(
pMnode
,
pVgroup
)
!=
0
)
{
...
...
@@ -299,7 +304,7 @@ int32_t mndAllocVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj **ppVgroups) {
return
-
1
;
}
alloceVgroups
++
;
alloce
d
Vgroups
++
;
}
*
ppVgroups
=
pVgroups
;
...
...
@@ -313,8 +318,7 @@ static int32_t mndProcessSyncVnodeRsp(SMnodeMsg *pMsg) { return 0; }
static
int32_t
mndProcessCompactVnodeRsp
(
SMnodeMsg
*
pMsg
)
{
return
0
;
}
static
int32_t
mndGetVgroupMaxReplica
(
SMnode
*
pMnode
,
char
*
dbName
,
int8_t
*
pReplica
,
int32_t
*
pNumOfVgroups
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SDbObj
*
pDb
=
mndAcquireDb
(
pMnode
,
dbName
);
if
(
pDb
==
NULL
)
{
terrno
=
TSDB_CODE_MND_DB_NOT_SELECTED
;
...
...
@@ -330,7 +334,7 @@ static int32_t mndGetVgroupMaxReplica(SMnode *pMnode, char *dbName, int8_t *pRep
pIter
=
sdbFetch
(
pSdb
,
SDB_VGROUP
,
pIter
,
(
void
**
)
&
pVgroup
);
if
(
pIter
==
NULL
)
break
;
if
(
strcmp
(
pVgroup
->
dbName
,
dbName
)
==
0
)
{
if
(
pVgroup
->
dbUid
==
pDb
->
uid
)
{
replica
=
MAX
(
replica
,
pVgroup
->
replica
);
numOfVgroups
++
;
}
...
...
@@ -442,11 +446,25 @@ static void mndCancelGetNextVgroup(SMnode *pMnode, void *pIter) {
}
static
int32_t
mndGetVnodesNum
(
SMnode
*
pMnode
,
int32_t
dnodeId
)
{
if
(
dnodeId
==
0
)
{
return
0
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfVnodes
=
0
;
void
*
pIter
=
NULL
;
while
(
1
)
{
SVgObj
*
pVgroup
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_VGROUP
,
pIter
,
(
void
**
)
&
pVgroup
);
if
(
pIter
==
NULL
)
break
;
for
(
int32_t
v
=
0
;
v
<
pVgroup
->
replica
;
++
v
)
{
if
(
pVgroup
->
vnodeGid
[
v
].
dnodeId
==
dnodeId
)
{
numOfVnodes
++
;
}
}
sdbRelease
(
pSdb
,
pVgroup
);
}
return
0
;
return
numOfVnodes
;
}
static
int32_t
mndGetVnodeMeta
(
SMnodeMsg
*
pMsg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
...
...
source/dnode/mnode/impl/src/mnode.c
浏览文件 @
acacf74b
...
...
@@ -237,6 +237,9 @@ SMnode *mndOpen(const char *path, const SMnodeOpt *pOption) {
return
NULL
;
}
char
timestr
[
24
]
=
"1970-01-01 00:00:00.00"
;
(
void
)
taosParseTime
(
timestr
,
&
pMnode
->
checkTime
,
(
int32_t
)
strlen
(
timestr
),
TSDB_TIME_PRECISION_MILLI
,
0
);
pMnode
->
pSteps
=
taosArrayInit
(
24
,
sizeof
(
SMnodeStep
));
if
(
pMnode
->
pSteps
==
NULL
)
{
free
(
pMnode
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录