Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4cbcf232
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
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看板
提交
4cbcf232
编写于
9月 16, 2022
作者:
B
Benguang Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: 1. let doCleanupSubqueries be idempotent
2. access pSql->subState.numOfSub in the same way
上级
5e918eaa
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
26 addition
and
39 deletion
+26
-39
src/client/inc/tscSubquery.h
src/client/inc/tscSubquery.h
+1
-1
src/client/src/tscDelete.c
src/client/src/tscDelete.c
+8
-14
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+17
-24
未找到文件。
src/client/inc/tscSubquery.h
浏览文件 @
4cbcf232
...
...
@@ -50,7 +50,7 @@ void tscUnlockByThread(int64_t *lockedBy);
int
tsInsertInitialCheck
(
SSqlObj
*
pSql
);
void
doCleanupSubqueries
(
SSqlObj
*
pSql
,
int32_t
numOfSubs
);
void
doCleanupSubqueries
(
SSqlObj
*
pSql
);
void
tscFreeRetrieveSup
(
void
**
param
);
...
...
src/client/src/tscDelete.c
浏览文件 @
4cbcf232
...
...
@@ -195,7 +195,6 @@ int32_t executeDelete(SSqlObj* pSql, SQueryInfo* pQueryInfo) {
return
TSDB_CODE_VND_INVALID_VGROUP_ID
;
}
SSubqueryState
*
pState
=
&
pSql
->
subState
;
int32_t
numOfSub
=
pTableMetaInfo
->
vgroupList
->
numOfVgroups
;
if
(
numOfSub
==
0
)
{
tscInfo
(
":CDEL SQL:%p tablename=%s numOfVgroups is zero, maybe empty table."
,
pSql
,
pTableMetaInfo
->
name
.
tname
);
...
...
@@ -203,16 +202,16 @@ int32_t executeDelete(SSqlObj* pSql, SQueryInfo* pQueryInfo) {
}
ret
=
doReInitSubState
(
pSql
,
numOfSub
);
if
(
ret
!=
0
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
tscAsyncResultOnError
(
pSql
);
return
ret
;
}
tscDebug
(
"0x%"
PRIx64
":CDEL retrieved query data from %d vnode(s)"
,
pSql
->
self
,
pS
tate
->
numOfSub
);
tscDebug
(
"0x%"
PRIx64
":CDEL retrieved query data from %d vnode(s)"
,
pSql
->
self
,
pS
ql
->
subState
.
numOfSub
);
pRes
->
code
=
TSDB_CODE_SUCCESS
;
int32_t
i
;
for
(
i
=
0
;
i
<
pS
tate
->
numOfSub
;
++
i
)
{
for
(
i
=
0
;
i
<
pS
ql
->
subState
.
numOfSub
;
++
i
)
{
// vgroup
SVgroupMsg
*
pVgroupMsg
=
&
pTableMetaInfo
->
vgroupList
->
vgroups
[
i
];
...
...
@@ -234,23 +233,18 @@ int32_t executeDelete(SSqlObj* pSql, SQueryInfo* pQueryInfo) {
}
pSql
->
pSubs
[
i
]
=
pNew
;
}
if
(
i
<
pS
tate
->
numOfSub
)
{
if
(
i
<
pS
ql
->
subState
.
numOfSub
)
{
tscError
(
"0x%"
PRIx64
":CDEL failed to prepare subdelete structure and launch subqueries"
,
pSql
->
self
);
pRes
->
code
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
doCleanupSubqueries
(
pSql
,
i
);
return
pRes
->
code
;
// free all allocated resource
}
if
(
pRes
->
code
==
TSDB_CODE_TSC_QUERY_CANCELLED
)
{
doCleanupSubqueries
(
pSql
,
i
);
if
(
pRes
->
code
!=
TSDB_CODE_SUCCESS
)
{
doCleanupSubqueries
(
pSql
);
return
pRes
->
code
;
}
// send sub sql
doConcurrentlySendSubQueries
(
pSql
);
//return TSDB_CODE_TSC_QUERY_CANCELLED;
return
TSDB_CODE_SUCCESS
;
}
src/client/src/tscSubquery.c
浏览文件 @
4cbcf232
...
...
@@ -694,6 +694,10 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
void
freeJoinSubqueryObj
(
SSqlObj
*
pSql
)
{
pthread_mutex_lock
(
&
pSql
->
subState
.
mutex
);
if
(
pSql
->
subState
.
numOfSub
==
0
)
{
goto
_out
;
}
for
(
int32_t
i
=
0
;
i
<
pSql
->
subState
.
numOfSub
;
++
i
)
{
SSqlObj
*
pSub
=
pSql
->
pSubs
[
i
];
if
(
pSub
==
NULL
)
{
...
...
@@ -709,6 +713,8 @@ void freeJoinSubqueryObj(SSqlObj* pSql) {
tfree
(
pSql
->
pSubs
);
tfree
(
pSql
->
subState
.
states
);
pSql
->
subState
.
numOfSub
=
0
;
_out:
pthread_mutex_unlock
(
&
pSql
->
subState
.
mutex
);
}
...
...
@@ -2227,23 +2233,17 @@ void tscHandleMasterJoinQuery(SSqlObj* pSql) {
tscAsyncResultOnError
(
pSql
);
}
void
doCleanupSubqueries
(
SSqlObj
*
pSql
,
int32_t
numOfSubs
)
{
void
doCleanupSubqueries
(
SSqlObj
*
pSql
)
{
pthread_mutex_lock
(
&
pSql
->
subState
.
mutex
);
if
(
numOfSubs
>
pSql
->
subState
.
numOfSub
||
numOfSubs
<=
0
||
pSql
->
subState
.
numOfSub
<=
0
)
{
goto
_out
;
}
for
(
int32_t
i
=
0
;
i
<
numOfSubs
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pSql
->
subState
.
numOfSub
;
++
i
)
{
SSqlObj
*
pSub
=
pSql
->
pSubs
[
i
];
pSql
->
pSubs
[
i
]
=
NULL
;
if
(
!
pSub
)
continue
;
pSql
->
pSubs
[
i
]
=
NULL
;
tscFreeRetrieveSup
(
&
pSub
->
param
);
taos_free_result
(
pSub
);
}
_out:
pthread_mutex_unlock
(
&
pSql
->
subState
.
mutex
);
}
...
...
@@ -2739,8 +2739,6 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
pCmd
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
SSubqueryState
*
pState
=
&
pSql
->
subState
;
int32_t
numOfSub
=
(
pTableMetaInfo
->
pVgroupTables
==
NULL
)
?
pTableMetaInfo
->
vgroupList
->
numOfVgroups
:
(
int32_t
)
taosArrayGetSize
(
pTableMetaInfo
->
pVgroupTables
);
int32_t
ret
=
doReInitSubState
(
pSql
,
numOfSub
);
...
...
@@ -2758,11 +2756,11 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
return
ret
;
}
tscDebug
(
"0x%"
PRIx64
" retrieved query data from %d vnode(s)"
,
pSql
->
self
,
pS
tate
->
numOfSub
);
tscDebug
(
"0x%"
PRIx64
" retrieved query data from %d vnode(s)"
,
pSql
->
self
,
pS
ql
->
subState
.
numOfSub
);
pRes
->
code
=
TSDB_CODE_SUCCESS
;
int32_t
i
=
0
;
for
(;
i
<
pS
tate
->
numOfSub
;
++
i
)
{
for
(;
i
<
pS
ql
->
subState
.
numOfSub
;
++
i
)
{
SRetrieveSupport
*
trs
=
(
SRetrieveSupport
*
)
calloc
(
1
,
sizeof
(
SRetrieveSupport
));
if
(
trs
==
NULL
)
{
tscError
(
"0x%"
PRIx64
" failed to malloc buffer for SRetrieveSupport, orderOfSub:%d, reason:%s"
,
pSql
->
self
,
i
,
strerror
(
errno
));
...
...
@@ -2802,24 +2800,19 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
tscDebug
(
"0x%"
PRIx64
" sub:0x%"
PRIx64
" create subquery success. orderOfSub:%d"
,
pSql
->
self
,
pNew
->
self
,
trs
->
subqueryIndex
);
}
if
(
i
<
pS
tate
->
numOfSub
)
{
if
(
i
<
pS
ql
->
subState
.
numOfSub
)
{
tscError
(
"0x%"
PRIx64
" failed to prepare subquery structure and launch subqueries"
,
pSql
->
self
);
pRes
->
code
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
tscDestroyGlobalMergerEnv
(
pMemoryBuf
,
pDesc
,
pState
->
numOfSub
);
doCleanupSubqueries
(
pSql
,
i
);
return
pRes
->
code
;
// free all allocated resource
}
if
(
pRes
->
code
==
TSDB_CODE_TSC_QUERY_CANCELLED
)
{
tscDestroyGlobalMergerEnv
(
pMemoryBuf
,
pDesc
,
pS
tate
->
numOfSub
);
doCleanupSubqueries
(
pSql
,
i
);
if
(
pRes
->
code
!=
TSDB_CODE_SUCCESS
)
{
tscDestroyGlobalMergerEnv
(
pMemoryBuf
,
pDesc
,
pS
ql
->
subState
.
numOfSub
);
doCleanupSubqueries
(
pSql
);
return
pRes
->
code
;
}
doConcurrentlySendSubQueries
(
pSql
);
return
TSDB_CODE_SUCCESS
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录