Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d0a3a288
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看板
提交
d0a3a288
编写于
11月 19, 2019
作者:
S
slguan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TBASE-1186]
上级
54e7aef8
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
110 addition
and
54 deletion
+110
-54
src/inc/taoserror.h
src/inc/taoserror.h
+1
-0
src/rpc/src/tstring.c
src/rpc/src/tstring.c
+1
-0
src/system/detail/src/dnodeMgmt.c
src/system/detail/src/dnodeMgmt.c
+5
-1
src/system/detail/src/mgmtDnodeInt.c
src/system/detail/src/mgmtDnodeInt.c
+4
-4
src/system/detail/src/mgmtMeter.c
src/system/detail/src/mgmtMeter.c
+44
-18
src/system/detail/src/mgmtShell.c
src/system/detail/src/mgmtShell.c
+36
-19
src/system/detail/src/mgmtVgroup.c
src/system/detail/src/mgmtVgroup.c
+16
-9
src/system/detail/src/vnodeStore.c
src/system/detail/src/vnodeStore.c
+2
-2
src/system/lite/src/dnodeMgmt.spec.c
src/system/lite/src/dnodeMgmt.spec.c
+1
-1
未找到文件。
src/inc/taoserror.h
浏览文件 @
d0a3a288
...
...
@@ -135,6 +135,7 @@ extern "C" {
#define TSDB_CODE_NOT_ACTIVE_TABLE 114
#define TSDB_CODE_INVALID_TABLE_ID 115
#define TSDB_CODE_INVALID_VNODE_STATUS 116
#define TSDB_CODE_FAILED_TO_LOCK_RESOURCES 117
#ifdef __cplusplus
}
...
...
src/rpc/src/tstring.c
浏览文件 @
d0a3a288
...
...
@@ -241,4 +241,5 @@ char *tsError[] = {"success",
"not active table(not created yet or deleted already)"
,
//114
"invalid table id"
,
"invalid vnode status"
,
//116
"failed to lock resources"
,
};
src/system/detail/src/dnodeMgmt.c
浏览文件 @
d0a3a288
...
...
@@ -373,7 +373,11 @@ int vnodeProcessVPeerCfg(char *msg, int msgLen, SMgmtObj *pMgmtObj) {
}
else
{
dTrace
(
"vid:%d, vnode is not empty"
,
vnode
);
if
(
pCfg
->
maxSessions
>
0
)
{
dTrace
(
"vid:%d, status:%s, start to update vnode"
,
vnode
,
taosGetVnodeStatusStr
(
vnodeList
[
vnode
].
vnodeStatus
));
if
(
vnodeList
[
vnode
].
vnodeStatus
==
TSDB_VNODE_STATUS_DELETING
)
{
dTrace
(
"vid:%d, status:%s, wait vnode delete finished"
,
vnode
,
taosGetVnodeStatusStr
(
vnodeList
[
vnode
].
vnodeStatus
));
}
else
{
dTrace
(
"vid:%d, status:%s, start to update vnode"
,
vnode
,
taosGetVnodeStatusStr
(
vnodeList
[
vnode
].
vnodeStatus
));
}
/*
if (pCfg->maxSessions != vnodeList[vnode].cfg.maxSessions) {
vnodeCleanUpOneVnode(vnode);
...
...
src/system/detail/src/mgmtDnodeInt.c
浏览文件 @
d0a3a288
...
...
@@ -128,7 +128,8 @@ int mgmtProcessVPeersRsp(char *msg, int msgLen, SDnodeObj *pObj) {
}
if
(
pDb
->
vgStatus
!=
TSDB_VG_STATUS_IN_PROGRESS
)
{
mTrace
(
"dnode:%s, db:%s vpeer rsp already disposed, code:%d"
,
taosIpStr
(
pObj
->
privateIp
),
pRsp
->
more
,
pRsp
->
code
);
mTrace
(
"===> pDb:%s %p status:%d"
,
pDb
->
name
,
pDb
,
pDb
->
vgStatus
);
mTrace
(
"dnode:%s, db:%s vpeer rsp already disposed, vgroup status:%d code:%d"
,
taosIpStr
(
pObj
->
privateIp
),
pRsp
->
more
,
pDb
->
vgStatus
,
pRsp
->
code
);
return
0
;
}
...
...
@@ -140,10 +141,11 @@ int mgmtProcessVPeersRsp(char *msg, int msgLen, SDnodeObj *pObj) {
if
(
pRsp
->
code
==
TSDB_CODE_VG_COMMITLOG_INIT_FAILED
)
{
pDb
->
vgStatus
=
TSDB_VG_STATUS_COMMITLOG_INIT_FAILED
;
mError
(
"dnode:%s, db:%s vgroup commit log init failed, code:%d"
,
taosIpStr
(
pObj
->
privateIp
),
pRsp
->
more
,
pRsp
->
code
);
}
else
{
pDb
->
vgStatus
=
TSDB_VG_STATUS_INIT_FAILED
;
mError
(
"dnode:%s, db:%s vgroup init failed, code:%d"
,
taosIpStr
(
pObj
->
privateIp
),
pRsp
->
more
,
pRsp
->
code
);
}
mError
(
"dnode:%s, db:%s vgroup create failed, code:%d"
,
taosIpStr
(
pObj
->
privateIp
),
pRsp
->
more
,
pRsp
->
code
);
return
0
;
}
...
...
@@ -331,7 +333,6 @@ char *mgmtBuildVpeersIe(char *pMsg, SVgObj *pVgroup, int vnode) {
pCfg
->
replications
=
(
char
)
pVgroup
->
numOfVnodes
;
pCfg
->
rowsInFileBlock
=
htonl
(
pCfg
->
rowsInFileBlock
);
#ifdef CLUSTER
SVPeerDesc
*
vpeerDesc
=
pVPeers
->
vpeerDesc
;
pMsg
=
(
char
*
)(
pVPeers
->
vpeerDesc
);
...
...
@@ -341,7 +342,6 @@ char *mgmtBuildVpeersIe(char *pMsg, SVgObj *pVgroup, int vnode) {
vpeerDesc
[
j
].
vnode
=
htonl
(
pVgroup
->
vnodeGid
[
j
].
vnode
);
pMsg
+=
sizeof
(
SVPeerDesc
);
}
#endif
return
pMsg
;
}
...
...
src/system/detail/src/mgmtMeter.c
浏览文件 @
d0a3a288
...
...
@@ -502,7 +502,7 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
int
numOfTables
=
sdbGetNumOfRows
(
meterSdb
);
if
(
numOfTables
>=
tsMaxTables
)
{
m
Warn
(
"numOfTables:%d, exceed tsMaxTables:%d"
,
numOfTables
,
tsMaxTables
);
m
Error
(
"table:%s, numOfTables:%d exceed maxTables:%d"
,
pCreate
->
meterId
,
numOfTables
,
tsMaxTables
);
return
TSDB_CODE_TOO_MANY_TABLES
;
}
...
...
@@ -510,6 +510,7 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
assert
(
pAcct
!=
NULL
);
int
code
=
mgmtCheckMeterLimit
(
pAcct
,
pCreate
);
if
(
code
!=
0
)
{
mError
(
"table:%s, exceed the limit"
,
pCreate
->
meterId
);
return
code
;
}
...
...
@@ -517,8 +518,10 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
pMeter
=
mgmtGetMeter
(
pCreate
->
meterId
);
if
(
pMeter
)
{
if
(
pCreate
->
igExists
)
{
mError
(
"table:%s, igExists is true"
,
pCreate
->
meterId
);
return
TSDB_CODE_SUCCESS
;
}
else
{
mError
(
"table:%s, table is already exist"
,
pCreate
->
meterId
);
return
TSDB_CODE_TABLE_ALREADY_EXIST
;
}
}
...
...
@@ -533,6 +536,7 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
char
*
pTagData
=
(
char
*
)
pCreate
->
schema
;
// it is a tag key
pMetric
=
mgmtGetMeter
(
pTagData
);
if
(
pMetric
==
NULL
)
{
mError
(
"table:%s, corresponding super table does not exist"
,
pCreate
->
meterId
);
return
TSDB_CODE_INVALID_TABLE
;
}
...
...
@@ -545,6 +549,7 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
pMeter
->
schema
=
(
char
*
)
malloc
(
size
);
if
(
pMeter
->
schema
==
NULL
)
{
mgmtDestroyMeter
(
pMeter
);
mError
(
"table:%s, corresponding super table schema is null"
,
pCreate
->
meterId
);
return
TSDB_CODE_INVALID_TABLE
;
}
memset
(
pMeter
->
schema
,
0
,
size
);
...
...
@@ -556,13 +561,13 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
pMeter
->
pTagData
=
pMeter
->
schema
;
pMeter
->
nextColId
=
pMetric
->
nextColId
;
memcpy
(
pMeter
->
pTagData
,
pTagData
,
size
);
}
else
{
int
numOfCols
=
pCreate
->
numOfColumns
+
pCreate
->
numOfTags
;
size
=
numOfCols
*
sizeof
(
SSchema
)
+
pCreate
->
sqlLen
;
pMeter
->
schema
=
(
char
*
)
malloc
(
size
);
if
(
pMeter
->
schema
==
NULL
)
{
mgmtDestroyMeter
(
pMeter
);
mError
(
"table:%s, no schema input"
,
pCreate
->
meterId
);
return
TSDB_CODE_SERV_OUT_OF_MEMORY
;
}
memset
(
pMeter
->
schema
,
0
,
size
);
...
...
@@ -583,7 +588,7 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
pMeter
->
pSql
=
pMeter
->
schema
+
numOfCols
*
sizeof
(
SSchema
);
memcpy
(
pMeter
->
pSql
,
(
char
*
)(
pCreate
->
schema
)
+
numOfCols
*
sizeof
(
SSchema
),
pCreate
->
sqlLen
);
pMeter
->
pSql
[
pCreate
->
sqlLen
-
1
]
=
0
;
mTrace
(
"
stream sql len:%d, sql:%s"
,
pCreate
->
sqlLen
,
pMeter
->
pSql
);
mTrace
(
"
table:%s, stream sql len:%d sql:%s"
,
pCreate
->
meterId
,
pCreate
->
sqlLen
,
pMeter
->
pSql
);
}
else
{
if
(
pCreate
->
numOfTags
>
0
)
{
pMeter
->
meterType
=
TSDB_METER_METRIC
;
...
...
@@ -596,13 +601,14 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
pMeter
->
createdTime
=
taosGetTimestampMs
();
strcpy
(
pMeter
->
meterId
,
pCreate
->
meterId
);
if
(
pthread_rwlock_init
(
&
pMeter
->
rwLock
,
NULL
))
{
mError
(
"
Failed to init meter lock"
);
mError
(
"
table:%s, failed to init meter lock"
,
pCreate
->
meterId
);
mgmtDestroyMeter
(
pMeter
);
return
TSDB_CODE_
OTHER
S
;
return
TSDB_CODE_
FAILED_TO_LOCK_RESOURCE
S
;
}
code
=
mgmtCheckMeterGrant
(
pCreate
,
pMeter
);
if
(
code
!=
0
)
{
mError
(
"table:%s, grant expired"
,
pCreate
->
meterId
);
return
code
;
}
...
...
@@ -611,21 +617,26 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
if
(
pDb
->
vgStatus
==
TSDB_VG_STATUS_IN_PROGRESS
)
{
mgmtDestroyMeter
(
pMeter
);
mTrace
(
"table:%s, vgroup in creating progress"
,
pCreate
->
meterId
);
mTrace
(
"===> pDb:%s %p status:%d"
,
pDb
->
name
,
pDb
,
pDb
->
vgStatus
);
return
TSDB_CODE_ACTION_IN_PROGRESS
;
}
if
(
pDb
->
vgStatus
==
TSDB_VG_STATUS_FULL
)
{
mgmtDestroyMeter
(
pMeter
);
mError
(
"table:%s, vgroup is full"
,
pCreate
->
meterId
);
return
TSDB_CODE_NO_ENOUGH_DNODES
;
}
if
(
pDb
->
vgStatus
==
TSDB_VG_STATUS_COMMITLOG_INIT_FAILED
)
{
mgmtDestroyMeter
(
pMeter
);
mError
(
"table:%s, commit log init failed"
,
pCreate
->
meterId
);
return
TSDB_CODE_VG_COMMITLOG_INIT_FAILED
;
}
if
(
pDb
->
vgStatus
==
TSDB_VG_STATUS_INIT_FAILED
)
{
mgmtDestroyMeter
(
pMeter
);
mError
(
"table:%s, vgroup init failed"
,
pCreate
->
meterId
);
return
TSDB_CODE_VG_INIT_FAILED
;
}
...
...
@@ -633,12 +644,14 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
pDb
->
vgStatus
=
TSDB_VG_STATUS_IN_PROGRESS
;
mgmtCreateVgroup
(
pDb
);
mgmtDestroyMeter
(
pMeter
);
mTrace
(
"table:%s, vgroup malloced, wait for create progress finished"
,
pCreate
->
meterId
);
mTrace
(
"===> pDb:%s %p status:%d"
,
pDb
->
name
,
pDb
,
pDb
->
vgStatus
);
return
TSDB_CODE_ACTION_IN_PROGRESS
;
}
int
sid
=
taosAllocateId
(
pVgroup
->
idPool
);
if
(
sid
<
0
)
{
mWarn
(
"
db:%s, vgroup:%d, run out of ID, num:%d"
,
pDb
->
name
,
pVgroup
->
vgId
,
taosIdPoolNumOfUsed
(
pVgroup
->
idPool
));
mWarn
(
"
table:%s, vgroup:%d run out of ID, num:%d"
,
pCreate
->
meterId
,
pVgroup
->
vgId
,
taosIdPoolNumOfUsed
(
pVgroup
->
idPool
));
pDb
->
vgStatus
=
TSDB_VG_STATUS_IN_PROGRESS
;
mgmtCreateVgroup
(
pDb
);
mgmtDestroyMeter
(
pMeter
);
...
...
@@ -650,18 +663,21 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
pMeter
->
uid
=
(((
uint64_t
)
pMeter
->
gid
.
vgId
)
<<
40
)
+
((((
uint64_t
)
pMeter
->
gid
.
sid
)
&
((
1ul
<<
24
)
-
1ul
))
<<
16
)
+
((
uint64_t
)
sdbVersion
&
((
1ul
<<
16
)
-
1ul
));
mTrace
(
"
meter:%s, create meter in vgroup, vgId:%d, sid:%d, vnode:%d, uid:%d
"
,
pMeter
->
meterId
,
pVgroup
->
vgId
,
sid
,
pVgroup
->
vnodeGid
[
0
].
vnode
,
pMeter
->
uid
);
mTrace
(
"
table:%s, create table in vgroup, vgId:%d sid:%d vnode:%d uid:%d db:%s
"
,
pMeter
->
meterId
,
pVgroup
->
vgId
,
sid
,
pVgroup
->
vnodeGid
[
0
].
vnode
,
pMeter
->
uid
,
pDb
->
name
);
}
else
{
pMeter
->
uid
=
(((
uint64_t
)
pMeter
->
createdTime
)
<<
16
)
+
((
uint64_t
)
sdbVersion
&
((
1ul
<<
16
)
-
1ul
));
}
if
(
sdbInsertRow
(
meterSdb
,
pMeter
,
0
)
<
0
)
return
TSDB_CODE_SDB_ERROR
;
if
(
sdbInsertRow
(
meterSdb
,
pMeter
,
0
)
<
0
)
{
mError
(
"table:%s, update sdb error"
,
pCreate
->
meterId
);
return
TSDB_CODE_SDB_ERROR
;
}
// send create message to the selected vnode servers
if
(
pCreate
->
numOfTags
==
0
)
{
mTrace
(
"
meter:%s, send msg to dnode, vgId:%d, sid:%d, vnode:%d, dbname:%s
"
,
pMeter
->
meterId
,
pMeter
->
gid
.
vgId
,
pMeter
->
gid
.
sid
,
pVgroup
->
vnodeGid
[
0
].
vnode
,
pDb
->
name
);
mTrace
(
"
table:%s, send create msg to dnode, vgId:%d, sid:%d, vnode:%d
"
,
pMeter
->
meterId
,
pMeter
->
gid
.
vgId
,
pMeter
->
gid
.
sid
,
pVgroup
->
vnodeGid
[
0
].
vnode
);
grantAddTimeSeries
(
pMeter
->
numOfColumns
-
1
);
mgmtSendCreateMsgToVgroup
(
pMeter
,
pVgroup
);
...
...
@@ -881,7 +897,10 @@ void mgmtCleanUpMeters() { sdbCloseTable(meterSdb); }
int
mgmtGetMeterMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
int
cols
=
0
;
if
(
pConn
->
pDb
==
NULL
)
return
TSDB_CODE_DB_NOT_SELECTED
;
SDbObj
*
pDb
=
NULL
;
if
(
pConn
->
pDb
!=
NULL
)
pDb
=
mgmtGetDb
(
pConn
->
pDb
->
name
);
if
(
pDb
==
NULL
)
return
TSDB_CODE_DB_NOT_SELECTED
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
...
...
@@ -916,7 +935,7 @@ int mgmtGetMeterMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
for
(
int
i
=
1
;
i
<
cols
;
++
i
)
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
// pShow->numOfRows = sdbGetNumOfRows (meterSdb);
pShow
->
numOfRows
=
p
Conn
->
p
Db
->
numOfTables
;
pShow
->
numOfRows
=
pDb
->
numOfTables
;
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
return
0
;
...
...
@@ -1208,8 +1227,12 @@ int mgmtRetrieveMeters(SShowObj *pShow, char *data, int rows, SConnObj *pConn) {
int
numOfRead
=
0
;
char
prefix
[
20
]
=
{
0
};
if
(
pConn
->
pDb
==
NULL
)
return
0
;
strcpy
(
prefix
,
pConn
->
pDb
->
name
);
SDbObj
*
pDb
=
NULL
;
if
(
pConn
->
pDb
!=
NULL
)
pDb
=
mgmtGetDb
(
pConn
->
pDb
->
name
);
if
(
pDb
==
NULL
)
return
0
;
strcpy
(
prefix
,
pDb
->
name
);
strcat
(
prefix
,
TS_PATH_DELIMITER
);
prefixLen
=
strlen
(
prefix
);
...
...
@@ -1269,7 +1292,10 @@ int mgmtRetrieveMeters(SShowObj *pShow, char *data, int rows, SConnObj *pConn) {
int
mgmtGetMetricMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
int
cols
=
0
;
if
(
pConn
->
pDb
==
NULL
)
return
TSDB_CODE_DB_NOT_SELECTED
;
SDbObj
*
pDb
=
NULL
;
if
(
pConn
->
pDb
!=
NULL
)
pDb
=
mgmtGetDb
(
pConn
->
pDb
->
name
);
if
(
pDb
==
NULL
)
return
TSDB_CODE_DB_NOT_SELECTED
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
...
...
@@ -1309,8 +1335,8 @@ int mgmtGetMetricMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
pShow
->
offset
[
0
]
=
0
;
for
(
int
i
=
1
;
i
<
cols
;
++
i
)
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
pShow
->
numOfRows
=
p
Conn
->
p
Db
->
numOfMetrics
;
pShow
->
pNode
=
p
Conn
->
p
Db
->
pMetric
;
pShow
->
numOfRows
=
pDb
->
numOfMetrics
;
pShow
->
pNode
=
pDb
->
pMetric
;
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
return
0
;
...
...
src/system/detail/src/mgmtShell.c
浏览文件 @
d0a3a288
...
...
@@ -189,8 +189,11 @@ int mgmtProcessMeterMetaMsg(char *pMsg, int msgLen, SConnObj *pConn) {
int
size
=
sizeof
(
STaosHeader
)
+
sizeof
(
STaosRsp
)
+
sizeof
(
SMeterMeta
)
+
sizeof
(
SSchema
)
*
TSDB_MAX_COLUMNS
+
sizeof
(
SSchema
)
*
TSDB_MAX_TAGS
+
TSDB_MAX_TAGS_LEN
+
TSDB_EXTRA_PAYLOAD_SIZE
;
SDbObj
*
pDb
=
NULL
;
if
(
pConn
->
pDb
!=
NULL
)
pDb
=
mgmtGetDb
(
pConn
->
pDb
->
name
);
// todo db check should be extracted
if
(
p
Conn
->
pDb
==
NULL
||
(
pConn
->
pDb
!=
NULL
&&
pConn
->
pDb
->
dropStatus
!=
TSDB_DB_STATUS_READY
))
{
if
(
p
Db
==
NULL
||
(
pDb
!=
NULL
&&
pDb
->
dropStatus
!=
TSDB_DB_STATUS_READY
))
{
if
((
pStart
=
mgmtAllocMsg
(
pConn
,
size
,
&
pMsg
,
&
pRsp
))
==
NULL
)
{
taosSendSimpleRsp
(
pConn
->
thandle
,
TSDB_MSG_TYPE_METERINFO_RSP
,
TSDB_CODE_SERV_OUT_OF_MEMORY
);
...
...
@@ -223,10 +226,10 @@ int mgmtProcessMeterMetaMsg(char *pMsg, int msgLen, SConnObj *pConn) {
SDbObj
*
pMeterDb
=
mgmtGetDbByMeterId
(
pCreateMsg
->
meterId
);
mTrace
(
"meter:%s, pConnDb:%p, pConnDbName:%s, pMeterDb:%p, pMeterDbName:%s"
,
pCreateMsg
->
meterId
,
p
Conn
->
pDb
,
pConn
->
pDb
->
name
,
pMeterDb
,
pMeterDb
->
name
);
assert
(
p
Conn
->
p
Db
==
pMeterDb
);
pCreateMsg
->
meterId
,
p
Db
,
pDb
->
name
,
pMeterDb
,
pMeterDb
->
name
);
assert
(
pDb
==
pMeterDb
);
int32_t
code
=
mgmtCreateMeter
(
p
Conn
->
p
Db
,
pCreateMsg
);
int32_t
code
=
mgmtCreateMeter
(
pDb
,
pCreateMsg
);
char
stableName
[
TSDB_METER_ID_LEN
]
=
{
0
};
strncpy
(
stableName
,
pInfo
->
tags
,
TSDB_METER_ID_LEN
);
...
...
@@ -256,7 +259,7 @@ int mgmtProcessMeterMetaMsg(char *pMsg, int msgLen, SConnObj *pConn) {
}
if
(
pMeterObj
==
NULL
)
{
if
(
p
Conn
->
p
Db
)
if
(
pDb
)
pRsp
->
code
=
TSDB_CODE_INVALID_TABLE
;
else
pRsp
->
code
=
TSDB_CODE_DB_NOT_SELECTED
;
...
...
@@ -274,7 +277,7 @@ int mgmtProcessMeterMetaMsg(char *pMsg, int msgLen, SConnObj *pConn) {
pMeta
->
vgid
=
htonl
(
pMeterObj
->
gid
.
vgId
);
pMeta
->
sversion
=
htons
(
pMeterObj
->
sversion
);
pMeta
->
precision
=
p
Conn
->
p
Db
->
cfg
.
precision
;
pMeta
->
precision
=
pDb
->
cfg
.
precision
;
pMeta
->
numOfTags
=
pMeterObj
->
numOfTags
;
pMeta
->
numOfColumns
=
htons
(
pMeterObj
->
numOfColumns
);
...
...
@@ -505,7 +508,10 @@ int mgmtProcessMetricMetaMsg(char *pMsg, int msgLen, SConnObj *pConn) {
SMetricMetaElemMsg
*
pElem
=
(
SMetricMetaElemMsg
*
)(((
char
*
)
pMetricMetaMsg
)
+
pMetricMetaMsg
->
metaElem
[
0
]);
pMetric
=
mgmtGetMeter
(
pElem
->
meterId
);
if
(
pMetric
==
NULL
||
(
pConn
->
pDb
!=
NULL
&&
pConn
->
pDb
->
dropStatus
!=
TSDB_DB_STATUS_READY
))
{
SDbObj
*
pDb
=
NULL
;
if
(
pConn
->
pDb
!=
NULL
)
pDb
=
mgmtGetDb
(
pConn
->
pDb
->
name
);
if
(
pMetric
==
NULL
||
(
pDb
!=
NULL
&&
pDb
->
dropStatus
!=
TSDB_DB_STATUS_READY
))
{
pStart
=
taosBuildRspMsg
(
pConn
->
thandle
,
TSDB_MSG_TYPE_METRIC_META_RSP
);
if
(
pStart
==
NULL
)
{
taosSendSimpleRsp
(
pConn
->
thandle
,
TSDB_MSG_TYPE_METRIC_META_RSP
,
TSDB_CODE_SERV_OUT_OF_MEMORY
);
...
...
@@ -514,7 +520,7 @@ int mgmtProcessMetricMetaMsg(char *pMsg, int msgLen, SConnObj *pConn) {
pMsg
=
pStart
;
pRsp
=
(
STaosRsp
*
)
pMsg
;
if
(
p
Conn
->
p
Db
)
if
(
pDb
)
pRsp
->
code
=
TSDB_CODE_INVALID_TABLE
;
else
pRsp
->
code
=
TSDB_CODE_DB_NOT_SELECTED
;
...
...
@@ -957,17 +963,23 @@ int mgmtProcessCreateTableMsg(char *pMsg, int msgLen, SConnObj *pConn) {
pSchema
++
;
}
if
(
pConn
->
pDb
)
{
code
=
mgmtCreateMeter
(
pConn
->
pDb
,
pCreate
);
if
(
code
==
0
)
{
mTrace
(
"meter:%s is created by %s"
,
pCreate
->
meterId
,
pConn
->
pUser
->
user
);
// mLPrint("meter:%s is created by %s", pCreate->meterId, pConn->pUser->user);
}
SDbObj
*
pDb
=
NULL
;
if
(
pConn
->
pDb
!=
NULL
)
pDb
=
mgmtGetDb
(
pConn
->
pDb
->
name
);
if
(
pDb
)
{
code
=
mgmtCreateMeter
(
pDb
,
pCreate
);
}
else
{
code
=
TSDB_CODE_DB_NOT_SELECTED
;
}
}
if
(
code
!=
0
)
{
mError
(
"table:%s, failed to create table, code:%d"
,
pCreate
->
meterId
,
code
);
}
else
{
mTrace
(
"table:%s, table is created by %s"
,
pCreate
->
meterId
,
pConn
->
pUser
->
user
);
//mLPrint("meter:%s is created by %s", pCreate->meterId, pConn->pUser->user);
}
taosSendSimpleRsp
(
pConn
->
thandle
,
TSDB_MSG_TYPE_CREATE_TABLE_RSP
,
code
);
return
0
;
...
...
@@ -984,7 +996,10 @@ int mgmtProcessDropTableMsg(char *pMsg, int msgLen, SConnObj *pConn) {
if
(
!
pConn
->
writeAuth
)
{
code
=
TSDB_CODE_NO_RIGHTS
;
}
else
{
code
=
mgmtDropMeter
(
pConn
->
pDb
,
pDrop
->
meterId
,
pDrop
->
igNotExists
);
SDbObj
*
pDb
=
NULL
;
if
(
pConn
->
pDb
!=
NULL
)
pDb
=
mgmtGetDb
(
pConn
->
pDb
->
name
);
code
=
mgmtDropMeter
(
pDb
,
pDrop
->
meterId
,
pDrop
->
igNotExists
);
if
(
code
==
0
)
{
mTrace
(
"meter:%s is dropped by user:%s"
,
pDrop
->
meterId
,
pConn
->
pUser
->
user
);
// mLPrint("meter:%s is dropped by user:%s", pDrop->meterId, pConn->pUser->user);
...
...
@@ -1014,12 +1029,15 @@ int mgmtProcessAlterTableMsg(char *pMsg, int msgLen, SConnObj *pConn) {
mError
(
"meter:%s error numOfCols:%d in alter table"
,
pAlter
->
meterId
,
pAlter
->
numOfCols
);
code
=
TSDB_CODE_APP_ERROR
;
}
else
{
if
(
pConn
->
pDb
)
{
SDbObj
*
pDb
=
NULL
;
if
(
pConn
->
pDb
!=
NULL
)
pDb
=
mgmtGetDb
(
pConn
->
pDb
->
name
);
if
(
pDb
)
{
for
(
int32_t
i
=
0
;
i
<
pAlter
->
numOfCols
;
++
i
)
{
pAlter
->
schema
[
i
].
bytes
=
htons
(
pAlter
->
schema
[
i
].
bytes
);
}
code
=
mgmtAlterMeter
(
p
Conn
->
p
Db
,
pAlter
);
code
=
mgmtAlterMeter
(
pDb
,
pAlter
);
if
(
code
==
0
)
{
mLPrint
(
"meter:%s is altered by %s"
,
pAlter
->
meterId
,
pConn
->
pUser
->
user
);
}
...
...
@@ -1263,8 +1281,7 @@ void *mgmtProcessMsgFromShell(char *msg, void *ahandle, void *thandle) {
}
if
(
pConn
->
pAcct
)
{
if
(
pConn
->
pDb
==
NULL
||
strncmp
(
pConn
->
pDb
->
name
,
pHead
->
db
,
tListLen
(
pConn
->
pDb
->
name
))
!=
0
)
{
if
(
pConn
->
pDb
==
NULL
||
strncmp
(
pConn
->
pDb
->
name
,
pHead
->
db
,
tListLen
(
pConn
->
pDb
->
name
))
!=
0
)
{
pConn
->
pDb
=
mgmtGetDb
(
pHead
->
db
);
}
...
...
src/system/detail/src/mgmtVgroup.c
浏览文件 @
d0a3a288
...
...
@@ -123,7 +123,7 @@ void mgmtProcessVgTimer(void *handle, void *tmrId) {
if
(
pDb
==
NULL
)
return
;
if
(
pDb
->
vgStatus
>
TSDB_VG_STATUS_IN_PROGRESS
)
{
mTrace
(
"db:%s, set vg
status from %d to %d"
,
pDb
->
name
,
pDb
->
vgStatus
,
TSDB_VG_STATUS_READY
);
mTrace
(
"db:%s, set vg
roup status from %d to ready"
,
pDb
->
name
,
pDb
->
vgStatus
);
pDb
->
vgStatus
=
TSDB_VG_STATUS_READY
;
}
...
...
@@ -143,7 +143,7 @@ SVgObj *mgmtCreateVgroup(SDbObj *pDb) {
// based on load balance, create a new one
if
(
mgmtAllocVnodes
(
pVgroup
)
!=
0
)
{
mError
(
"
no enough free dnode"
);
mError
(
"
db:%s, no enough free dnode to alloc %d vnodes"
,
pDb
->
name
,
pVgroup
->
numOfVnodes
);
free
(
pVgroup
);
pDb
->
vgStatus
=
TSDB_VG_STATUS_FULL
;
taosTmrReset
(
mgmtProcessVgTimer
,
5000
,
pDb
,
mgmtTmr
,
&
pDb
->
vgTimer
);
...
...
@@ -152,9 +152,9 @@ SVgObj *mgmtCreateVgroup(SDbObj *pDb) {
sdbInsertRow
(
vgSdb
,
pVgroup
,
0
);
mTrace
(
"vgroup:%d,
db:%s replica:%d is create
d"
,
pVgroup
->
vgId
,
pDb
->
name
,
pVgroup
->
numOfVnodes
);
mTrace
(
"vgroup:%d,
vgroup is created, db:%s replica:%
d"
,
pVgroup
->
vgId
,
pDb
->
name
,
pVgroup
->
numOfVnodes
);
for
(
int
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
mTrace
(
"
dnode:%s, vgroup:%d, vnode:%d is created"
,
taosIpStr
(
pVgroup
->
vnodeGid
[
i
].
ip
),
pVgroup
->
vgId
,
pVgroup
->
vnodeGid
[
i
].
vnode
);
mTrace
(
"
vgroup:%d, dnode:%s vnode:%d is created"
,
pVgroup
->
vgId
,
taosIpStr
(
pVgroup
->
vnodeGid
[
i
].
ip
)
,
pVgroup
->
vnodeGid
[
i
].
vnode
);
mgmtSendVPeersMsg
(
pVgroup
);
...
...
@@ -206,7 +206,10 @@ void mgmtCleanUpVgroups() { sdbCloseTable(vgSdb); }
int
mgmtGetVgroupMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
int
cols
=
0
;
if
(
pConn
->
pDb
==
NULL
)
return
TSDB_CODE_DB_NOT_SELECTED
;
SDbObj
*
pDb
=
NULL
;
if
(
pConn
->
pDb
!=
NULL
)
pDb
=
mgmtGetDb
(
pConn
->
pDb
->
name
);
if
(
pDb
==
NULL
)
return
TSDB_CODE_DB_NOT_SELECTED
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
...
...
@@ -229,7 +232,7 @@ int mgmtGetVgroupMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
cols
++
;
int
maxReplica
=
0
;
SVgObj
*
pVgroup
=
p
Conn
->
p
Db
->
pHead
;
SVgObj
*
pVgroup
=
pDb
->
pHead
;
while
(
pVgroup
!=
NULL
)
{
maxReplica
=
pVgroup
->
numOfVnodes
>
maxReplica
?
pVgroup
->
numOfVnodes
:
maxReplica
;
pVgroup
=
pVgroup
->
next
;
...
...
@@ -267,8 +270,8 @@ int mgmtGetVgroupMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
pShow
->
offset
[
0
]
=
0
;
for
(
int
i
=
1
;
i
<
cols
;
++
i
)
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
pShow
->
numOfRows
=
p
Conn
->
p
Db
->
numOfVgroups
;
pShow
->
pNode
=
p
Conn
->
p
Db
->
pHead
;
pShow
->
numOfRows
=
pDb
->
numOfVgroups
;
pShow
->
pNode
=
pDb
->
pHead
;
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
return
0
;
...
...
@@ -282,7 +285,11 @@ int mgmtRetrieveVgroups(SShowObj *pShow, char *data, int rows, SConnObj *pConn)
char
ipstr
[
20
];
int
maxReplica
=
0
;
pVgroup
=
pConn
->
pDb
->
pHead
;
SDbObj
*
pDb
=
NULL
;
if
(
pConn
->
pDb
!=
NULL
)
pDb
=
mgmtGetDb
(
pConn
->
pDb
->
name
);
pVgroup
=
pDb
->
pHead
;
while
(
pVgroup
!=
NULL
)
{
maxReplica
=
pVgroup
->
numOfVnodes
>
maxReplica
?
pVgroup
->
numOfVnodes
:
maxReplica
;
pVgroup
=
pVgroup
->
next
;
...
...
src/system/detail/src/vnodeStore.c
浏览文件 @
d0a3a288
...
...
@@ -141,7 +141,7 @@ static int vnodeCloseVnode(int vnode) {
}
if
(
pVnode
->
vnodeStatus
==
TSDB_VNODE_STATUS_DELETING
)
{
dTrace
(
"vid:%d, status:%s, another performed delete operation"
,
vnode
,
taosGetVnodeStatusStr
(
pVnode
->
vnodeStatus
));
dTrace
(
"vid:%d, status:%s, another
thread
performed delete operation"
,
vnode
,
taosGetVnodeStatusStr
(
pVnode
->
vnodeStatus
));
return
TSDB_CODE_SUCCESS
;
}
else
{
dTrace
(
"vid:%d, status:%s, enter close operation"
,
vnode
,
taosGetVnodeStatusStr
(
pVnode
->
vnodeStatus
));
...
...
@@ -250,7 +250,7 @@ static void vnodeRemoveDataFiles(int vnode) {
sprintf
(
vnodeDir
,
"%s/vnode%d"
,
tsDirectory
,
vnode
);
rmdir
(
vnodeDir
);
dTrace
(
"v
node %d
is removed!"
,
vnode
);
dTrace
(
"v
id:%d, vnode
is removed!"
,
vnode
);
}
int
vnodeRemoveVnode
(
int
vnode
)
{
...
...
src/system/lite/src/dnodeMgmt.spec.c
浏览文件 @
d0a3a288
...
...
@@ -50,7 +50,7 @@ char *taosBuildReqMsgToMnode(SMgmtObj *pObj, char type) {
}
int
taosSendMsgToMnode
(
SMgmtObj
*
pObj
,
char
*
msg
,
int
msgLen
)
{
m
Trace
(
"msg:%s is sent to mnode"
,
taosMsg
[
*
(
msg
-
1
)]);
d
Trace
(
"msg:%s is sent to mnode"
,
taosMsg
[
*
(
msg
-
1
)]);
/*
* Lite version has no message header, so minus one
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录