Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
05ce45e7
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看板
提交
05ce45e7
编写于
12月 17, 2019
作者:
H
hjxilinx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix the bugs in issue #932. [tbase-1353]
上级
14be1790
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
91 addition
and
64 deletion
+91
-64
src/client/src/tscServer.c
src/client/src/tscServer.c
+61
-44
src/inc/taoserror.h
src/inc/taoserror.h
+2
-1
src/inc/taosmsg.h
src/inc/taosmsg.h
+1
-3
src/rpc/src/tstring.c
src/rpc/src/tstring.c
+4
-3
src/system/detail/src/vnodeRead.c
src/system/detail/src/vnodeRead.c
+3
-1
src/system/detail/src/vnodeShell.c
src/system/detail/src/vnodeShell.c
+20
-12
未找到文件。
src/client/src/tscServer.c
浏览文件 @
05ce45e7
...
...
@@ -1482,6 +1482,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 +1552,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 +1739,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
)
{
...
...
@@ -3226,44 +3240,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
浏览文件 @
05ce45e7
...
...
@@ -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
浏览文件 @
05ce45e7
...
...
@@ -487,7 +487,7 @@ typedef struct SColumnInfo {
*/
typedef
struct
SMeterSidExtInfo
{
int32_t
sid
;
void
*
pObj
;
int64_t
uid
;
char
tags
[];
}
SMeterSidExtInfo
;
...
...
@@ -724,9 +724,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/rpc/src/tstring.c
浏览文件 @
05ce45e7
...
...
@@ -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/src/vnodeRead.c
浏览文件 @
05ce45e7
...
...
@@ -1097,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
浏览文件 @
05ce45e7
...
...
@@ -28,7 +28,7 @@
#include "vnodeRead.h"
#include "vnodeUtil.h"
#include "vnodeStore.h"
#include "
ts
tatus.h"
#include "
vnodeS
tatus.h"
extern
int
tsMaxQueues
;
...
...
@@ -297,7 +297,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
;
}
...
...
@@ -312,31 +312,39 @@ 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
;
}
SMeterObj
*
pMeterObj
=
pVnode
->
meterList
[
pSids
[
i
]
->
sid
];
if
(
pMeterObj
->
uid
!=
pSids
[
i
]
->
uid
||
pMeterObj
->
sid
!=
pSids
[
i
]
->
sid
)
{
// uid/sid not match, error in query msg
dError
(
"qmsg:%p sid/uid mismatch, vid:%d sid:%d id:%s uid:%"
", in msg sid:%d, uid:%lld"
,
pQueryMsg
,
pQueryMsg
->
vnode
,
pMeterObj
->
sid
,
pMeterObj
->
meterId
,
pMeterObj
->
uid
,
pSids
[
i
]
->
sid
,
pSids
[
i
]
->
uid
);
code
=
TSDB_CODE_TABLE_ID_MISMATCH
;
goto
_query_over
;
}
}
// todo optimize for single table query process
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录