Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
adminstrot
TDengine
提交
ef6df509
TDengine
项目概览
adminstrot
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
ef6df509
编写于
12月 17, 2019
作者:
S
slguan
提交者:
GitHub
12月 17, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #933 from taosdata/feature/liaohj
Feature/liaohj
上级
d92692b6
7d493b3d
变更
37
展开全部
隐藏空白更改
内联
并排
Showing
37 changed file
with
512 addition
and
378 deletion
+512
-378
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+8
-6
src/client/src/tscSchemaUtil.c
src/client/src/tscSchemaUtil.c
+12
-8
src/client/src/tscServer.c
src/client/src/tscServer.c
+67
-58
src/inc/taoserror.h
src/inc/taoserror.h
+2
-1
src/inc/taosmsg.h
src/inc/taosmsg.h
+1
-3
src/inc/tsched.h
src/inc/tsched.h
+2
-0
src/inc/tschemautil.h
src/inc/tschemautil.h
+1
-1
src/rpc/src/tstring.c
src/rpc/src/tstring.c
+4
-3
src/system/detail/inc/mgmtBalance.h
src/system/detail/inc/mgmtBalance.h
+1
-1
src/system/detail/inc/vnode.h
src/system/detail/inc/vnode.h
+0
-11
src/system/detail/inc/vnodeRead.h
src/system/detail/inc/vnodeRead.h
+1
-0
src/system/detail/inc/vnodeStatus.h
src/system/detail/inc/vnodeStatus.h
+20
-9
src/system/detail/src/dnodeMgmt.c
src/system/detail/src/dnodeMgmt.c
+1
-1
src/system/detail/src/mgmtDb.c
src/system/detail/src/mgmtDb.c
+1
-1
src/system/detail/src/mgmtDnode.c
src/system/detail/src/mgmtDnode.c
+1
-2
src/system/detail/src/mgmtMeter.c
src/system/detail/src/mgmtMeter.c
+34
-30
src/system/detail/src/mgmtShell.c
src/system/detail/src/mgmtShell.c
+1
-1
src/system/detail/src/mgmtSupertableQuery.c
src/system/detail/src/mgmtSupertableQuery.c
+2
-2
src/system/detail/src/mgmtVgroup.c
src/system/detail/src/mgmtVgroup.c
+1
-1
src/system/detail/src/vnodeCache.c
src/system/detail/src/vnodeCache.c
+1
-1
src/system/detail/src/vnodeCommit.c
src/system/detail/src/vnodeCommit.c
+2
-1
src/system/detail/src/vnodeFile.c
src/system/detail/src/vnodeFile.c
+2
-1
src/system/detail/src/vnodeImport.c
src/system/detail/src/vnodeImport.c
+1
-0
src/system/detail/src/vnodeMeter.c
src/system/detail/src/vnodeMeter.c
+7
-7
src/system/detail/src/vnodeQueryImpl.c
src/system/detail/src/vnodeQueryImpl.c
+204
-156
src/system/detail/src/vnodeRead.c
src/system/detail/src/vnodeRead.c
+3
-3
src/system/detail/src/vnodeShell.c
src/system/detail/src/vnodeShell.c
+11
-12
src/system/detail/src/vnodeStatus.c
src/system/detail/src/vnodeStatus.c
+22
-10
src/system/detail/src/vnodeStore.c
src/system/detail/src/vnodeStore.c
+2
-2
src/system/detail/src/vnodeStream.c
src/system/detail/src/vnodeStream.c
+2
-2
src/system/detail/src/vnodeSystem.c
src/system/detail/src/vnodeSystem.c
+13
-7
src/system/detail/src/vnodeUtil.c
src/system/detail/src/vnodeUtil.c
+40
-31
src/system/lite/src/mgmtBalance.spec.c
src/system/lite/src/mgmtBalance.spec.c
+1
-1
src/system/lite/src/mgmtDnode.spec.c
src/system/lite/src/mgmtDnode.spec.c
+1
-1
src/system/lite/src/mgmtDnodeInt.spec.c
src/system/lite/src/mgmtDnodeInt.spec.c
+1
-1
src/system/lite/src/vnodePeer.spec.c
src/system/lite/src/vnodePeer.spec.c
+1
-1
src/util/src/tsched.c
src/util/src/tsched.c
+38
-2
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
ef6df509
...
...
@@ -1957,7 +1957,8 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, int32_t colIdx, tSQLExprItem* pItem
}
SColumnIndex
index
=
COLUMN_INDEX_INITIALIZER
;
if
(
getColumnIndexByNameEx
(
&
pParamElem
->
pNode
->
colInfo
,
pCmd
,
&
index
)
!=
TSDB_CODE_SUCCESS
)
{
if
((
getColumnIndexByNameEx
(
&
pParamElem
->
pNode
->
colInfo
,
pCmd
,
&
index
)
!=
TSDB_CODE_SUCCESS
)
||
index
.
columnIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
return
invalidSqlErrMsg
(
pCmd
,
msg3
);
}
...
...
@@ -1966,7 +1967,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, int32_t colIdx, tSQLExprItem* pItem
SSchema
*
pSchema
=
tsGetColumnSchema
(
pMeterMetaInfo
->
pMeterMeta
,
index
.
columnIndex
);
int16_t
colType
=
pSchema
->
type
;
if
(
colType
=
=
TSDB_DATA_TYPE_BOOL
||
colType
>=
TSDB_DATA_TYPE_BINARY
)
{
if
(
colType
<
=
TSDB_DATA_TYPE_BOOL
||
colType
>=
TSDB_DATA_TYPE_BINARY
)
{
return
invalidSqlErrMsg
(
pCmd
,
msg1
);
}
...
...
@@ -2336,7 +2337,7 @@ static int32_t getMeterIndex(SSQLToken* pTableToken, SSqlCmd* pCmd, SColumnIndex
for
(
int32_t
i
=
0
;
i
<
pCmd
->
numOfTables
;
++
i
)
{
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
pCmd
,
i
);
extract
Meter
Name
(
pMeterMetaInfo
->
name
,
tableName
);
extract
Table
Name
(
pMeterMetaInfo
->
name
,
tableName
);
if
(
strncasecmp
(
tableName
,
pTableToken
->
z
,
pTableToken
->
n
)
==
0
&&
strlen
(
tableName
)
==
pTableToken
->
n
)
{
pIndex
->
tableIndex
=
i
;
...
...
@@ -5468,15 +5469,16 @@ static int32_t doAddGroupbyColumnsOnDemand(SSqlCmd* pCmd) {
int32_t
doFunctionsCompatibleCheck
(
SSqlObj
*
pSql
)
{
const
char
*
msg1
=
"functions/columns not allowed in group by query"
;
const
char
*
msg2
=
"projection query on columns not allowed"
;
const
char
*
msg3
=
"group by not allowed on projection query"
;
const
char
*
msg
5
=
"retrieve tags not compatible with group by or interval query"
;
const
char
*
msg
4
=
"retrieve tags not compatible with group by or interval query"
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
// only retrieve tags, group by is not supportted
if
(
pCmd
->
command
==
TSDB_SQL_RETRIEVE_TAGS
)
{
if
(
pCmd
->
groupbyExpr
.
numOfGroupCols
>
0
||
pCmd
->
nAggTimeInterval
>
0
)
{
return
invalidSqlErrMsg
(
pCmd
,
msg
5
);
return
invalidSqlErrMsg
(
pCmd
,
msg
4
);
}
else
{
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -5509,7 +5511,7 @@ int32_t doFunctionsCompatibleCheck(SSqlObj* pSql) {
}
if
(
!
qualified
)
{
return
TSDB_CODE_INVALID_SQL
;
return
invalidSqlErrMsg
(
pCmd
,
msg2
)
;
}
}
...
...
src/client/src/tscSchemaUtil.c
浏览文件 @
ef6df509
...
...
@@ -131,35 +131,39 @@ bool tsMeterMetaIdentical(SMeterMeta* p1, SMeterMeta* p2) {
}
// todo refactor
static
FORCE_INLINE
char
*
skipSegments
(
char
*
input
,
char
delim
iter
,
int32_t
num
)
{
static
FORCE_INLINE
char
*
skipSegments
(
char
*
input
,
char
delim
,
int32_t
num
)
{
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
while
(
*
input
!=
0
&&
*
input
++
!=
delim
iter
)
{
while
(
*
input
!=
0
&&
*
input
++
!=
delim
)
{
};
}
return
input
;
}
static
FORCE_INLINE
void
copySegment
(
char
*
dst
,
char
*
src
,
char
delimiter
)
{
static
FORCE_INLINE
size_t
copy
(
char
*
dst
,
const
char
*
src
,
char
delimiter
)
{
size_t
len
=
0
;
while
(
*
src
!=
delimiter
&&
*
src
!=
0
)
{
*
dst
++
=
*
src
++
;
len
++
;
}
return
len
;
}
/**
* extract
meter
name from meterid, which the format of userid.dbname.metername
* extract
table
name from meterid, which the format of userid.dbname.metername
* @param meterId
* @return
*/
void
extract
Meter
Name
(
char
*
meterId
,
char
*
name
)
{
void
extract
Table
Name
(
char
*
meterId
,
char
*
name
)
{
char
*
r
=
skipSegments
(
meterId
,
TS_PATH_DELIMITER
[
0
],
2
);
copy
Segment
(
name
,
r
,
TS_PATH_DELIMITER
[
0
]);
copy
(
name
,
r
,
TS_PATH_DELIMITER
[
0
]);
}
SSQLToken
extractDBName
(
char
*
meterId
,
char
*
name
)
{
char
*
r
=
skipSegments
(
meterId
,
TS_PATH_DELIMITER
[
0
],
1
);
copySegment
(
name
,
r
,
TS_PATH_DELIMITER
[
0
]);
size_t
len
=
copy
(
name
,
r
,
TS_PATH_DELIMITER
[
0
]);
SSQLToken
token
=
{.
z
=
name
,
.
n
=
strlen
(
name
)
,
.
type
=
TK_STRING
};
SSQLToken
token
=
{.
z
=
name
,
.
n
=
len
,
.
type
=
TK_STRING
};
return
token
;
}
...
...
src/client/src/tscServer.c
浏览文件 @
ef6df509
...
...
@@ -477,25 +477,17 @@ void *tscProcessMsgFromServer(char *msg, void *ahandle, void *thandle) {
if
(
code
==
0
)
return
pSql
;
msg
=
NULL
;
}
else
if
(
rspCode
==
TSDB_CODE_NOT_ACTIVE_TABLE
||
rspCode
==
TSDB_CODE_INVALID_TABLE_ID
||
rspCode
==
TSDB_CODE_
INVALID_VNODE_ID
||
rspCode
==
TSDB_CODE_NOT_ACTIVE_VNODE
||
rspCode
==
TSDB_CODE_NETWORK_UNAVAIL
)
{
rspCode
==
TSDB_CODE_
NOT_ACTIVE_VNODE
||
rspCode
==
TSDB_CODE_INVALID_VNODE_ID
||
rspCode
==
TSDB_CODE_
TABLE_ID_MISMATCH
||
rspCode
==
TSDB_CODE_
NETWORK_UNAVAIL
)
{
#else
if
(
rspCode
==
TSDB_CODE_NOT_ACTIVE_TABLE
||
rspCode
==
TSDB_CODE_INVALID_TABLE_ID
||
rspCode
==
TSDB_CODE_
INVALID_VNODE_ID
||
rspCode
==
TSDB_CODE_NOT_ACTIVE_VNODE
||
rspCode
==
TSDB_CODE_NETWORK_UNAVAIL
)
{
rspCode
==
TSDB_CODE_
NOT_ACTIVE_VNODE
||
rspCode
==
TSDB_CODE_INVALID_VNODE_ID
||
rspCode
==
TSDB_CODE_
TABLE_ID_MISMATCH
||
rspCode
==
TSDB_CODE_
NETWORK_UNAVAIL
)
{
#endif
pSql
->
thandle
=
NULL
;
taosAddConnIntoCache
(
tscConnCache
,
thandle
,
pSql
->
ip
,
pSql
->
vnode
,
pObj
->
user
);
if
((
pCmd
->
command
==
TSDB_SQL_INSERT
||
pCmd
->
command
==
TSDB_SQL_SELECT
)
&&
(
rspCode
==
TSDB_CODE_INVALID_TABLE_ID
||
rspCode
==
TSDB_CODE_INVALID_VNODE_ID
))
{
/*
* In case of the insert/select operations, the invalid table(vnode) id means
* the submit/query msg is invalid, renew meter meta will not help to fix this problem,
* so return the invalid_query_msg to client directly.
*/
code
=
TSDB_CODE_INVALID_QUERY_MSG
;
}
else
if
(
pCmd
->
command
==
TSDB_SQL_CONNECT
)
{
if
(
pCmd
->
command
==
TSDB_SQL_CONNECT
)
{
code
=
TSDB_CODE_NETWORK_UNAVAIL
;
}
else
if
(
pCmd
->
command
==
TSDB_SQL_HB
)
{
code
=
TSDB_CODE_NOT_READY
;
...
...
@@ -1482,6 +1474,46 @@ static int32_t tscEstimateQueryMsgSize(SSqlCmd *pCmd) {
return
size
;
}
static
char
*
doSerializeTableInfo
(
SSqlObj
*
pSql
,
int32_t
numOfMeters
,
int32_t
vnodeId
,
char
*
pMsg
)
{
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
0
);
SMeterMeta
*
pMeterMeta
=
pMeterMetaInfo
->
pMeterMeta
;
SMetricMeta
*
pMetricMeta
=
pMeterMetaInfo
->
pMetricMeta
;
tscTrace
(
"%p vid:%d, query on %d meters"
,
pSql
,
htons
(
vnodeId
),
numOfMeters
);
if
(
UTIL_METER_IS_NOMRAL_METER
(
pMeterMetaInfo
))
{
#ifdef _DEBUG_VIEW
tscTrace
(
"%p sid:%d, uid:%lld"
,
pSql
,
pMeterMetaInfo
->
pMeterMeta
->
sid
,
pMeterMetaInfo
->
pMeterMeta
->
uid
);
#endif
SMeterSidExtInfo
*
pMeterInfo
=
(
SMeterSidExtInfo
*
)
pMsg
;
pMeterInfo
->
sid
=
htonl
(
pMeterMeta
->
sid
);
pMeterInfo
->
uid
=
htobe64
(
pMeterMeta
->
uid
);
pMsg
+=
sizeof
(
SMeterSidExtInfo
);
}
else
{
SVnodeSidList
*
pVnodeSidList
=
tscGetVnodeSidList
(
pMetricMeta
,
pMeterMetaInfo
->
vnodeIndex
);
for
(
int32_t
i
=
0
;
i
<
numOfMeters
;
++
i
)
{
SMeterSidExtInfo
*
pMeterInfo
=
(
SMeterSidExtInfo
*
)
pMsg
;
SMeterSidExtInfo
*
pQueryMeterInfo
=
tscGetMeterSidInfo
(
pVnodeSidList
,
i
);
pMeterInfo
->
sid
=
htonl
(
pQueryMeterInfo
->
sid
);
pMeterInfo
->
uid
=
htobe64
(
pQueryMeterInfo
->
uid
);
pMsg
+=
sizeof
(
SMeterSidExtInfo
);
memcpy
(
pMsg
,
pQueryMeterInfo
->
tags
,
pMetricMeta
->
tagLen
);
pMsg
+=
pMetricMeta
->
tagLen
;
#ifdef _DEBUG_VIEW
tscTrace
(
"%p sid:%d, uid:%lld"
,
pSql
,
pQueryMeterInfo
->
sid
,
pQueryMeterInfo
->
uid
);
#endif
}
}
return
pMsg
;
}
int
tscBuildQueryMsg
(
SSqlObj
*
pSql
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
...
...
@@ -1512,7 +1544,7 @@ int tscBuildQueryMsg(SSqlObj *pSql) {
pQueryMsg
->
vnode
=
htons
(
pMeterMeta
->
vpeerDesc
[
pMeterMeta
->
index
].
vnode
);
pQueryMsg
->
uid
=
pMeterMeta
->
uid
;
pQueryMsg
->
numOfTagsCols
=
0
;
}
else
{
// query on
metric
}
else
{
// query on
super table
if
(
pMeterMetaInfo
->
vnodeIndex
<
0
)
{
tscError
(
"%p error vnodeIdx:%d"
,
pSql
,
pMeterMetaInfo
->
vnodeIndex
);
return
-
1
;
...
...
@@ -1699,34 +1731,8 @@ int tscBuildQueryMsg(SSqlObj *pSql) {
pQueryMsg
->
colNameLen
=
htonl
(
len
);
// set sids list
tscTrace
(
"%p vid:%d, query on %d meters"
,
pSql
,
htons
(
pQueryMsg
->
vnode
),
numOfMeters
);
if
(
UTIL_METER_IS_NOMRAL_METER
(
pMeterMetaInfo
))
{
#ifdef _DEBUG_VIEW
tscTrace
(
"%p %d"
,
pSql
,
pMeterMetaInfo
->
pMeterMeta
->
sid
);
#endif
SMeterSidExtInfo
*
pSMeterTagInfo
=
(
SMeterSidExtInfo
*
)
pMsg
;
pSMeterTagInfo
->
sid
=
htonl
(
pMeterMeta
->
sid
);
pMsg
+=
sizeof
(
SMeterSidExtInfo
);
}
else
{
SVnodeSidList
*
pVnodeSidList
=
tscGetVnodeSidList
(
pMetricMeta
,
pMeterMetaInfo
->
vnodeIndex
);
for
(
int32_t
i
=
0
;
i
<
numOfMeters
;
++
i
)
{
SMeterSidExtInfo
*
pMeterTagInfo
=
(
SMeterSidExtInfo
*
)
pMsg
;
SMeterSidExtInfo
*
pQueryMeterInfo
=
tscGetMeterSidInfo
(
pVnodeSidList
,
i
);
pMeterTagInfo
->
sid
=
htonl
(
pQueryMeterInfo
->
sid
);
pMsg
+=
sizeof
(
SMeterSidExtInfo
);
#ifdef _DEBUG_VIEW
tscTrace
(
"%p %d"
,
pSql
,
pQueryMeterInfo
->
sid
);
#endif
memcpy
(
pMsg
,
pQueryMeterInfo
->
tags
,
pMetricMeta
->
tagLen
);
pMsg
+=
pMetricMeta
->
tagLen
;
}
}
// serialize the table info (sid, uid, tags)
pMsg
=
doSerializeTableInfo
(
pSql
,
numOfMeters
,
htons
(
pQueryMsg
->
vnode
),
pMsg
);
// only include the required tag column schema. If a tag is not required, it won't be sent to vnode
if
(
pMeterMetaInfo
->
numOfTags
>
0
)
{
...
...
@@ -2317,7 +2323,7 @@ int tscBuildCreateTableMsg(SSqlObj *pSql) {
size
=
tscEstimateCreateTableMsgLength
(
pSql
);
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
size
))
{
tscError
(
"%p failed to malloc for create table msg"
,
pSql
);
free
(
tmpData
);
free
(
tmpData
);
return
-
1
;
}
...
...
@@ -3228,44 +3234,47 @@ int tscProcessMetricMetaRsp(SSqlObj *pSql) {
size
+=
pMeta
->
numOfVnodes
*
sizeof
(
SVnodeSidList
*
)
+
pMeta
->
numOfMeters
*
sizeof
(
SMeterSidExtInfo
*
);
char
*
p
Str
=
calloc
(
1
,
size
);
if
(
p
Str
==
NULL
)
{
char
*
p
Buf
=
calloc
(
1
,
size
);
if
(
p
Buf
==
NULL
)
{
pSql
->
res
.
code
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
goto
_error_clean
;
}
SMetricMeta
*
pNewMetricMeta
=
(
SMetricMeta
*
)
p
Str
;
SMetricMeta
*
pNewMetricMeta
=
(
SMetricMeta
*
)
p
Buf
;
metricMetaList
[
k
]
=
pNewMetricMeta
;
pNewMetricMeta
->
numOfMeters
=
pMeta
->
numOfMeters
;
pNewMetricMeta
->
numOfVnodes
=
pMeta
->
numOfVnodes
;
pNewMetricMeta
->
tagLen
=
pMeta
->
tagLen
;
p
Str
=
pStr
+
sizeof
(
SMetricMeta
)
+
pNewMetricMeta
->
numOfVnodes
*
sizeof
(
SVnodeSidList
*
);
p
Buf
=
pBuf
+
sizeof
(
SMetricMeta
)
+
pNewMetricMeta
->
numOfVnodes
*
sizeof
(
SVnodeSidList
*
);
for
(
int32_t
i
=
0
;
i
<
pMeta
->
numOfVnodes
;
++
i
)
{
SVnodeSidList
*
pSidLists
=
(
SVnodeSidList
*
)
rsp
;
memcpy
(
p
Str
,
pSidLists
,
sizeof
(
SVnodeSidList
));
memcpy
(
p
Buf
,
pSidLists
,
sizeof
(
SVnodeSidList
));
pNewMetricMeta
->
list
[
i
]
=
p
Str
-
(
char
*
)
pNewMetricMeta
;
// offset value
SVnodeSidList
*
pLists
=
(
SVnodeSidList
*
)
p
Str
;
pNewMetricMeta
->
list
[
i
]
=
p
Buf
-
(
char
*
)
pNewMetricMeta
;
// offset value
SVnodeSidList
*
pLists
=
(
SVnodeSidList
*
)
p
Buf
;
tscTrace
(
"%p metricmeta:vid:%d,numOfMeters:%d"
,
pSql
,
i
,
pLists
->
numOfSids
);
p
Str
+=
sizeof
(
SVnodeSidList
)
+
sizeof
(
SMeterSidExtInfo
*
)
*
pSidLists
->
numOfSids
;
p
Buf
+=
sizeof
(
SVnodeSidList
)
+
sizeof
(
SMeterSidExtInfo
*
)
*
pSidLists
->
numOfSids
;
rsp
+=
sizeof
(
SVnodeSidList
);
size_t
sid
Size
=
sizeof
(
SMeterSidExtInfo
)
+
pNewMetricMeta
->
tagLen
;
size_t
elem
Size
=
sizeof
(
SMeterSidExtInfo
)
+
pNewMetricMeta
->
tagLen
;
for
(
int32_t
j
=
0
;
j
<
pSidLists
->
numOfSids
;
++
j
)
{
pLists
->
pSidExtInfoList
[
j
]
=
pStr
-
(
char
*
)
pLists
;
memcpy
(
pStr
,
rsp
,
sidSize
);
rsp
+=
sidSize
;
pStr
+=
sidSize
;
pLists
->
pSidExtInfoList
[
j
]
=
pBuf
-
(
char
*
)
pLists
;
memcpy
(
pBuf
,
rsp
,
elemSize
);
((
SMeterSidExtInfo
*
)
pBuf
)
->
uid
=
htobe64
(((
SMeterSidExtInfo
*
)
pBuf
)
->
uid
);
((
SMeterSidExtInfo
*
)
pBuf
)
->
sid
=
htonl
(((
SMeterSidExtInfo
*
)
pBuf
)
->
sid
);
rsp
+=
elemSize
;
pBuf
+=
elemSize
;
}
}
sizes
[
k
]
=
p
Str
-
(
char
*
)
pNewMetricMeta
;
sizes
[
k
]
=
p
Buf
-
(
char
*
)
pNewMetricMeta
;
}
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
...
...
src/inc/taoserror.h
浏览文件 @
ef6df509
...
...
@@ -136,8 +136,9 @@ extern "C" {
#define TSDB_CODE_INVALID_TABLE_ID 115
#define TSDB_CODE_INVALID_VNODE_STATUS 116
#define TSDB_CODE_FAILED_TO_LOCK_RESOURCES 117
#define TSDB_CODE_TABLE_ID_MISMATCH 118
#define TSDB_CODE_MAX_ERROR_CODE 11
8
#define TSDB_CODE_MAX_ERROR_CODE 11
9
#ifdef __cplusplus
}
...
...
src/inc/taosmsg.h
浏览文件 @
ef6df509
...
...
@@ -489,7 +489,7 @@ typedef struct SColumnInfo {
*/
typedef
struct
SMeterSidExtInfo
{
int32_t
sid
;
void
*
pObj
;
int64_t
uid
;
char
tags
[];
}
SMeterSidExtInfo
;
...
...
@@ -727,9 +727,7 @@ typedef struct {
int32_t
numOfMeters
;
int32_t
join
;
int32_t
joinCondLen
;
// for join condition
int32_t
metaElem
[
TSDB_MAX_JOIN_TABLE_NUM
];
}
SMetricMetaMsg
;
typedef
struct
{
...
...
src/inc/tsched.h
浏览文件 @
ef6df509
...
...
@@ -32,6 +32,8 @@ typedef struct _sched_msg {
void
*
taosInitScheduler
(
int
queueSize
,
int
numOfThreads
,
const
char
*
label
);
void
*
taosInitSchedulerWithInfo
(
int
queueSize
,
int
numOfThreads
,
const
char
*
label
,
void
*
tmrCtrl
);
int
taosScheduleTask
(
void
*
qhandle
,
SSchedMsg
*
pMsg
);
void
taosCleanUpScheduler
(
void
*
param
);
...
...
src/inc/tschemautil.h
浏览文件 @
ef6df509
...
...
@@ -53,7 +53,7 @@ char *tsGetTagsValue(SMeterMeta *pMeta);
bool
tsMeterMetaIdentical
(
SMeterMeta
*
p1
,
SMeterMeta
*
p2
);
void
extract
Meter
Name
(
char
*
meterId
,
char
*
name
);
void
extract
Table
Name
(
char
*
meterId
,
char
*
name
);
SSQLToken
extractDBName
(
char
*
meterId
,
char
*
name
);
...
...
src/rpc/src/tstring.c
浏览文件 @
ef6df509
...
...
@@ -238,8 +238,9 @@ char *tsError[] = {"success",
"only super table has metric meta info"
,
"tags value not unique for join"
,
"invalid submit message"
,
"not active table(not created yet or dropped already)"
,
//114
"invalid table id"
,
"invalid vnode status"
,
//116
"not active table(not created yet or dropped already)"
,
"invalid table id"
,
// 115
"invalid vnode status"
,
"failed to lock resources"
,
"table id/uid mismatch"
,
// 118
};
src/system/detail/inc/mgmtBalance.h
浏览文件 @
ef6df509
...
...
@@ -25,7 +25,7 @@ extern "C" {
#include "dnodeSystem.h"
#include "mgmt.h"
#include "tglobalcfg.h"
#include "
ts
tatus.h"
#include "
vnodeS
tatus.h"
#include "ttime.h"
void
mgmtCreateDnodeOrderList
();
...
...
src/system/detail/inc/vnode.h
浏览文件 @
ef6df509
...
...
@@ -64,15 +64,6 @@ enum _sync_cmd {
TSDB_SYNC_CMD_REMOVE
,
};
enum
_meter_state
{
TSDB_METER_STATE_READY
=
0x00
,
TSDB_METER_STATE_INSERT
=
0x01
,
TSDB_METER_STATE_IMPORTING
=
0x02
,
TSDB_METER_STATE_UPDATING
=
0x04
,
TSDB_METER_STATE_DELETING
=
0x10
,
TSDB_METER_STATE_DELETED
=
0x18
,
};
typedef
struct
{
int64_t
offset
:
48
;
int64_t
length
:
16
;
...
...
@@ -267,9 +258,7 @@ typedef struct SQuery {
int16_t
checkBufferInLoop
;
// check if the buffer is full during scan each block
SLimitVal
limit
;
int32_t
rowSize
;
int32_t
dataRowSize
;
// row size of each loaded data from disk, the value is
// used for prepare buffer
SSqlGroupbyExpr
*
pGroupbyExpr
;
SSqlFunctionExpr
*
pSelectExpr
;
SColumnInfoEx
*
colList
;
...
...
src/system/detail/inc/vnodeRead.h
浏览文件 @
ef6df509
...
...
@@ -40,6 +40,7 @@ typedef struct SQueryLoadBlockInfo {
int32_t
fileId
;
int32_t
slotIdx
;
int32_t
sid
;
bool
tsLoaded
;
// if timestamp column of current block is loaded or not
}
SQueryLoadBlockInfo
;
typedef
struct
SQueryLoadCompBlockInfo
{
...
...
src/
inc/ts
tatus.h
→
src/
system/detail/inc/vnodeS
tatus.h
浏览文件 @
ef6df509
...
...
@@ -78,15 +78,26 @@ enum _TSDB_VN_STREAM_STATUS {
TSDB_VN_STREAM_STATUS_START
};
const
char
*
taosGetVgroupStatusStr
(
int
vgroupStatus
);
const
char
*
taosGetDbStatusStr
(
int
dbStatus
);
const
char
*
taosGetVnodeStatusStr
(
int
vnodeStatus
);
const
char
*
taosGetVnodeSyncStatusStr
(
int
vnodeSyncStatus
);
const
char
*
taosGetVnodeDropStatusStr
(
int
dropping
);
const
char
*
taosGetDnodeStatusStr
(
int
dnodeStatus
);
const
char
*
taosGetDnodeLbStatusStr
(
int
dnodeBalanceStatus
);
const
char
*
taosGetVgroupLbStatusStr
(
int
vglbStatus
);
const
char
*
taosGetVnodeStreamStatusStr
(
int
vnodeStreamStatus
);
enum
TSDB_TABLE_STATUS
{
TSDB_METER_STATE_READY
=
0x00
,
TSDB_METER_STATE_INSERTING
=
0x01
,
TSDB_METER_STATE_IMPORTING
=
0x02
,
TSDB_METER_STATE_UPDATING
=
0x04
,
TSDB_METER_STATE_DROPPING
=
0x10
,
TSDB_METER_STATE_DROPPED
=
0x18
,
};
const
char
*
taosGetVgroupStatusStr
(
int32_t
vgroupStatus
);
const
char
*
taosGetDbStatusStr
(
int32_t
dbStatus
);
const
char
*
taosGetVnodeStatusStr
(
int32_t
vnodeStatus
);
const
char
*
taosGetVnodeSyncStatusStr
(
int32_t
vnodeSyncStatus
);
const
char
*
taosGetVnodeDropStatusStr
(
int32_t
dropping
);
const
char
*
taosGetDnodeStatusStr
(
int32_t
dnodeStatus
);
const
char
*
taosGetDnodeLbStatusStr
(
int32_t
dnodeBalanceStatus
);
const
char
*
taosGetVgroupLbStatusStr
(
int32_t
vglbStatus
);
const
char
*
taosGetVnodeStreamStatusStr
(
int32_t
vnodeStreamStatus
);
const
char
*
taosGetTableStatusStr
(
int32_t
tableStatus
);
#ifdef __cplusplus
}
...
...
src/system/detail/src/dnodeMgmt.c
浏览文件 @
ef6df509
...
...
@@ -26,7 +26,7 @@
#include "vnodeMgmt.h"
#include "vnodeSystem.h"
#include "vnodeUtil.h"
#include "
ts
tatus.h"
#include "
vnodeS
tatus.h"
SMgmtObj
mgmtObj
;
extern
uint64_t
tsCreatedTime
;
...
...
src/system/detail/src/mgmtDb.c
浏览文件 @
ef6df509
...
...
@@ -20,7 +20,7 @@
#include "mgmtBalance.h"
#include "mgmtUtil.h"
#include "tschemautil.h"
#include "
ts
tatus.h"
#include "
vnodeS
tatus.h"
void
*
dbSdb
=
NULL
;
int
tsDbUpdateSize
;
...
...
src/system/detail/src/mgmtDnode.c
浏览文件 @
ef6df509
...
...
@@ -20,8 +20,7 @@
#include "dnodeSystem.h"
#include "mgmt.h"
#include "tschemautil.h"
#include "tstatus.h"
#include "tstatus.h"
#include "vnodeStatus.h"
bool
mgmtCheckModuleInDnode
(
SDnodeObj
*
pDnode
,
int
moduleType
);
int
mgmtGetDnodesNum
();
...
...
src/system/detail/src/mgmtMeter.c
浏览文件 @
ef6df509
...
...
@@ -27,7 +27,7 @@
#include "tsqlfunction.h"
#include "ttime.h"
#include "vnodeTagMgmt.h"
#include "
ts
tatus.h"
#include "
vnodeS
tatus.h"
extern
int64_t
sdbVersion
;
...
...
@@ -984,6 +984,28 @@ SSchema *mgmtGetMeterSchema(STabObj *pMeter) {
return
(
SSchema
*
)
pMetric
->
schema
;
}
static
int32_t
mgmtSerializeTagValue
(
char
*
pMsg
,
STabObj
*
pMeter
,
int16_t
*
tagsId
,
int32_t
numOfTags
)
{
int32_t
offset
=
0
;
for
(
int32_t
j
=
0
;
j
<
numOfTags
;
++
j
)
{
if
(
tagsId
[
j
]
==
TSDB_TBNAME_COLUMN_INDEX
)
{
// handle the table name tags
char
name
[
TSDB_METER_NAME_LEN
]
=
{
0
};
extractTableName
(
pMeter
->
meterId
,
name
);
memcpy
(
pMsg
+
offset
,
name
,
TSDB_METER_NAME_LEN
);
offset
+=
TSDB_METER_NAME_LEN
;
}
else
{
SSchema
s
=
{
0
};
char
*
tag
=
mgmtMeterGetTag
(
pMeter
,
tagsId
[
j
],
&
s
);
memcpy
(
pMsg
+
offset
,
tag
,
(
size_t
)
s
.
bytes
);
offset
+=
s
.
bytes
;
}
}
return
offset
;
}
/*
* serialize SVnodeSidList to byte array
*/
...
...
@@ -996,7 +1018,6 @@ static char *mgmtBuildMetricMetaMsg(SConnObj *pConn, STabObj *pMeter, int32_t *o
* 1. the query msg may be larger than 64k,
* 2. the following meters belong to different vnodes
*/
(
*
pList
)
=
(
SVnodeSidList
*
)
pMsg
;
(
*
pList
)
->
numOfSids
=
0
;
(
*
pList
)
->
index
=
0
;
...
...
@@ -1020,29 +1041,15 @@ static char *mgmtBuildMetricMetaMsg(SConnObj *pConn, STabObj *pMeter, int32_t *o
(
*
pList
)
->
numOfSids
++
;
SMeterSidExtInfo
*
pSMeterTagInfo
=
(
SMeterSidExtInfo
*
)
pMsg
;
pSMeterTagInfo
->
sid
=
pMeter
->
gid
.
sid
;
pSMeterTagInfo
->
sid
=
htonl
(
pMeter
->
gid
.
sid
);
pSMeterTagInfo
->
uid
=
htobe64
(
pMeter
->
uid
);
pMsg
+=
sizeof
(
SMeterSidExtInfo
);
int32_t
offset
=
0
;
for
(
int32_t
j
=
0
;
j
<
numOfTags
;
++
j
)
{
if
(
tagsId
[
j
]
==
-
1
)
{
char
name
[
TSDB_METER_NAME_LEN
]
=
{
0
};
extractMeterName
(
pMeter
->
meterId
,
name
);
memcpy
(
pMsg
+
offset
,
name
,
TSDB_METER_NAME_LEN
);
offset
+=
TSDB_METER_NAME_LEN
;
}
else
{
SSchema
s
=
{
0
};
char
*
tag
=
mgmtMeterGetTag
(
pMeter
,
tagsId
[
j
],
&
s
);
memcpy
(
pMsg
+
offset
,
tag
,
(
size_t
)
s
.
bytes
);
offset
+=
s
.
bytes
;
}
}
pMsg
+=
offset
;
int32_t
offset
=
mgmtSerializeTagValue
(
pMsg
,
pMeter
,
tagsId
,
numOfTags
);
assert
(
offset
==
tagLen
);
pMsg
+=
offset
;
return
pMsg
;
}
...
...
@@ -1214,12 +1221,9 @@ int mgmtRetrieveMetricMeta(SConnObj *pConn, char **pStart, SMetricMetaMsg *pMetr
#endif
if
(
ret
==
TSDB_CODE_SUCCESS
)
{
// todo opt performance
for
(
int32_t
i
=
0
;
i
<
pMetricMetaMsg
->
numOfMeters
;
++
i
)
{
ret
=
mgmtRetrieveMetersFromMetric
(
pMetricMetaMsg
,
i
,
&
result
[
i
]);
// todo opt performance
// if (result[i].num <= 0) {//no result
// } else if (result[i].num < 10) {
// }
}
}
...
...
@@ -1287,7 +1291,7 @@ int mgmtRetrieveMeters(SShowObj *pShow, char *data, int rows, SConnObj *pConn) {
memset
(
meterName
,
0
,
tListLen
(
meterName
));
// pattern compare for meter name
extract
Meter
Name
(
pMeter
->
meterId
,
meterName
);
extract
Table
Name
(
pMeter
->
meterId
,
meterName
);
if
(
pShow
->
payloadLen
>
0
&&
patternMatch
(
pShow
->
payload
,
meterName
,
TSDB_METER_NAME_LEN
,
&
info
)
!=
TSDB_PATTERN_MATCH
)
...
...
@@ -1309,7 +1313,7 @@ int mgmtRetrieveMeters(SShowObj *pShow, char *data, int rows, SConnObj *pConn) {
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
if
(
pMeter
->
pTagData
)
{
extract
Meter
Name
(
pMeter
->
pTagData
,
pWrite
);
extract
Table
Name
(
pMeter
->
pTagData
,
pWrite
);
}
cols
++
;
...
...
@@ -1393,7 +1397,7 @@ int mgmtRetrieveMetrics(SShowObj *pShow, char *data, int rows, SConnObj *pConn)
pShow
->
pNode
=
(
void
*
)
pMetric
->
next
;
memset
(
metricName
,
0
,
tListLen
(
metricName
));
extract
Meter
Name
(
pMetric
->
meterId
,
metricName
);
extract
Table
Name
(
pMetric
->
meterId
,
metricName
);
if
(
pShow
->
payloadLen
>
0
&&
patternMatch
(
pShow
->
payload
,
metricName
,
TSDB_METER_NAME_LEN
,
&
info
)
!=
TSDB_PATTERN_MATCH
)
...
...
@@ -1402,7 +1406,7 @@ int mgmtRetrieveMetrics(SShowObj *pShow, char *data, int rows, SConnObj *pConn)
cols
=
0
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
extract
Meter
Name
(
pMetric
->
meterId
,
pWrite
);
extract
Table
Name
(
pMetric
->
meterId
,
pWrite
);
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
...
...
src/system/detail/src/mgmtShell.c
浏览文件 @
ef6df509
...
...
@@ -21,7 +21,7 @@
#include "mgmtProfile.h"
#include "taosmsg.h"
#include "tlog.h"
#include "
ts
tatus.h"
#include "
vnodeS
tatus.h"
#define MAX_LEN_OF_METER_META (sizeof(SMultiMeterMeta) + sizeof(SSchema) * TSDB_MAX_COLUMNS + sizeof(SSchema) * TSDB_MAX_TAGS + TSDB_MAX_TAGS_LEN)
...
...
src/system/detail/src/mgmtSupertableQuery.c
浏览文件 @
ef6df509
...
...
@@ -196,7 +196,7 @@ static bool mgmtTablenameFilterCallback(tSkipListNode* pNode, void* param) {
// pattern compare for meter name
STabObj
*
pMeterObj
=
(
STabObj
*
)
pNode
->
pData
;
extract
Meter
Name
(
pMeterObj
->
meterId
,
name
);
extract
Table
Name
(
pMeterObj
->
meterId
,
name
);
return
patternMatch
(
pSupporter
->
pattern
,
name
,
TSDB_METER_ID_LEN
,
&
pSupporter
->
info
)
==
TSDB_PATTERN_MATCH
;
}
...
...
@@ -786,7 +786,7 @@ int mgmtRetrieveMetersFromMetric(SMetricMetaMsg* pMsg, int32_t tableIndex, tQuer
// todo refactor!!!!!
static
char
*
getTagValueFromMeter
(
STabObj
*
pMeter
,
int32_t
offset
,
int32_t
len
,
char
*
param
)
{
if
(
offset
==
TSDB_TBNAME_COLUMN_INDEX
)
{
extract
Meter
Name
(
pMeter
->
meterId
,
param
);
extract
Table
Name
(
pMeter
->
meterId
,
param
);
}
else
{
char
*
tags
=
pMeter
->
pTagData
+
offset
+
TSDB_METER_ID_LEN
;
// tag start position
memcpy
(
param
,
tags
,
len
);
// make sure the value is null-terminated string
...
...
src/system/detail/src/mgmtVgroup.c
浏览文件 @
ef6df509
...
...
@@ -19,7 +19,7 @@
#include "mgmt.h"
#include "tschemautil.h"
#include "tlog.h"
#include "
ts
tatus.h"
#include "
vnodeS
tatus.h"
void
*
vgSdb
=
NULL
;
int
tsVgUpdateSize
;
...
...
src/system/detail/src/vnodeCache.c
浏览文件 @
ef6df509
...
...
@@ -20,7 +20,7 @@
#include "vnode.h"
#include "vnodeCache.h"
#include "vnodeUtil.h"
#include "
ts
tatus.h"
#include "
vnodeS
tatus.h"
void
vnodeSearchPointInCache
(
SMeterObj
*
pObj
,
SQuery
*
pQuery
);
void
vnodeProcessCommitTimer
(
void
*
param
,
void
*
tmrId
);
...
...
src/system/detail/src/vnodeCommit.c
浏览文件 @
ef6df509
...
...
@@ -19,6 +19,7 @@
#include "tsdb.h"
#include "vnode.h"
#include "vnodeUtil.h"
#include "vnodeStatus.h"
typedef
struct
{
int
sversion
;
...
...
@@ -165,7 +166,7 @@ size_t vnodeRestoreDataFromLog(int vnode, char *fileName, uint64_t *firstV) {
continue
;
}
if
(
vnodeIsMeterState
(
pObj
,
TSDB_METER_STATE_D
ELET
ING
))
{
if
(
vnodeIsMeterState
(
pObj
,
TSDB_METER_STATE_D
ROPP
ING
))
{
dWarn
(
"vid:%d sid:%d id:%s, meter is dropped, ignore data in commit log, contLen:%d action:%d"
,
vnode
,
head
.
sid
,
head
.
contLen
,
head
.
action
);
continue
;
...
...
src/system/detail/src/vnodeFile.c
浏览文件 @
ef6df509
...
...
@@ -21,6 +21,7 @@
#include "vnode.h"
#include "vnodeFile.h"
#include "vnodeUtil.h"
#include "vnodeStatus.h"
#define FILE_QUERY_NEW_BLOCK -5 // a special negative number
...
...
@@ -611,7 +612,7 @@ _again:
}
// meter is going to be deleted, abort
if
(
vnodeIsMeterState
(
pObj
,
TSDB_METER_STATE_D
ELET
ING
))
{
if
(
vnodeIsMeterState
(
pObj
,
TSDB_METER_STATE_D
ROPP
ING
))
{
dWarn
(
"vid:%d sid:%d is dropped, ignore this meter"
,
vnode
,
sid
);
continue
;
}
...
...
src/system/detail/src/vnodeImport.c
浏览文件 @
ef6df509
...
...
@@ -18,6 +18,7 @@
#include "vnode.h"
#include "vnodeUtil.h"
#include "vnodeStatus.h"
extern
void
vnodeGetHeadTname
(
char
*
nHeadName
,
char
*
nLastName
,
int
vnode
,
int
fileId
);
extern
int
vnodeReadColumnToMem
(
int
fd
,
SCompBlock
*
pBlock
,
SField
**
fields
,
int
col
,
char
*
data
,
int
dataSize
,
...
...
src/system/detail/src/vnodeMeter.c
浏览文件 @
ef6df509
...
...
@@ -24,7 +24,7 @@
#include "vnodeMgmt.h"
#include "vnodeShell.h"
#include "vnodeUtil.h"
#include "
ts
tatus.h"
#include "
vnodeS
tatus.h"
#define VALID_TIMESTAMP(key, curKey, prec) (((key) >= 0) && ((key) <= ((curKey) + 36500 * tsMsPerDay[prec])))
...
...
@@ -520,7 +520,7 @@ int vnodeRemoveMeterObj(int vnode, int sid) {
}
// after remove this meter, change its state to DELETED
pObj
->
state
=
TSDB_METER_STATE_D
ELET
ED
;
pObj
->
state
=
TSDB_METER_STATE_D
ROPP
ED
;
pObj
->
timeStamp
=
taosGetTimestampMs
();
vnodeList
[
vnode
].
lastRemove
=
pObj
->
timeStamp
;
...
...
@@ -612,12 +612,12 @@ int vnodeInsertPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi
return
TSDB_CODE_TIMESTAMP_OUT_OF_RANGE
;
}
if
((
code
=
vnodeSetMeterInsertImportStateEx
(
pObj
,
TSDB_METER_STATE_INSERT
))
!=
TSDB_CODE_SUCCESS
)
{
if
((
code
=
vnodeSetMeterInsertImportStateEx
(
pObj
,
TSDB_METER_STATE_INSERT
ING
))
!=
TSDB_CODE_SUCCESS
)
{
goto
_over
;
}
for
(
i
=
0
;
i
<
numOfPoints
;
++
i
)
{
// meter will be dropped, abort current insertion
if
(
vnodeIsMeterState
(
pObj
,
TSDB_METER_STATE_D
ELET
ING
))
{
if
(
vnodeIsMeterState
(
pObj
,
TSDB_METER_STATE_D
ROPP
ING
))
{
dWarn
(
"vid:%d sid:%d id:%s, meter is dropped, abort insert, state:%d"
,
pObj
->
vnode
,
pObj
->
sid
,
pObj
->
meterId
,
pObj
->
state
);
...
...
@@ -660,7 +660,7 @@ int vnodeInsertPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi
pthread_mutex_unlock
(
&
(
pVnode
->
vmutex
));
vnodeClearMeterState
(
pObj
,
TSDB_METER_STATE_INSERT
);
vnodeClearMeterState
(
pObj
,
TSDB_METER_STATE_INSERT
ING
);
_over:
dTrace
(
"vid:%d sid:%d id:%s, %d out of %d points are inserted, lastKey:%ld source:%d, vnode total storage: %ld"
,
...
...
@@ -726,7 +726,7 @@ void vnodeUpdateMeter(void *param, void *tmrId) {
}
SMeterObj
*
pObj
=
pVnode
->
meterList
[
pNew
->
sid
];
if
(
pObj
==
NULL
||
vnodeIsMeterState
(
pObj
,
TSDB_METER_STATE_D
ELET
ING
))
{
if
(
pObj
==
NULL
||
vnodeIsMeterState
(
pObj
,
TSDB_METER_STATE_D
ROPP
ING
))
{
dTrace
(
"vid:%d sid:%d id:%s, meter is deleted, abort update schema"
,
pNew
->
vnode
,
pNew
->
sid
,
pNew
->
meterId
);
free
(
pNew
->
schema
);
free
(
pNew
);
...
...
@@ -734,7 +734,7 @@ void vnodeUpdateMeter(void *param, void *tmrId) {
}
int32_t
state
=
vnodeSetMeterState
(
pObj
,
TSDB_METER_STATE_UPDATING
);
if
(
state
>=
TSDB_METER_STATE_D
ELET
ING
)
{
if
(
state
>=
TSDB_METER_STATE_D
ROPP
ING
)
{
dError
(
"vid:%d sid:%d id:%s, meter is deleted, failed to update, state:%d"
,
pObj
->
vnode
,
pObj
->
sid
,
pObj
->
meterId
,
state
);
return
;
...
...
src/system/detail/src/vnodeQueryImpl.c
浏览文件 @
ef6df509
此差异已折叠。
点击以展开。
src/system/detail/src/vnodeRead.c
浏览文件 @
ef6df509
...
...
@@ -193,8 +193,6 @@ static SQInfo *vnodeAllocateQInfoCommon(SQueryMeterMsg *pQueryMsg, SMeterObj *pM
}
else
{
pQuery
->
colList
[
i
].
data
.
filters
=
NULL
;
}
pQuery
->
dataRowSize
+=
colList
[
i
].
bytes
;
}
vnodeUpdateQueryColumnIndex
(
pQuery
,
pMeterObj
);
...
...
@@ -1099,10 +1097,12 @@ int32_t vnodeConvertQueryMeterMsg(SQueryMeterMsg *pQueryMsg) {
pSids
[
0
]
=
(
SMeterSidExtInfo
*
)
pMsg
;
pSids
[
0
]
->
sid
=
htonl
(
pSids
[
0
]
->
sid
);
pSids
[
0
]
->
uid
=
htobe64
(
pSids
[
0
]
->
uid
);
for
(
int32_t
j
=
1
;
j
<
pQueryMsg
->
numOfSids
;
++
j
)
{
pSids
[
j
]
=
(
SMeterSidExtInfo
*
)((
char
*
)
pSids
[
j
-
1
]
+
sizeof
(
SMeterSidExtInfo
)
+
pQueryMsg
->
tagLength
);
pSids
[
j
]
->
sid
=
htonl
(
pSids
[
j
]
->
sid
);
pSids
[
j
]
->
uid
=
htobe64
(
pSids
[
j
]
->
uid
);
}
pMsg
=
(
char
*
)
pSids
[
pQueryMsg
->
numOfSids
-
1
];
...
...
src/system/detail/src/vnodeShell.c
浏览文件 @
ef6df509
...
...
@@ -28,7 +28,7 @@
#include "vnodeRead.h"
#include "vnodeUtil.h"
#include "vnodeStore.h"
#include "
ts
tatus.h"
#include "
vnodeS
tatus.h"
extern
int
tsMaxQueues
;
...
...
@@ -295,7 +295,7 @@ int vnodeProcessQueryRequest(char *pMsg, int msgLen, SShellObj *pObj) {
}
if
(
pQueryMsg
->
vnode
>=
TSDB_MAX_VNODES
||
pQueryMsg
->
vnode
<
0
)
{
d
Trace
(
"qmsg:%p,vid:%d is out of range"
,
pQueryMsg
,
pQueryMsg
->
vnode
);
d
Error
(
"qmsg:%p,vid:%d is out of range"
,
pQueryMsg
,
pQueryMsg
->
vnode
);
code
=
TSDB_CODE_INVALID_TABLE_ID
;
goto
_query_over
;
}
...
...
@@ -310,28 +310,27 @@ int vnodeProcessQueryRequest(char *pMsg, int msgLen, SShellObj *pObj) {
}
if
(
!
(
pVnode
->
accessState
&
TSDB_VN_READ_ACCCESS
))
{
dError
(
"qmsg:%p,vid:%d access not allowed"
,
pQueryMsg
,
pQueryMsg
->
vnode
);
code
=
TSDB_CODE_NO_READ_ACCESS
;
goto
_query_over
;
}
if
(
pQueryMsg
->
pSidExtInfo
==
0
)
{
dTrace
(
"qmsg:%p,SQueryMeterMsg wrong format"
,
pQueryMsg
);
code
=
TSDB_CODE_INVALID_QUERY_MSG
;
goto
_query_over
;
}
if
(
pVnode
->
meterList
==
NULL
)
{
dError
(
"qmsg:%p,vid:%d has been closed"
,
pQueryMsg
,
pQueryMsg
->
vnode
);
code
=
TSDB_CODE_NOT_ACTIVE_VNODE
;
goto
_query_over
;
}
if
(
pQueryMsg
->
pSidExtInfo
==
0
)
{
dError
(
"qmsg:%p,SQueryMeterMsg wrong format"
,
pQueryMsg
);
code
=
TSDB_CODE_INVALID_QUERY_MSG
;
goto
_query_over
;
}
pSids
=
(
SMeterSidExtInfo
**
)
pQueryMsg
->
pSidExtInfo
;
for
(
int32_t
i
=
0
;
i
<
pQueryMsg
->
numOfSids
;
++
i
)
{
if
(
pSids
[
i
]
->
sid
>=
pVnode
->
cfg
.
maxSessions
||
pSids
[
i
]
->
sid
<
0
)
{
dTrace
(
"qmsg:%p sid:%d is out of range, valid range:[%d,%d]"
,
pQueryMsg
,
pSids
[
i
]
->
sid
,
0
,
pVnode
->
cfg
.
maxSessions
);
dError
(
"qmsg:%p sid:%d out of range, valid range:[%d,%d]"
,
pQueryMsg
,
pSids
[
i
]
->
sid
,
0
,
pVnode
->
cfg
.
maxSessions
);
code
=
TSDB_CODE_INVALID_TABLE_ID
;
goto
_query_over
;
}
...
...
src/
util/src/ts
tatus.c
→
src/
system/detail/src/vnodeS
tatus.c
浏览文件 @
ef6df509
...
...
@@ -15,9 +15,9 @@
#include "taosmsg.h"
#include "tsdb.h"
#include "
ts
tatus.h"
#include "
vnodeS
tatus.h"
const
char
*
taosGetVgroupStatusStr
(
int
vgroupStatus
)
{
const
char
*
taosGetVgroupStatusStr
(
int
32_t
vgroupStatus
)
{
switch
(
vgroupStatus
)
{
case
TSDB_VG_STATUS_READY
:
return
"ready"
;
case
TSDB_VG_STATUS_IN_PROGRESS
:
return
"inprogress"
;
...
...
@@ -28,7 +28,7 @@ const char* taosGetVgroupStatusStr(int vgroupStatus) {
}
}
const
char
*
taosGetDbStatusStr
(
int
dbStatus
)
{
const
char
*
taosGetDbStatusStr
(
int
32_t
dbStatus
)
{
switch
(
dbStatus
)
{
case
TSDB_DB_STATUS_READY
:
return
"ready"
;
case
TSDB_DB_STATUS_DROPPING
:
return
"dropping"
;
...
...
@@ -37,7 +37,7 @@ const char* taosGetDbStatusStr(int dbStatus) {
}
}
const
char
*
taosGetVnodeStatusStr
(
int
vnodeStatus
)
{
const
char
*
taosGetVnodeStatusStr
(
int
32_t
vnodeStatus
)
{
switch
(
vnodeStatus
)
{
case
TSDB_VN_STATUS_OFFLINE
:
return
"offline"
;
case
TSDB_VN_STATUS_CREATING
:
return
"creating"
;
...
...
@@ -50,7 +50,7 @@ const char* taosGetVnodeStatusStr(int vnodeStatus) {
}
}
const
char
*
taosGetVnodeSyncStatusStr
(
int
vnodeSyncStatus
)
{
const
char
*
taosGetVnodeSyncStatusStr
(
int
32_t
vnodeSyncStatus
)
{
switch
(
vnodeSyncStatus
)
{
case
TSDB_VN_SYNC_STATUS_INIT
:
return
"init"
;
case
TSDB_VN_SYNC_STATUS_SYNCING
:
return
"syncing"
;
...
...
@@ -60,7 +60,7 @@ const char* taosGetVnodeSyncStatusStr(int vnodeSyncStatus) {
}
}
const
char
*
taosGetVnodeDropStatusStr
(
int
dropping
)
{
const
char
*
taosGetVnodeDropStatusStr
(
int
32_t
dropping
)
{
switch
(
dropping
)
{
case
TSDB_VN_DROP_STATUS_READY
:
return
"ready"
;
case
TSDB_VN_DROP_STATUS_DROPPING
:
return
"dropping"
;
...
...
@@ -68,7 +68,7 @@ const char* taosGetVnodeDropStatusStr(int dropping) {
}
}
const
char
*
taosGetDnodeStatusStr
(
int
dnodeStatus
)
{
const
char
*
taosGetDnodeStatusStr
(
int
32_t
dnodeStatus
)
{
switch
(
dnodeStatus
)
{
case
TSDB_DN_STATUS_OFFLINE
:
return
"offline"
;
case
TSDB_DN_STATUS_READY
:
return
"ready"
;
...
...
@@ -76,7 +76,7 @@ const char* taosGetDnodeStatusStr(int dnodeStatus) {
}
}
const
char
*
taosGetDnodeLbStatusStr
(
int
dnodeBalanceStatus
)
{
const
char
*
taosGetDnodeLbStatusStr
(
int
32_t
dnodeBalanceStatus
)
{
switch
(
dnodeBalanceStatus
)
{
case
TSDB_DN_LB_STATUS_BALANCED
:
return
"balanced"
;
case
TSDB_DN_LB_STATUS_BALANCING
:
return
"balancing"
;
...
...
@@ -86,7 +86,7 @@ const char* taosGetDnodeLbStatusStr(int dnodeBalanceStatus) {
}
}
const
char
*
taosGetVgroupLbStatusStr
(
int
vglbStatus
)
{
const
char
*
taosGetVgroupLbStatusStr
(
int
32_t
vglbStatus
)
{
switch
(
vglbStatus
)
{
case
TSDB_VG_LB_STATUS_READY
:
return
"ready"
;
case
TSDB_VG_LB_STATUS_UPDATE
:
return
"updating"
;
...
...
@@ -94,10 +94,22 @@ const char* taosGetVgroupLbStatusStr(int vglbStatus) {
}
}
const
char
*
taosGetVnodeStreamStatusStr
(
int
vnodeStreamStatus
)
{
const
char
*
taosGetVnodeStreamStatusStr
(
int
32_t
vnodeStreamStatus
)
{
switch
(
vnodeStreamStatus
)
{
case
TSDB_VN_STREAM_STATUS_START
:
return
"start"
;
case
TSDB_VN_STREAM_STATUS_STOP
:
return
"stop"
;
default:
return
"undefined"
;
}
}
const
char
*
taosGetTableStatusStr
(
int32_t
tableStatus
)
{
switch
(
tableStatus
)
{
case
TSDB_METER_STATE_INSERTING
:
return
"inserting"
;
case
TSDB_METER_STATE_IMPORTING
:
return
"importing"
;
case
TSDB_METER_STATE_UPDATING
:
return
"updating"
;
case
TSDB_METER_STATE_DROPPING
:
return
"deleting"
;
case
TSDB_METER_STATE_DROPPED
:
return
"dropped"
;
case
TSDB_METER_STATE_READY
:
return
"ready"
;
default:
return
"undefined"
;
}
}
src/system/detail/src/vnodeStore.c
浏览文件 @
ef6df509
...
...
@@ -22,7 +22,7 @@
#include "vnode.h"
#include "vnodeStore.h"
#include "vnodeUtil.h"
#include "
ts
tatus.h"
#include "
vnodeS
tatus.h"
int
tsMaxVnode
=
-
1
;
int
tsOpenVnodes
=
0
;
...
...
@@ -118,7 +118,7 @@ static int32_t vnodeMarkAllMetersDropped(SVnodeObj* pVnode) {
}
else
{
// set the meter is to be deleted
SMeterObj
*
pObj
=
pVnode
->
meterList
[
sid
];
if
(
pObj
!=
NULL
)
{
pObj
->
state
=
TSDB_METER_STATE_D
ELET
ED
;
pObj
->
state
=
TSDB_METER_STATE_D
ROPP
ED
;
}
}
}
...
...
src/system/detail/src/vnodeStream.c
浏览文件 @
ef6df509
...
...
@@ -17,7 +17,7 @@
#include "taosmsg.h"
#include "vnode.h"
#include "vnodeUtil.h"
#include "
ts
tatus.h"
#include "
vnodeS
tatus.h"
/* static TAOS *dbConn = NULL; */
void
vnodeCloseStreamCallback
(
void
*
param
);
...
...
@@ -86,7 +86,7 @@ void vnodeOpenStreams(void *param, void *tmrId) {
for
(
int
sid
=
0
;
sid
<
pVnode
->
cfg
.
maxSessions
;
++
sid
)
{
pObj
=
pVnode
->
meterList
[
sid
];
if
(
pObj
==
NULL
||
pObj
->
sqlLen
==
0
||
vnodeIsMeterState
(
pObj
,
TSDB_METER_STATE_D
ELET
ING
))
continue
;
if
(
pObj
==
NULL
||
pObj
->
sqlLen
==
0
||
vnodeIsMeterState
(
pObj
,
TSDB_METER_STATE_D
ROPP
ING
))
continue
;
dTrace
(
"vid:%d sid:%d id:%s, open stream:%s"
,
pObj
->
vnode
,
sid
,
pObj
->
meterId
,
pObj
->
pSql
);
...
...
src/system/detail/src/vnodeSystem.c
浏览文件 @
ef6df509
...
...
@@ -36,8 +36,14 @@ void vnodeCleanUpSystem() {
bool
vnodeInitQueryHandle
()
{
int
numOfThreads
=
tsRatioOfQueryThreads
*
tsNumOfCores
*
tsNumOfThreadsPerCore
;
if
(
numOfThreads
<
1
)
numOfThreads
=
1
;
queryQhandle
=
taosInitScheduler
(
tsNumOfVnodesPerCore
*
tsNumOfCores
*
tsSessionsPerVnode
,
numOfThreads
,
"query"
);
if
(
numOfThreads
<
1
)
{
numOfThreads
=
1
;
}
int32_t
maxQueueSize
=
tsNumOfVnodesPerCore
*
tsNumOfCores
*
tsSessionsPerVnode
;
dTrace
(
"query task queue initialized, max slot:%d, task threads:%d"
,
maxQueueSize
,
numOfThreads
);
queryQhandle
=
taosInitSchedulerWithInfo
(
maxQueueSize
,
numOfThreads
,
"query"
,
vnodeTmrCtrl
);
return
true
;
}
...
...
@@ -52,15 +58,15 @@ bool vnodeInitTmrCtl() {
int
vnodeInitSystem
()
{
if
(
!
vnodeInitQueryHandle
())
{
dError
(
"failed to init query qhandle, exit"
);
return
-
1
;
}
if
(
!
vnodeInitTmrCtl
())
{
dError
(
"failed to init timer, exit"
);
return
-
1
;
}
if
(
!
vnodeInitQueryHandle
())
{
dError
(
"failed to init query qhandle, exit"
);
return
-
1
;
}
if
(
vnodeInitStore
()
<
0
)
{
dError
(
"failed to init vnode storage"
);
...
...
src/system/detail/src/vnodeUtil.c
浏览文件 @
ef6df509
...
...
@@ -22,6 +22,7 @@
#include "vnode.h"
#include "vnodeDataFilterFunc.h"
#include "vnodeUtil.h"
#include "vnodeStatus.h"
int
vnodeCheckFileIntegrity
(
FILE
*
fp
)
{
/*
...
...
@@ -547,30 +548,38 @@ int32_t vnodeIncQueryRefCount(SQueryMeterMsg* pQueryMsg, SMeterSidExtInfo** pSid
for
(
int32_t
i
=
0
;
i
<
pQueryMsg
->
numOfSids
;
++
i
)
{
SMeterObj
*
pMeter
=
pVnode
->
meterList
[
pSids
[
i
]
->
sid
];
if
(
pMeter
==
NULL
||
(
pMeter
->
state
>
TSDB_METER_STATE_INSERT
))
{
if
(
pMeter
==
NULL
||
vnodeIsMeterState
(
pMeter
,
TSDB_METER_STATE_DELETING
))
{
code
=
TSDB_CODE_NOT_ACTIVE_TABLE
;
dError
(
"qmsg:%p, vid:%d sid:%d, not there or will be dropped"
,
pQueryMsg
,
pQueryMsg
->
vnode
,
pSids
[
i
]
->
sid
);
vnodeSendMeterCfgMsg
(
pQueryMsg
->
vnode
,
pSids
[
i
]
->
sid
);
}
else
{
//update or import
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
dTrace
(
"qmsg:%p, vid:%d sid:%d id:%s, it is in state:%d, wait!"
,
pQueryMsg
,
pQueryMsg
->
vnode
,
pSids
[
i
]
->
sid
,
pMeter
->
meterId
,
pMeter
->
state
);
}
}
else
{
/*
* vnodeIsSafeToDeleteMeter will wait for this function complete, and then it can
* check if the numOfQueries is 0 or not.
*/
pMeterObjList
[(
*
numOfInc
)
++
]
=
pMeter
;
atomic_fetch_add_32
(
&
pMeter
->
numOfQueries
,
1
);
// output for meter more than one query executed
if
(
pMeter
->
numOfQueries
>
1
)
{
dTrace
(
"qmsg:%p, vid:%d sid:%d id:%s, inc query ref, numOfQueries:%d"
,
pQueryMsg
,
pMeter
->
vnode
,
pMeter
->
sid
,
pMeter
->
meterId
,
pMeter
->
numOfQueries
);
num
++
;
}
if
(
pMeter
==
NULL
||
vnodeIsMeterState
(
pMeter
,
TSDB_METER_STATE_DROPPING
))
{
code
=
TSDB_CODE_NOT_ACTIVE_TABLE
;
dError
(
"qmsg:%p, vid:%d sid:%d, not there or will be dropped"
,
pQueryMsg
,
pQueryMsg
->
vnode
,
pSids
[
i
]
->
sid
);
vnodeSendMeterCfgMsg
(
pQueryMsg
->
vnode
,
pSids
[
i
]
->
sid
);
continue
;
}
else
if
(
pMeter
->
uid
!=
pSids
[
i
]
->
uid
||
pMeter
->
sid
!=
pSids
[
i
]
->
sid
)
{
code
=
TSDB_CODE_TABLE_ID_MISMATCH
;
dError
(
"qmsg:%p, vid:%d sid:%d id:%s uid:%lld, id mismatch. sid:%d uid:%lld in msg"
,
pQueryMsg
,
pQueryMsg
->
vnode
,
pMeter
->
sid
,
pMeter
->
meterId
,
pMeter
->
uid
,
pSids
[
i
]
->
sid
,
pSids
[
i
]
->
uid
);
vnodeSendMeterCfgMsg
(
pQueryMsg
->
vnode
,
pSids
[
i
]
->
sid
);
continue
;
}
else
if
(
pMeter
->
state
>
TSDB_METER_STATE_INSERTING
)
{
//update or import
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
dTrace
(
"qmsg:%p, vid:%d sid:%d id:%s, it is in state:%s, wait!"
,
pQueryMsg
,
pQueryMsg
->
vnode
,
pSids
[
i
]
->
sid
,
pMeter
->
meterId
,
taosGetTableStatusStr
(
pMeter
->
state
));
continue
;
}
/*
* vnodeIsSafeToDeleteMeter will wait for this function complete, and then it can
* check if the numOfQueries is 0 or not.
*/
pMeterObjList
[(
*
numOfInc
)
++
]
=
pMeter
;
atomic_fetch_add_32
(
&
pMeter
->
numOfQueries
,
1
);
// output for meter more than one query executed
if
(
pMeter
->
numOfQueries
>
1
)
{
dTrace
(
"qmsg:%p, vid:%d sid:%d id:%s, inc query ref, numOfQueries:%d"
,
pQueryMsg
,
pMeter
->
vnode
,
pMeter
->
sid
,
pMeter
->
meterId
,
pMeter
->
numOfQueries
);
num
++
;
}
}
...
...
@@ -652,7 +661,7 @@ void vnodeClearMeterState(SMeterObj* pMeterObj, int32_t state) {
bool
vnodeIsMeterState
(
SMeterObj
*
pMeterObj
,
int32_t
state
)
{
if
(
state
==
TSDB_METER_STATE_READY
)
{
return
pMeterObj
->
state
==
TSDB_METER_STATE_READY
;
}
else
if
(
state
==
TSDB_METER_STATE_D
ELET
ING
)
{
}
else
if
(
state
==
TSDB_METER_STATE_D
ROPP
ING
)
{
return
pMeterObj
->
state
>=
state
;
}
else
{
return
(((
pMeterObj
->
state
)
&
state
)
==
state
);
...
...
@@ -664,7 +673,7 @@ void vnodeSetMeterDeleting(SMeterObj* pMeterObj) {
return
;
}
pMeterObj
->
state
|=
TSDB_METER_STATE_D
ELET
ING
;
pMeterObj
->
state
|=
TSDB_METER_STATE_D
ROPP
ING
;
}
int32_t
vnodeSetMeterInsertImportStateEx
(
SMeterObj
*
pObj
,
int32_t
st
)
{
...
...
@@ -672,7 +681,7 @@ int32_t vnodeSetMeterInsertImportStateEx(SMeterObj* pObj, int32_t st) {
int32_t
state
=
vnodeSetMeterState
(
pObj
,
st
);
if
(
state
!=
TSDB_METER_STATE_READY
)
{
//return to denote import is not performed
if
(
vnodeIsMeterState
(
pObj
,
TSDB_METER_STATE_D
ELET
ING
))
{
if
(
vnodeIsMeterState
(
pObj
,
TSDB_METER_STATE_D
ROPP
ING
))
{
dTrace
(
"vid:%d sid:%d id:%s, meter is deleted, state:%d"
,
pObj
->
vnode
,
pObj
->
sid
,
pObj
->
meterId
,
pObj
->
state
);
code
=
TSDB_CODE_NOT_ACTIVE_TABLE
;
...
...
@@ -690,17 +699,17 @@ int32_t vnodeSetMeterInsertImportStateEx(SMeterObj* pObj, int32_t st) {
bool
vnodeIsSafeToDeleteMeter
(
SVnodeObj
*
pVnode
,
int32_t
sid
)
{
SMeterObj
*
pObj
=
pVnode
->
meterList
[
sid
];
if
(
pObj
==
NULL
||
vnodeIsMeterState
(
pObj
,
TSDB_METER_STATE_D
ELET
ED
))
{
if
(
pObj
==
NULL
||
vnodeIsMeterState
(
pObj
,
TSDB_METER_STATE_D
ROPP
ED
))
{
return
true
;
}
int32_t
prev
=
vnodeSetMeterState
(
pObj
,
TSDB_METER_STATE_D
ELET
ING
);
int32_t
prev
=
vnodeSetMeterState
(
pObj
,
TSDB_METER_STATE_D
ROPP
ING
);
/*
* if the meter is not in ready/deleting state, it must be in insert/import/update,
* set the deleting state and wait the procedure to be completed
*/
if
(
prev
!=
TSDB_METER_STATE_READY
&&
prev
<
TSDB_METER_STATE_D
ELET
ING
)
{
if
(
prev
!=
TSDB_METER_STATE_READY
&&
prev
<
TSDB_METER_STATE_D
ROPP
ING
)
{
vnodeSetMeterDeleting
(
pObj
);
dWarn
(
"vid:%d sid:%d id:%s, can not be deleted, state:%d, wait"
,
pObj
->
vnode
,
pObj
->
sid
,
pObj
->
meterId
,
prev
);
...
...
@@ -710,7 +719,7 @@ bool vnodeIsSafeToDeleteMeter(SVnodeObj* pVnode, int32_t sid) {
bool
ready
=
true
;
/*
* the query will be stopped ASAP, since the state of meter is set to TSDB_METER_STATE_D
ELET
ING,
* the query will be stopped ASAP, since the state of meter is set to TSDB_METER_STATE_D
ROPP
ING,
* and new query will abort since the meter is deleted.
*/
pthread_mutex_lock
(
&
pVnode
->
vmutex
);
...
...
src/system/lite/src/mgmtBalance.spec.c
浏览文件 @
ef6df509
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "mgmtBalance.h"
#include "
ts
tatus.h"
#include "
vnodeS
tatus.h"
void
mgmtStartBalanceTimer
(
int64_t
mseconds
)
{}
...
...
src/system/lite/src/mgmtDnode.spec.c
浏览文件 @
ef6df509
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "mgmt.h"
#include "
ts
tatus.h"
#include "
vnodeS
tatus.h"
SDnodeObj
dnodeObj
;
extern
uint32_t
tsRebootTime
;
...
...
src/system/lite/src/mgmtDnodeInt.spec.c
浏览文件 @
ef6df509
...
...
@@ -23,7 +23,7 @@
#include "tutil.h"
#include "vnode.h"
#include "tsystem.h"
#include "
ts
tatus.h"
#include "
vnodeS
tatus.h"
extern
void
*
dmQhandle
;
void
*
mgmtStatusTimer
=
NULL
;
...
...
src/system/lite/src/vnodePeer.spec.c
浏览文件 @
ef6df509
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "vnode.h"
#include "
ts
tatus.h"
#include "
vnodeS
tatus.h"
int
vnodeInitPeer
(
int
numOfThreads
)
{
return
0
;
}
...
...
src/util/src/tsched.c
浏览文件 @
ef6df509
...
...
@@ -16,6 +16,9 @@
#include "os.h"
#include "tlog.h"
#include "tsched.h"
#include "ttimer.h"
#define DUMP_SCHEDULER_TIME_WINDOW 30000 //every 30sec, take a snap shot of task queue.
typedef
struct
{
char
label
[
16
];
...
...
@@ -28,10 +31,13 @@ typedef struct {
int
numOfThreads
;
pthread_t
*
qthread
;
SSchedMsg
*
queue
;
void
*
pTmrCtrl
;
void
*
pTimer
;
}
SSchedQueue
;
void
*
taosProcessSchedQueue
(
void
*
param
);
void
taosCleanUpScheduler
(
void
*
param
);
static
void
*
taosProcessSchedQueue
(
void
*
param
);
static
void
taosDumpSchedulerStatus
(
void
*
qhandle
,
void
*
tmrId
);
void
*
taosInitScheduler
(
int
queueSize
,
int
numOfThreads
,
const
char
*
label
)
{
pthread_attr_t
attr
;
...
...
@@ -96,6 +102,17 @@ _error:
return
NULL
;
}
void
*
taosInitSchedulerWithInfo
(
int
queueSize
,
int
numOfThreads
,
const
char
*
label
,
void
*
tmrCtrl
)
{
SSchedQueue
*
pSched
=
taosInitScheduler
(
queueSize
,
numOfThreads
,
label
);
if
(
tmrCtrl
!=
NULL
&&
pSched
!=
NULL
)
{
pSched
->
pTmrCtrl
=
tmrCtrl
;
taosTmrReset
(
taosDumpSchedulerStatus
,
DUMP_SCHEDULER_TIME_WINDOW
,
pSched
,
pSched
->
pTmrCtrl
,
&
pSched
->
pTimer
);
}
return
pSched
;
}
void
*
taosProcessSchedQueue
(
void
*
param
)
{
SSchedMsg
msg
;
SSchedQueue
*
pSched
=
(
SSchedQueue
*
)
param
;
...
...
@@ -173,8 +190,27 @@ void taosCleanUpScheduler(void *param) {
tsem_destroy
(
&
pSched
->
emptySem
);
tsem_destroy
(
&
pSched
->
fullSem
);
pthread_mutex_destroy
(
&
pSched
->
queueMutex
);
if
(
pSched
->
pTimer
)
{
taosTmrStopA
(
&
pSched
->
pTimer
);
}
free
(
pSched
->
queue
);
free
(
pSched
->
qthread
);
free
(
pSched
);
// fix memory leak
}
// for debug purpose, dump the scheduler status every 1min.
void
taosDumpSchedulerStatus
(
void
*
qhandle
,
void
*
tmrId
)
{
SSchedQueue
*
pSched
=
(
SSchedQueue
*
)
qhandle
;
if
(
pSched
==
NULL
||
pSched
->
pTimer
==
NULL
||
pSched
->
pTimer
!=
tmrId
)
{
return
;
}
int32_t
size
=
((
pSched
->
emptySlot
-
pSched
->
fullSlot
)
+
pSched
->
queueSize
)
%
pSched
->
queueSize
;
if
(
size
>
0
)
{
pTrace
(
"scheduler:%s, current tasks in queue:%d, task thread:%d"
,
pSched
->
label
,
size
,
pSched
->
numOfThreads
);
}
taosTmrReset
(
taosDumpSchedulerStatus
,
DUMP_SCHEDULER_TIME_WINDOW
,
pSched
,
pSched
->
pTmrCtrl
,
&
pSched
->
pTimer
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录