Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4e8f3b5d
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
4e8f3b5d
编写于
8月 19, 2021
作者:
D
dapan1121
提交者:
GitHub
8月 19, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7416 from taosdata/hotfix/TD-6020
[TD-6020]fix taos crash issue
上级
3b896816
16fe1e27
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
50 addition
and
31 deletion
+50
-31
src/client/inc/tscSubquery.h
src/client/inc/tscSubquery.h
+6
-0
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+29
-22
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+15
-9
未找到文件。
src/client/inc/tscSubquery.h
浏览文件 @
4e8f3b5d
...
...
@@ -50,6 +50,12 @@ void tscUnlockByThread(int64_t *lockedBy);
int
tsInsertInitialCheck
(
SSqlObj
*
pSql
);
void
doCleanupSubqueries
(
SSqlObj
*
pSql
,
int32_t
numOfSubs
);
void
tscFreeRetrieveSup
(
SSqlObj
*
pSql
);
#ifdef __cplusplus
}
#endif
...
...
src/client/src/tscSubquery.c
浏览文件 @
4e8f3b5d
...
...
@@ -2034,17 +2034,14 @@ void tscHandleMasterJoinQuery(SSqlObj* pSql) {
tscAsyncResultOnError
(
pSql
);
}
static
void
doCleanupSubqueries
(
SSqlObj
*
pSql
,
int32_t
numOfSubs
)
{
void
doCleanupSubqueries
(
SSqlObj
*
pSql
,
int32_t
numOfSubs
)
{
assert
(
numOfSubs
<=
pSql
->
subState
.
numOfSub
&&
numOfSubs
>=
0
);
for
(
int32_t
i
=
0
;
i
<
numOfSubs
;
++
i
)
{
SSqlObj
*
pSub
=
pSql
->
pSubs
[
i
];
assert
(
pSub
!=
NULL
);
SRetrieveSupport
*
pSupport
=
pSub
->
param
;
tfree
(
pSupport
->
localBuffer
);
tfree
(
pSupport
);
tscFreeRetrieveSup
(
pSub
);
taos_free_result
(
pSub
);
}
...
...
@@ -2562,7 +2559,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
return
TSDB_CODE_SUCCESS
;
}
static
void
tscFreeRetrieveSup
(
SSqlObj
*
pSql
)
{
void
tscFreeRetrieveSup
(
SSqlObj
*
pSql
)
{
SRetrieveSupport
*
trsupport
=
pSql
->
param
;
void
*
p
=
atomic_val_compare_exchange_ptr
(
&
pSql
->
param
,
trsupport
,
0
);
...
...
@@ -2720,33 +2717,43 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
if
(
!
TSDB_QUERY_HAS_TYPE
(
pQueryInfo
->
type
,
TSDB_QUERY_TYPE_JOIN_SEC_STAGE
))
{
int32_t
code
=
pParentSql
->
res
.
code
;
if
((
code
==
TSDB_CODE_TDB_INVALID_TABLE_ID
||
code
==
TSDB_CODE_VND_INVALID_VGROUP_ID
)
&&
pParentSql
->
retry
<
pParentSql
->
maxRetry
)
{
// remove the cached tableMeta and vgroup id list, and then parse the sql again
SSqlCmd
*
pParentCmd
=
&
pParentSql
->
cmd
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
pParentCmd
,
0
);
tscRemoveTableMetaBuf
(
pTableMetaInfo
,
pParentSql
->
self
);
SSqlObj
*
userSql
=
NULL
;
if
(
pParentSql
->
param
)
{
userSql
=
((
SRetrieveSupport
*
)
pParentSql
->
param
)
->
pParentSql
;
}
pParentCmd
->
pTableMetaMap
=
tscCleanupTableMetaMap
(
pParentCmd
->
pTableMetaMap
);
pParentCmd
->
pTableMetaMap
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_NO_LOCK
);
if
(
userSql
==
NULL
)
{
userSql
=
pParentSql
;
}
if
((
code
==
TSDB_CODE_TDB_INVALID_TABLE_ID
||
code
==
TSDB_CODE_VND_INVALID_VGROUP_ID
)
&&
userSql
->
retry
<
userSql
->
maxRetry
)
{
if
(
userSql
!=
pParentSql
)
{
tscFreeRetrieveSup
(
pParentSql
);
}
pParentSql
->
res
.
code
=
TSDB_CODE_SUCCESS
;
pParentSql
->
retry
++
;
tscFreeSubobj
(
userSql
);
tfree
(
userSql
->
pSubs
)
;
tscDebug
(
"0x%"
PRIx64
" retry parse sql and send query, prev error: %s, retry:%d"
,
pParentSql
->
self
,
tstrerror
(
code
),
pParentSql
->
retry
)
;
userSql
->
res
.
code
=
TSDB_CODE_SUCCESS
;
userSql
->
retry
++
;
code
=
tsParseSql
(
pParentSql
,
true
);
tscDebug
(
"0x%"
PRIx64
" retry parse sql and send query, prev error: %s, retry:%d"
,
userSql
->
self
,
tstrerror
(
code
),
userSql
->
retry
);
tscResetSqlCmd
(
&
userSql
->
cmd
,
true
);
code
=
tsParseSql
(
userSql
,
true
);
if
(
code
==
TSDB_CODE_TSC_ACTION_IN_PROGRESS
)
{
return
;
}
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
pParent
Sql
->
res
.
code
=
code
;
tscAsyncResultOnError
(
pParent
Sql
);
user
Sql
->
res
.
code
=
code
;
tscAsyncResultOnError
(
user
Sql
);
return
;
}
executeQuery
(
pParentSql
,
pQueryInfo
);
pQueryInfo
=
tscGetQueryInfo
(
&
userSql
->
cmd
);
executeQuery
(
userSql
,
pQueryInfo
);
}
else
{
(
*
pParentSql
->
fp
)(
pParentSql
->
param
,
pParentSql
,
pParentSql
->
res
.
code
);
}
...
...
src/client/src/tscUtil.c
浏览文件 @
4e8f3b5d
...
...
@@ -3767,8 +3767,7 @@ static void tscSubqueryCompleteCallback(void* param, TAOS_RES* tres, int code) {
int32_t
index
=
ps
->
subqueryIndex
;
bool
ret
=
subAndCheckDone
(
pSql
,
pParentSql
,
index
);
tfree
(
ps
);
pSql
->
param
=
NULL
;
tscFreeRetrieveSup
(
pSql
);
if
(
!
ret
)
{
tscDebug
(
"0x%"
PRIx64
" sub:0x%"
PRIx64
" orderOfSub:%d completed, not all subquery finished"
,
pParentSql
->
self
,
pSql
->
self
,
index
);
...
...
@@ -3778,12 +3777,13 @@ static void tscSubqueryCompleteCallback(void* param, TAOS_RES* tres, int code) {
// todo refactor
tscDebug
(
"0x%"
PRIx64
" all subquery response received, retry"
,
pParentSql
->
self
);
SSqlCmd
*
pParentCmd
=
&
pParentSql
->
cmd
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
pParentCmd
,
0
);
tscRemoveTableMetaBuf
(
pTableMetaInfo
,
pParentSql
->
self
);
if
(
code
&&
!
((
code
==
TSDB_CODE_TDB_INVALID_TABLE_ID
||
code
==
TSDB_CODE_VND_INVALID_VGROUP_ID
)
&&
pParentSql
->
retry
<
pParentSql
->
maxRetry
))
{
tscAsyncResultOnError
(
pParentSql
);
return
;
}
pParentCmd
->
pTableMetaMap
=
tscCleanupTableMetaMap
(
pParentCmd
->
pTableMetaMap
);
pParentCmd
->
pTableMetaMap
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_NO_LOCK
);
tscFreeSubobj
(
pParentSql
);
tfree
(
pParentSql
->
pSubs
);
pParentSql
->
res
.
code
=
TSDB_CODE_SUCCESS
;
pParentSql
->
retry
++
;
...
...
@@ -3791,6 +3791,9 @@ static void tscSubqueryCompleteCallback(void* param, TAOS_RES* tres, int code) {
tscDebug
(
"0x%"
PRIx64
" retry parse sql and send query, prev error: %s, retry:%d"
,
pParentSql
->
self
,
tstrerror
(
code
),
pParentSql
->
retry
);
tscResetSqlCmd
(
&
pParentSql
->
cmd
,
true
);
code
=
tsParseSql
(
pParentSql
,
true
);
if
(
code
==
TSDB_CODE_TSC_ACTION_IN_PROGRESS
)
{
return
;
...
...
@@ -3802,7 +3805,8 @@ static void tscSubqueryCompleteCallback(void* param, TAOS_RES* tres, int code) {
return
;
}
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
pParentCmd
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
&
pParentSql
->
cmd
);
executeQuery
(
pParentSql
,
pQueryInfo
);
return
;
}
...
...
@@ -3825,9 +3829,11 @@ void executeQuery(SSqlObj* pSql, SQueryInfo* pQueryInfo) {
}
if
(
taosArrayGetSize
(
pQueryInfo
->
pUpstream
)
>
0
)
{
// nest query. do execute it firstly
assert
(
pSql
->
subState
.
numOfSub
==
0
);
pSql
->
subState
.
numOfSub
=
(
int32_t
)
taosArrayGetSize
(
pQueryInfo
->
pUpstream
);
assert
(
pSql
->
pSubs
==
NULL
);
pSql
->
pSubs
=
calloc
(
pSql
->
subState
.
numOfSub
,
POINTER_BYTES
);
assert
(
pSql
->
subState
.
states
==
NULL
);
pSql
->
subState
.
states
=
calloc
(
pSql
->
subState
.
numOfSub
,
sizeof
(
int8_t
));
code
=
pthread_mutex_init
(
&
pSql
->
subState
.
mutex
,
NULL
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录