Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
40ddf1f1
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看板
提交
40ddf1f1
编写于
9月 19, 2022
作者:
B
Benguang Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: synchronize iteration over sub queries with subState.mutex
上级
4cbcf232
变更
9
展开全部
隐藏空白更改
内联
并排
Showing
9 changed file
with
239 addition
and
82 deletion
+239
-82
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+2
-0
src/client/src/tscDelete.c
src/client/src/tscDelete.c
+6
-1
src/client/src/tscProfile.c
src/client/src/tscProfile.c
+4
-2
src/client/src/tscServer.c
src/client/src/tscServer.c
+4
-4
src/client/src/tscSql.c
src/client/src/tscSql.c
+5
-1
src/client/src/tscSub.c
src/client/src/tscSub.c
+0
-1
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+172
-64
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+46
-8
src/util/src/tref.c
src/util/src/tref.c
+0
-1
未找到文件。
src/client/inc/tsclient.h
浏览文件 @
40ddf1f1
...
...
@@ -440,6 +440,8 @@ typedef struct SSqlStream {
}
SSqlStream
;
SSqlObj
*
tscAllocSqlObj
();
SSqlObj
*
tscAcquireRefOfSubobj
(
SSqlObj
*
pSql
,
int32_t
idx
);
void
tscReleaseRefOfSubobj
(
SSqlObj
*
pSql
);
void
tscSetStreamDestTable
(
SSqlStream
*
pStream
,
const
char
*
dstTable
);
...
...
src/client/src/tscDelete.c
浏览文件 @
40ddf1f1
...
...
@@ -210,7 +210,10 @@ int32_t executeDelete(SSqlObj* pSql, SQueryInfo* pQueryInfo) {
tscDebug
(
"0x%"
PRIx64
":CDEL retrieved query data from %d vnode(s)"
,
pSql
->
self
,
pSql
->
subState
.
numOfSub
);
pRes
->
code
=
TSDB_CODE_SUCCESS
;
int32_t
i
;
int32_t
i
=
0
;
{
pthread_mutex_lock
(
&
pSql
->
subState
.
mutex
);
for
(
i
=
0
;
i
<
pSql
->
subState
.
numOfSub
;
++
i
)
{
// vgroup
SVgroupMsg
*
pVgroupMsg
=
&
pTableMetaInfo
->
vgroupList
->
vgroups
[
i
];
...
...
@@ -239,6 +242,8 @@ int32_t executeDelete(SSqlObj* pSql, SQueryInfo* pQueryInfo) {
pRes
->
code
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
pthread_mutex_unlock
(
&
pSql
->
subState
.
mutex
);
}
if
(
pRes
->
code
!=
TSDB_CODE_SUCCESS
)
{
doCleanupSubqueries
(
pSql
);
return
pRes
->
code
;
...
...
src/client/src/tscProfile.c
浏览文件 @
40ddf1f1
...
...
@@ -281,7 +281,8 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) {
// } else {
// pQdesc->stableQuery = 0;
// }
pthread_mutex_lock
(
&
pSql
->
subState
.
mutex
);
{
pthread_mutex_lock
(
&
pSql
->
subState
.
mutex
);
if
(
pSql
->
pSubs
!=
NULL
&&
pSql
->
subState
.
states
!=
NULL
)
{
for
(
int32_t
i
=
0
;
i
<
pSql
->
subState
.
numOfSub
;
++
i
)
{
// because subState maybe free on anytime by any thread, check validate from here
...
...
@@ -298,7 +299,8 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) {
}
}
pQdesc
->
numOfSub
=
pSql
->
subState
.
numOfSub
;
pthread_mutex_unlock
(
&
pSql
->
subState
.
mutex
);
pthread_mutex_unlock
(
&
pSql
->
subState
.
mutex
);
}
}
pQdesc
->
numOfSub
=
htonl
(
pQdesc
->
numOfSub
);
...
...
src/client/src/tscServer.c
浏览文件 @
40ddf1f1
...
...
@@ -353,8 +353,8 @@ void checkBrokenQueries(STscObj *pTscObj) {
pSql
->
lastAlive
=
taosGetTimestampMs
();
}
}
else
{
// lock subs
pthread_mutex_lock
(
&
pSql
->
subState
.
mutex
);
{
pthread_mutex_lock
(
&
pSql
->
subState
.
mutex
);
if
(
pSql
->
pSubs
)
{
// have sub sql
for
(
int
i
=
0
;
i
<
pSql
->
subState
.
numOfSub
;
i
++
)
{
...
...
@@ -375,8 +375,8 @@ void checkBrokenQueries(STscObj *pTscObj) {
}
}
}
// unlock
pthread_mutex_unlock
(
&
pSql
->
subState
.
mutex
);
pthread_mutex_unlock
(
&
pSql
->
subState
.
mutex
);
}
}
// kill query
...
...
src/client/src/tscSql.c
浏览文件 @
40ddf1f1
...
...
@@ -747,7 +747,9 @@ static void tscKillSTableQuery(SSqlObj *pSql) {
pSql
->
res
.
code
=
TSDB_CODE_TSC_QUERY_CANCELLED
;
tscLockByThread
(
&
pSql
->
squeryLock
);
{
pthread_mutex_lock
(
&
pSql
->
subState
.
mutex
);
for
(
int
i
=
0
;
i
<
pSql
->
subState
.
numOfSub
;
++
i
)
{
// NOTE: pSub may have been released already here
SSqlObj
*
pSub
=
pSql
->
pSubs
[
i
];
...
...
@@ -767,6 +769,8 @@ static void tscKillSTableQuery(SSqlObj *pSql) {
// taosRelekaseRef(tscObjRef, pSubObj->self);
}
pthread_mutex_unlock
(
&
pSql
->
subState
.
mutex
);
}
if
(
pSql
->
subState
.
numOfSub
<=
0
)
{
tscAsyncResultOnError
(
pSql
);
}
...
...
src/client/src/tscSub.c
浏览文件 @
40ddf1f1
...
...
@@ -83,7 +83,6 @@ void tscUpdateSubscriptionProgress(void* sub, int64_t uid, TSKEY ts) {
}
}
static
void
asyncCallback
(
void
*
param
,
TAOS_RES
*
tres
,
int
code
)
{
assert
(
param
!=
NULL
);
SSub
*
pSub
=
((
SSub
*
)
param
);
...
...
src/client/src/tscSubquery.c
浏览文件 @
40ddf1f1
此差异已折叠。
点击以展开。
src/client/src/tscUtil.c
浏览文件 @
40ddf1f1
...
...
@@ -1749,6 +1749,29 @@ SSqlObj* tscAllocSqlObj() {
return
pNew
;
}
SSqlObj
*
tscAcquireRefOfSubobj
(
SSqlObj
*
pSql
,
int32_t
idx
)
{
assert
(
pSql
!=
NULL
);
SSqlObj
*
pSub
=
NULL
;
pthread_mutex_lock
(
&
pSql
->
subState
.
mutex
);
if
(
idx
<
0
||
idx
>=
pSql
->
subState
.
numOfSub
||
!
pSql
->
pSubs
[
idx
])
{
goto
_out
;
}
pSub
=
taosAcquireRef
(
tscObjRef
,
pSql
->
pSubs
[
idx
]
->
self
);
assert
(
pSql
->
pSubs
[
idx
]
==
pSub
&&
"Refcounted subquery obj mismatch"
);
_out:
pthread_mutex_unlock
(
&
pSql
->
subState
.
mutex
);
return
pSub
;
}
void
tscReleaseRefOfSubobj
(
SSqlObj
*
pSub
)
{
assert
(
pSub
!=
NULL
&&
pSub
->
self
!=
0
&&
"Subquery obj not refcounted"
);
taosReleaseRef
(
tscObjRef
,
pSub
->
self
);
}
void
tscFreeSqlObj
(
SSqlObj
*
pSql
)
{
if
(
pSql
==
NULL
||
pSql
->
signature
!=
pSql
)
{
return
;
...
...
@@ -4209,14 +4232,16 @@ int32_t doReInitSubState(SSqlObj* pSql, int32_t numOfSubqueries) {
tscFreeSubobj
(
pSql
);
int32_t
code
=
TSDB_CODE_SUCCESS
;
pthread_mutex_lock
(
&
pSql
->
subState
.
mutex
);
{
pthread_mutex_lock
(
&
pSql
->
subState
.
mutex
);
pSql
->
pSubs
=
calloc
(
numOfSubqueries
,
POINTER_BYTES
);
pSql
->
subState
.
states
=
calloc
(
numOfSubqueries
,
sizeof
(
int8_t
));
if
(
pSql
->
pSubs
==
NULL
||
pSql
->
subState
.
states
==
NULL
)
{
code
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
pSql
->
subState
.
numOfSub
=
numOfSubqueries
;
pthread_mutex_unlock
(
&
pSql
->
subState
.
mutex
);
pthread_mutex_unlock
(
&
pSql
->
subState
.
mutex
);
}
return
code
;
}
...
...
@@ -4247,6 +4272,9 @@ void executeQuery(SSqlObj* pSql, SQueryInfo* pQueryInfo) {
goto
_error
;
}
int
errflag
=
0
;
{
pthread_mutex_lock
(
&
pSql
->
subState
.
mutex
);
for
(
int32_t
i
=
0
;
i
<
pSql
->
subState
.
numOfSub
;
++
i
)
{
SQueryInfo
*
pSub
=
taosArrayGetP
(
pQueryInfo
->
pUpstream
,
i
);
...
...
@@ -4256,7 +4284,8 @@ void executeQuery(SSqlObj* pSql, SQueryInfo* pQueryInfo) {
SSqlObj
*
pNew
=
tscAllocSqlObj
();
if
(
pNew
==
NULL
)
{
code
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
goto
_error
;
errflag
=
1
;
break
;
}
pNew
->
pTscObj
=
pSql
->
pTscObj
;
...
...
@@ -4272,19 +4301,23 @@ void executeQuery(SSqlObj* pSql, SQueryInfo* pQueryInfo) {
SRetrieveSupport
*
ps
=
calloc
(
1
,
sizeof
(
SRetrieveSupport
));
// todo use object id
if
(
ps
==
NULL
)
{
tscFreeSqlObj
(
pNew
);
goto
_error
;
errflag
=
1
;
break
;
}
ps
->
pParentSql
=
pSql
;
ps
->
subqueryIndex
=
i
;
pNew
->
param
=
ps
;
registerSqlObj
(
pNew
);
pSql
->
pSubs
[
i
]
=
pNew
;
SSqlCmd
*
pCmd
=
&
pNew
->
cmd
;
pCmd
->
command
=
TSDB_SQL_SELECT
;
if
((
code
=
tscAddQueryInfo
(
pCmd
))
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
errflag
=
1
;
break
;
}
SQueryInfo
*
pNewQueryInfo
=
tscGetQueryInfo
(
pCmd
);
...
...
@@ -4294,9 +4327,12 @@ void executeQuery(SSqlObj* pSql, SQueryInfo* pQueryInfo) {
numOfInit
++
;
}
pthread_mutex_unlock
(
&
pSql
->
subState
.
mutex
);
}
if
(
errflag
)
{
goto
_error
;
}
for
(
int32_t
i
=
0
;
i
<
pSql
->
subState
.
numOfSub
;
++
i
)
{
SSqlObj
*
psub
=
pSql
->
pSubs
[
i
];
registerSqlObj
(
psub
)
;
SSqlObj
*
psub
=
tscAcquireRefOfSubobj
(
pSql
,
i
);
// ACQ REF
if
(
!
psub
)
continue
;
// create sub query to handle the sub query.
SQueryInfo
*
pq
=
tscGetQueryInfo
(
&
psub
->
cmd
);
...
...
@@ -4306,6 +4342,8 @@ void executeQuery(SSqlObj* pSql, SQueryInfo* pQueryInfo) {
psub
->
cmd
.
command
=
TSDB_SQL_RETRIEVE_EMPTY_RESULT
;
}
executeQuery
(
psub
,
pq
);
tscReleaseRefOfSubobj
(
psub
);
// REL REF
}
return
;
...
...
src/util/src/tref.c
浏览文件 @
40ddf1f1
...
...
@@ -195,7 +195,6 @@ int taosRemoveRef(int rsetId, int64_t rid)
return
taosDecRefCount
(
rsetId
,
rid
,
1
);
}
// if rid is 0, return the first p in hash list, otherwise, return the next after current rid
void
*
taosAcquireRef
(
int
rsetId
,
int64_t
rid
)
{
int
hash
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录