Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
374bcb86
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
374bcb86
编写于
6月 30, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225] refactor code.
上级
457a7010
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
137 addition
and
122 deletion
+137
-122
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+129
-114
src/common/inc/tglobal.h
src/common/inc/tglobal.h
+2
-2
src/common/src/tglobal.c
src/common/src/tglobal.c
+3
-3
src/os/linux/src/linuxSysPara.c
src/os/linux/src/linuxSysPara.c
+2
-2
src/query/tests/astTest.cpp
src/query/tests/astTest.cpp
+1
-1
未找到文件。
src/client/src/tscSubquery.c
浏览文件 @
374bcb86
...
...
@@ -1415,7 +1415,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
}
trs
->
subqueryIndex
=
i
;
trs
->
pParentSql
Obj
=
pSql
;
trs
->
pParentSql
=
pSql
;
trs
->
pFinalColModel
=
pModel
;
pthread_mutexattr_t
mutexattr
;
...
...
@@ -1500,7 +1500,7 @@ static void tscAbortFurtherRetryRetrieval(SRetrieveSupport *trsupport, TAOS_RES
tscError
(
"sub:%p failed to flush data to disk, reason:%s"
,
tres
,
tstrerror
(
code
));
#endif
SSqlObj
*
pParentSql
=
trsupport
->
pParentSql
Obj
;
SSqlObj
*
pParentSql
=
trsupport
->
pParentSql
;
pParentSql
->
res
.
code
=
code
;
trsupport
->
numOfRetry
=
MAX_NUM_OF_SUBQUERY_RETRY
;
...
...
@@ -1509,8 +1509,45 @@ static void tscAbortFurtherRetryRetrieval(SRetrieveSupport *trsupport, TAOS_RES
tscHandleSubqueryError
(
trsupport
,
tres
,
pParentSql
->
res
.
code
);
}
/*
* current query failed, and the retry count is less than the available
* count, retry query clear previous retrieved data, then launch a new sub query
*/
static
int32_t
tscReissueSubquery
(
SRetrieveSupport
*
trsupport
,
SSqlObj
*
pSql
,
int32_t
code
)
{
SSqlObj
*
pParentSql
=
trsupport
->
pParentSql
;
int32_t
subqueryIndex
=
trsupport
->
subqueryIndex
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
&
pSql
->
cmd
,
0
,
0
);
SCMVgroupInfo
*
pVgroup
=
&
pTableMetaInfo
->
vgroupList
->
vgroups
[
0
];
tExtMemBufferClear
(
trsupport
->
pExtMemBuffer
[
subqueryIndex
]);
// clear local saved number of results
trsupport
->
localBuffer
->
num
=
0
;
pthread_mutex_unlock
(
&
trsupport
->
queryMutex
);
tscTrace
(
"%p sub:%p retrieve failed, code:%s, orderOfSub:%d, retry:%d"
,
trsupport
->
pParentSql
,
pSql
,
tstrerror
(
code
),
subqueryIndex
,
trsupport
->
numOfRetry
);
SSqlObj
*
pNew
=
tscCreateSqlObjForSubquery
(
trsupport
->
pParentSql
,
trsupport
,
pSql
);
// todo add to async res or not??
if
(
pNew
==
NULL
)
{
tscError
(
"%p sub:%p failed to create new subquery due to out of memory, abort retry, vgId:%d, orderOfSub:%d"
,
trsupport
->
pParentSql
,
pSql
,
pVgroup
->
vgId
,
trsupport
->
subqueryIndex
);
pParentSql
->
res
.
code
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
trsupport
->
numOfRetry
=
MAX_NUM_OF_SUBQUERY_RETRY
;
return
pParentSql
->
res
.
code
;
}
taos_free_result
(
pSql
);
return
tscProcessSql
(
pNew
);
}
void
tscHandleSubqueryError
(
SRetrieveSupport
*
trsupport
,
SSqlObj
*
pSql
,
int
numOfRows
)
{
SSqlObj
*
pParentSql
=
trsupport
->
pParentSql
Obj
;
SSqlObj
*
pParentSql
=
trsupport
->
pParentSql
;
int32_t
subqueryIndex
=
trsupport
->
subqueryIndex
;
assert
(
pSql
!=
NULL
);
...
...
@@ -1529,38 +1566,16 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
tscDebug
(
"%p query is cancelled, sub:%p, orderOfSub:%d abort retrieve, code:%d"
,
pParentSql
,
pSql
,
subqueryIndex
,
pParentSql
->
res
.
code
);
}
if
(
numOfRows
>=
0
)
{
// current query is successful, but other sub query failed, still abort current query.
tscDebug
(
"%p sub:%p retrieve numOfRows:%d,orderOfSub:%d"
,
pParentSql
,
pSql
,
numOfRows
,
subqueryIndex
);
tscError
(
"%p sub:%p abort further retrieval due to other queries failure,orderOfSub:%d,code:%d"
,
pParentSql
,
pSql
,
subqueryIndex
,
pParentSql
->
res
.
code
);
}
else
{
if
(
trsupport
->
numOfRetry
++
<
MAX_NUM_OF_SUBQUERY_RETRY
&&
pParentSql
->
res
.
code
==
TSDB_CODE_SUCCESS
)
{
/*
* current query failed, and the retry count is less than the available
* count, retry query clear previous retrieved data, then launch a new sub query
*/
tExtMemBufferClear
(
trsupport
->
pExtMemBuffer
[
subqueryIndex
]);
// clear local saved number of results
trsupport
->
localBuffer
->
num
=
0
;
pthread_mutex_unlock
(
&
trsupport
->
queryMutex
);
tscDebug
(
"%p sub:%p retrieve failed, code:%s, orderOfSub:%d, retry:%d"
,
trsupport
->
pParentSqlObj
,
pSql
,
tstrerror
(
numOfRows
),
subqueryIndex
,
trsupport
->
numOfRetry
);
SSqlObj
*
pNew
=
tscCreateSqlObjForSubquery
(
trsupport
->
pParentSqlObj
,
trsupport
,
pSql
);
if
(
pNew
==
NULL
)
{
tscError
(
"%p sub:%p failed to create new subquery sqlObj due to out of memory, abort retry"
,
trsupport
->
pParentSqlObj
,
pSql
);
pParentSql
->
res
.
code
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
trsupport
->
numOfRetry
=
MAX_NUM_OF_SUBQUERY_RETRY
;
if
(
tscReissueSubquery
(
trsupport
,
pSql
,
numOfRows
)
==
TSDB_CODE_SUCCESS
)
{
return
;
}
tscProcessSql
(
pNew
);
return
;
}
else
{
// reach the maximum retry count, abort
atomic_val_compare_exchange_32
(
&
pParentSql
->
res
.
code
,
TSDB_CODE_SUCCESS
,
numOfRows
);
tscError
(
"%p sub:%p retrieve failed,code:%s,orderOfSub:%d failed.no more retry,set global code:%s"
,
pParentSql
,
pSql
,
...
...
@@ -1601,7 +1616,7 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
static
void
tscAllDataRetrievedFromDnode
(
SRetrieveSupport
*
trsupport
,
SSqlObj
*
pSql
)
{
int32_t
idx
=
trsupport
->
subqueryIndex
;
SSqlObj
*
pP
Obj
=
trsupport
->
pParentSqlObj
;
SSqlObj
*
pP
arentSql
=
trsupport
->
pParentSql
;
tOrderDescriptor
*
pDesc
=
trsupport
->
pOrderDescriptor
;
SSubqueryState
*
pState
=
trsupport
->
pState
;
...
...
@@ -1611,7 +1626,7 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p
// data in from current vnode is stored in cache and disk
uint32_t
numOfRowsFromSubquery
=
trsupport
->
pExtMemBuffer
[
idx
]
->
numOfTotalElems
+
trsupport
->
localBuffer
->
num
;
tscDebug
(
"%p sub:%p all data retrieved from ip:%s, vgId:%d, numOfRows:%d, orderOfSub:%d"
,
pP
Obj
,
pSql
,
tscDebug
(
"%p sub:%p all data retrieved from ip:%s, vgId:%d, numOfRows:%d, orderOfSub:%d"
,
pP
arentSql
,
pSql
,
pTableMetaInfo
->
vgroupList
->
vgroups
[
0
].
ipAddr
[
0
].
fqdn
,
pTableMetaInfo
->
vgroupList
->
vgroups
[
0
].
vgId
,
numOfRowsFromSubquery
,
idx
);
...
...
@@ -1625,15 +1640,14 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p
trsupport
->
localBuffer
->
num
,
colInfo
);
#endif
if
(
tsTotalTmpDirGB
!=
0
&&
tsAvailTmpDirGB
<
tsMinimalTmpDirGB
)
{
tscError
(
"%p sub:%p client disk space remain %.3f GB, need at least %.3f GB, stop query"
,
pPObj
,
pSql
,
tsAvailTmpDirGB
,
tsMinimalTmpDirGB
);
tscAbortFurtherRetryRetrieval
(
trsupport
,
pSql
,
TSDB_CODE_TSC_NO_DISKSPACE
);
return
;
if
(
tsTotalTmpDirGB
!=
0
&&
tsAvailTmpDirectorySpace
<
tsReservedTmpDirectorySpace
)
{
tscError
(
"%p sub:%p client disk space remain %.3f GB, need at least %.3f GB, stop query"
,
pParentSql
,
pSql
,
tsAvailTmpDirectorySpace
,
tsReservedTmpDirectorySpace
);
return
tscAbortFurtherRetryRetrieval
(
trsupport
,
pSql
,
TSDB_CODE_TSC_NO_DISKSPACE
);
}
// each result for a vnode is ordered as an independant list,
// then used as an input of loser tree for disk-based merge
routine
// then used as an input of loser tree for disk-based merge
int32_t
code
=
tscFlushTmpBuffer
(
trsupport
->
pExtMemBuffer
[
idx
],
pDesc
,
trsupport
->
localBuffer
,
pQueryInfo
->
groupbyExpr
.
orderType
);
if
(
code
!=
0
)
{
// set no disk space error info, and abort retry
return
tscAbortFurtherRetryRetrieval
(
trsupport
,
pSql
,
code
);
...
...
@@ -1641,7 +1655,7 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p
int32_t
remain
=
-
1
;
if
((
remain
=
atomic_sub_fetch_32
(
&
pState
->
numOfRemain
,
1
))
>
0
)
{
tscDebug
(
"%p sub:%p orderOfSub:%d freed, finished subqueries:%d"
,
pP
Obj
,
pSql
,
trsupport
->
subqueryIndex
,
tscDebug
(
"%p sub:%p orderOfSub:%d freed, finished subqueries:%d"
,
pP
arentSql
,
pSql
,
trsupport
->
subqueryIndex
,
pState
->
numOfTotal
-
remain
);
return
tscFreeSubSqlObj
(
trsupport
,
pSql
);
...
...
@@ -1650,29 +1664,29 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p
// all sub-queries are returned, start to local merge process
pDesc
->
pColumnModel
->
capacity
=
trsupport
->
pExtMemBuffer
[
idx
]
->
numOfElemsPerPage
;
tscDebug
(
"%p retrieve from %d vnodes completed.final NumOfRows:%"
PRId64
",start to build loser tree"
,
pP
Obj
,
tscDebug
(
"%p retrieve from %d vnodes completed.final NumOfRows:%"
PRId64
",start to build loser tree"
,
pP
arentSql
,
pState
->
numOfTotal
,
pState
->
numOfRetrievedRows
);
SQueryInfo
*
pPQueryInfo
=
tscGetQueryInfoDetail
(
&
pP
Obj
->
cmd
,
0
);
SQueryInfo
*
pPQueryInfo
=
tscGetQueryInfoDetail
(
&
pP
arentSql
->
cmd
,
0
);
tscClearInterpInfo
(
pPQueryInfo
);
tscCreateLocalReducer
(
trsupport
->
pExtMemBuffer
,
pState
->
numOfTotal
,
pDesc
,
trsupport
->
pFinalColModel
,
pP
Obj
);
tscDebug
(
"%p build loser tree completed"
,
pP
Obj
);
tscCreateLocalReducer
(
trsupport
->
pExtMemBuffer
,
pState
->
numOfTotal
,
pDesc
,
trsupport
->
pFinalColModel
,
pP
arentSql
);
tscDebug
(
"%p build loser tree completed"
,
pP
arentSql
);
pP
Obj
->
res
.
precision
=
pSql
->
res
.
precision
;
pP
Obj
->
res
.
numOfRows
=
0
;
pP
Obj
->
res
.
row
=
0
;
pP
arentSql
->
res
.
precision
=
pSql
->
res
.
precision
;
pP
arentSql
->
res
.
numOfRows
=
0
;
pP
arentSql
->
res
.
row
=
0
;
// only free once
tfree
(
trsupport
->
pState
);
tscFreeSubSqlObj
(
trsupport
,
pSql
);
// set the command flag must be after the semaphore been correctly set.
pP
Obj
->
cmd
.
command
=
TSDB_SQL_RETRIEVE_LOCALMERGE
;
if
(
pP
Obj
->
res
.
code
==
TSDB_CODE_SUCCESS
)
{
(
*
pP
Obj
->
fp
)(
pPObj
->
param
,
pPObj
,
0
);
pP
arentSql
->
cmd
.
command
=
TSDB_SQL_RETRIEVE_LOCALMERGE
;
if
(
pP
arentSql
->
res
.
code
==
TSDB_CODE_SUCCESS
)
{
(
*
pP
arentSql
->
fp
)(
pParentSql
->
param
,
pParentSql
,
0
);
}
else
{
tscQueueAsyncRes
(
pP
Obj
);
tscQueueAsyncRes
(
pP
arentSql
);
}
}
...
...
@@ -1680,22 +1694,48 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
SRetrieveSupport
*
trsupport
=
(
SRetrieveSupport
*
)
param
;
tOrderDescriptor
*
pDesc
=
trsupport
->
pOrderDescriptor
;
int32_t
idx
=
trsupport
->
subqueryIndex
;
SSqlObj
*
pP
Obj
=
trsupport
->
pParentSqlObj
;
SSqlObj
*
pP
arentSql
=
trsupport
->
pParentSql
;
SSqlObj
*
pSql
=
(
SSqlObj
*
)
tres
;
if
(
pSql
==
NULL
)
{
// sql object has been released in error process, return immediately
tscDebug
(
"%p subquery has been released, idx:%d, abort"
,
pP
Obj
,
idx
);
tscDebug
(
"%p subquery has been released, idx:%d, abort"
,
pP
arentSql
,
idx
);
return
;
}
SSubqueryState
*
pState
=
trsupport
->
pState
;
assert
(
pState
->
numOfRemain
<=
pState
->
numOfTotal
&&
pState
->
numOfRemain
>=
0
&&
pP
Obj
->
numOfSubs
==
pState
->
numOfTotal
);
assert
(
pState
->
numOfRemain
<=
pState
->
numOfTotal
&&
pState
->
numOfRemain
>=
0
&&
pP
arentSql
->
numOfSubs
==
pState
->
numOfTotal
);
// query process and cancel query process may execute at the same time
pthread_mutex_lock
(
&
trsupport
->
queryMutex
);
if
(
numOfRows
<
0
||
pPObj
->
res
.
code
!=
TSDB_CODE_SUCCESS
)
{
return
tscHandleSubqueryError
(
trsupport
,
pSql
,
numOfRows
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
&
pSql
->
cmd
,
0
,
0
);
SCMVgroupInfo
*
pVgroup
=
&
pTableMetaInfo
->
vgroupList
->
vgroups
[
0
];
if
(
pParentSql
->
res
.
code
!=
TSDB_CODE_SUCCESS
)
{
trsupport
->
numOfRetry
=
MAX_NUM_OF_SUBQUERY_RETRY
;
tscTrace
(
"%p query cancelled or failed, sub:%p, vgId:%d, orderOfSub:%d, code:%s, global code:%s"
,
pParentSql
,
pSql
,
pVgroup
->
vgId
,
trsupport
->
subqueryIndex
,
tstrerror
(
numOfRows
),
tstrerror
(
pParentSql
->
res
.
code
));
tscHandleSubqueryError
(
param
,
tres
,
numOfRows
);
return
;
}
if
(
taos_errno
(
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
assert
(
numOfRows
==
taos_errno
(
pSql
));
if
(
trsupport
->
numOfRetry
++
<
MAX_NUM_OF_SUBQUERY_RETRY
)
{
tscTrace
(
"%p sub:%p failed code:%s, retry:%d"
,
pParentSql
,
pSql
,
tstrerror
(
numOfRows
),
trsupport
->
numOfRetry
);
if
(
tscReissueSubquery
(
trsupport
,
pSql
,
numOfRows
)
==
TSDB_CODE_SUCCESS
)
{
return
;
}
}
else
{
tscTrace
(
"%p sub:%p reach the max retry times, set global code:%s"
,
pParentSql
,
pSql
,
tstrerror
(
numOfRows
));
atomic_val_compare_exchange_32
(
&
pParentSql
->
res
.
code
,
TSDB_CODE_SUCCESS
,
numOfRows
);
// set global code and abort
}
tscHandleSubqueryError
(
param
,
tres
,
numOfRows
);
return
;
}
SSqlRes
*
pRes
=
&
pSql
->
res
;
...
...
@@ -1705,14 +1745,13 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
assert
(
pRes
->
numOfRows
==
numOfRows
);
int64_t
num
=
atomic_add_fetch_64
(
&
pState
->
numOfRetrievedRows
,
numOfRows
);
tscDebug
(
"%p sub:%p retrieve numOfRows:%"
PRId64
" totalNumOfRows:%"
PRIu64
" from ip:%s, orderOfSub:%d"
,
pP
Obj
,
pSql
,
tscDebug
(
"%p sub:%p retrieve numOfRows:%"
PRId64
" totalNumOfRows:%"
PRIu64
" from ip:%s, orderOfSub:%d"
,
pP
arentSql
,
pSql
,
pRes
->
numOfRows
,
pState
->
numOfRetrievedRows
,
pSql
->
ipList
.
fqdn
[
pSql
->
ipList
.
inUse
],
idx
);
if
(
num
>
tsMaxNumOfOrderedResults
&&
tscIsProjectionQueryOnSTable
(
pQueryInfo
,
0
))
{
tscError
(
"%p sub:%p num of OrderedRes is too many, max allowed:%"
PRId32
" , current:%"
PRId64
,
pPObj
,
pSql
,
tsMaxNumOfOrderedResults
,
num
);
tscAbortFurtherRetryRetrieval
(
trsupport
,
tres
,
TSDB_CODE_TSC_SORTED_RES_TOO_MANY
);
return
;
pParentSql
,
pSql
,
tsMaxNumOfOrderedResults
,
num
);
return
tscAbortFurtherRetryRetrieval
(
trsupport
,
tres
,
TSDB_CODE_TSC_SORTED_RES_TOO_MANY
);
}
#ifdef _DEBUG_VIEW
...
...
@@ -1723,11 +1762,11 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
tColModelDisplayEx
(
pDesc
->
pColumnModel
,
pRes
->
data
,
pRes
->
numOfRows
,
pRes
->
numOfRows
,
colInfo
);
#endif
if
(
tsTotalTmpDirGB
!=
0
&&
tsAvailTmpDirGB
<
tsMinimalTmpDirGB
)
{
tscError
(
"%p sub:%p client disk space remain %.3f GB, need at least %.3f GB, stop query"
,
pPObj
,
pSql
,
tsAvailTmpDirGB
,
tsMinimalTmpDirGB
);
tscAbortFurtherRetryRetrieval
(
trsupport
,
tres
,
TSDB_CODE_TSC_NO_DISKSPACE
);
return
;
// no disk space for tmp directory
if
(
tsTotalTmpDirGB
!=
0
&&
tsAvailTmpDirectorySpace
<
tsReservedTmpDirectorySpace
)
{
tscError
(
"%p sub:%p client disk space remain %.3f GB, need at least %.3f GB, stop query"
,
pParentSql
,
pSql
,
tsAvailTmpDirectorySpace
,
tsReservedTmpDirectorySpace
);
return
tscAbortFurtherRetryRetrieval
(
trsupport
,
tres
,
TSDB_CODE_TSC_NO_DISKSPACE
)
;
}
int32_t
ret
=
saveToBuffer
(
trsupport
->
pExtMemBuffer
[
idx
],
pDesc
,
trsupport
->
localBuffer
,
pRes
->
data
,
...
...
@@ -1772,80 +1811,56 @@ static SSqlObj *tscCreateSqlObjForSubquery(SSqlObj *pSql, SRetrieveSupport *trsu
void
tscRetrieveDataRes
(
void
*
param
,
TAOS_RES
*
tres
,
int
code
)
{
SRetrieveSupport
*
trsupport
=
(
SRetrieveSupport
*
)
param
;
SSqlObj
*
pParentSql
=
trsupport
->
pParentSql
Obj
;
SSqlObj
*
pParentSql
=
trsupport
->
pParentSql
;
SSqlObj
*
pSql
=
(
SSqlObj
*
)
tres
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
assert
(
pSql
->
cmd
.
numOfClause
==
1
&&
pQueryInfo
->
numOfTables
==
1
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
&
pSql
->
cmd
,
0
,
0
);
SCMVgroupInfo
*
pVgroup
=
&
pTableMetaInfo
->
vgroupList
->
vgroups
[
0
];
SSubqueryState
*
pState
=
trsupport
->
pState
;
assert
(
pState
->
numOfRemain
<=
pState
->
numOfTotal
&&
pState
->
numOfRemain
>=
0
&&
pParentSql
->
numOfSubs
==
pState
->
numOfTotal
);
SCMVgroupInfo
*
pVgroup
=
&
pTableMetaInfo
->
vgroupList
->
vgroups
[
trsupport
->
subqueryIndex
];
//
todo set error code
//
stable query killed or other subquery failed, all query stopped
if
(
pParentSql
->
res
.
code
!=
TSDB_CODE_SUCCESS
)
{
// stable query is killed, abort further retry
trsupport
->
numOfRetry
=
MAX_NUM_OF_SUBQUERY_RETRY
;
if
(
pParentSql
->
res
.
code
!=
TSDB_CODE_SUCCESS
)
{
code
=
pParentSql
->
res
.
code
;
}
tscDebug
(
"%p query cancelled or failed, sub:%p, orderOfSub:%d abort, code:%s"
,
pParentSql
,
pSql
,
trsupport
->
subqueryIndex
,
tstrerror
(
code
));
tscTrace
(
"%p query cancelled or failed, sub:%p, vgId:%d, orderOfSub:%d, code:%s, global code:%s"
,
pParentSql
,
pSql
,
pVgroup
->
vgId
,
trsupport
->
subqueryIndex
,
tstrerror
(
code
),
tstrerror
(
pParentSql
->
res
.
code
));
tscHandleSubqueryError
(
param
,
tres
,
code
);
return
;
}
/*
* if a
query on a vnode is
failed, all retrieve operations from vnode that occurs later
* if a
subquery on a vnode
failed, all retrieve operations from vnode that occurs later
* than this one are actually not necessary, we simply call the tscRetrieveFromDnodeCallBack
* function to abort current and remain retrieve process.
*
* NOTE: thread safe is required.
*/
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
trsupport
->
numOfRetry
++
>=
MAX_NUM_OF_SUBQUERY_RETRY
)
{
tscDebug
(
"%p sub:%p reach the max retry times, set global code:%s"
,
pParentSql
,
pSql
,
tstrerror
(
code
));
atomic_val_compare_exchange_32
(
&
pParentSql
->
res
.
code
,
TSDB_CODE_SUCCESS
,
code
);
}
else
{
// does not reach the maximum retry time, go on
tscDebug
(
"%p sub:%p failed code:%s, retry:%d"
,
pParentSql
,
pSql
,
tstrerror
(
code
),
trsupport
->
numOfRetry
);
SSqlObj
*
pNew
=
tscCreateSqlObjForSubquery
(
pParentSql
,
trsupport
,
pSql
);
if
(
pNew
==
NULL
)
{
tscError
(
"%p sub:%p failed to create new subquery due to out of memory, abort retry, vgId:%d, orderOfSub:%d"
,
trsupport
->
pParentSqlObj
,
pSql
,
pVgroup
->
vgId
,
trsupport
->
subqueryIndex
);
pParentSql
->
res
.
code
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
trsupport
->
numOfRetry
=
MAX_NUM_OF_SUBQUERY_RETRY
;
}
else
{
SQueryInfo
*
pNewQueryInfo
=
tscGetQueryInfoDetail
(
&
pNew
->
cmd
,
0
);
assert
(
pNewQueryInfo
->
pTableMetaInfo
[
0
]
->
pTableMeta
!=
NULL
);
if
(
taos_errno
(
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
assert
(
code
==
taos_errno
(
pSql
));
taos_free_result
(
pSql
);
tscProcessSql
(
pNew
);
if
(
trsupport
->
numOfRetry
++
<
MAX_NUM_OF_SUBQUERY_RETRY
)
{
tscTrace
(
"%p sub:%p failed code:%s, retry:%d"
,
pParentSql
,
pSql
,
tstrerror
(
code
),
trsupport
->
numOfRetry
);
if
(
tscReissueSubquery
(
trsupport
,
pSql
,
code
)
==
TSDB_CODE_SUCCESS
)
{
return
;
}
}
}
if
(
pParentSql
->
res
.
code
!=
TSDB_CODE_SUCCESS
)
{
// at least one peer subquery failed, abort current query
tscDebug
(
"%p sub:%p query failed,ip:%s,vgId:%d,orderOfSub:%d,global code:%d"
,
pParentSql
,
pSql
,
pVgroup
->
ipAddr
[
0
].
fqdn
,
pVgroup
->
vgId
,
trsupport
->
subqueryIndex
,
pParentSql
->
res
.
code
);
tscHandleSubqueryError
(
param
,
tres
,
pParentSql
->
res
.
code
);
}
else
{
// success, proceed to retrieve data from dnode
tscDebug
(
"%p sub:%p query complete, ip:%s, vgId:%d, orderOfSub:%d, retrieve data"
,
trsupport
->
pParentSqlObj
,
pSql
,
pVgroup
->
ipAddr
[
0
].
fqdn
,
pVgroup
->
vgId
,
trsupport
->
subqueryIndex
);
if
(
pSql
->
res
.
qhandle
==
0
)
{
// qhandle is NULL, code is TSDB_CODE_SUCCESS means no results generated from this vnode
tscRetrieveFromDnodeCallBack
(
param
,
pSql
,
0
);
}
else
{
taos_fetch_rows_a
(
tres
,
tscRetrieveFromDnodeCallBack
,
param
);
tscTrace
(
"%p sub:%p reach the max retry times, set global code:%s"
,
pParentSql
,
pSql
,
tstrerror
(
code
));
atomic_val_compare_exchange_32
(
&
pParentSql
->
res
.
code
,
TSDB_CODE_SUCCESS
,
code
);
// set global code and abort
}
tscHandleSubqueryError
(
param
,
tres
,
pParentSql
->
res
.
code
);
return
;
}
tscTrace
(
"%p sub:%p query complete, ip:%s, vgId:%d, orderOfSub:%d, retrieve data"
,
trsupport
->
pParentSql
,
pSql
,
pVgroup
->
ipAddr
[
0
].
fqdn
,
pVgroup
->
vgId
,
trsupport
->
subqueryIndex
);
if
(
pSql
->
res
.
qhandle
==
0
)
{
// qhandle is NULL, code is TSDB_CODE_SUCCESS means no results generated from this vnode
tscRetrieveFromDnodeCallBack
(
param
,
pSql
,
0
);
}
else
{
taos_fetch_rows_a
(
tres
,
tscRetrieveFromDnodeCallBack
,
param
);
}
}
...
...
src/common/inc/tglobal.h
浏览文件 @
374bcb86
...
...
@@ -128,10 +128,10 @@ extern float tsTotalLogDirGB;
extern
float
tsTotalTmpDirGB
;
extern
float
tsTotalDataDirGB
;
extern
float
tsAvailLogDirGB
;
extern
float
tsAvailTmpDir
GB
;
extern
float
tsAvailTmpDir
ectorySpace
;
extern
float
tsAvailDataDirGB
;
extern
float
tsMinimalLogDirGB
;
extern
float
ts
MinimalTmpDirGB
;
extern
float
ts
ReservedTmpDirectorySpace
;
extern
float
tsMinimalDataDirGB
;
extern
int32_t
tsTotalMemoryMB
;
extern
int32_t
tsVersion
;
...
...
src/common/src/tglobal.c
浏览文件 @
374bcb86
...
...
@@ -170,9 +170,9 @@ int64_t tsStreamMax;
int32_t
tsNumOfCores
=
1
;
float
tsTotalTmpDirGB
=
0
;
float
tsTotalDataDirGB
=
0
;
float
tsAvailTmpDir
GB
=
0
;
float
tsAvailTmpDir
ectorySpace
=
0
;
float
tsAvailDataDirGB
=
0
;
float
ts
MinimalTmpDirGB
=
0
.
1
;
float
ts
ReservedTmpDirectorySpace
=
0
.
1
;
float
tsMinimalDataDirGB
=
0
.
5
;
int32_t
tsTotalMemoryMB
=
0
;
int32_t
tsVersion
=
0
;
...
...
@@ -807,7 +807,7 @@ static void doInitGlobalConfig() {
taosInitConfigOption
(
cfg
);
cfg
.
option
=
"minimalTmpDirGB"
;
cfg
.
ptr
=
&
ts
MinimalTmpDirGB
;
cfg
.
ptr
=
&
ts
ReservedTmpDirectorySpace
;
cfg
.
valType
=
TAOS_CFG_VTYPE_FLOAT
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
minValue
=
0
.
001
;
...
...
src/os/linux/src/linuxSysPara.c
浏览文件 @
374bcb86
...
...
@@ -326,12 +326,12 @@ bool taosGetDisk() {
if
(
statvfs
(
"/tmp"
,
&
info
))
{
//tsTotalTmpDirGB = 0;
//tsAvailTmpDir
GB
= 0;
//tsAvailTmpDir
ectorySpace
= 0;
uError
(
"failed to get disk size, tmpDir:/tmp errno:%s"
,
strerror
(
errno
));
return
false
;
}
else
{
tsTotalTmpDirGB
=
(
float
)((
double
)
info
.
f_blocks
*
(
double
)
info
.
f_frsize
/
unit
);
tsAvailTmpDir
GB
=
(
float
)((
double
)
info
.
f_bavail
*
(
double
)
info
.
f_frsize
/
unit
);
tsAvailTmpDir
ectorySpace
=
(
float
)((
double
)
info
.
f_bavail
*
(
double
)
info
.
f_frsize
/
unit
);
}
return
true
;
...
...
src/query/tests/astTest.cpp
浏览文件 @
374bcb86
...
...
@@ -631,5 +631,5 @@ void exprSerializeTest2() {
}
}
// namespace
TEST
(
testCase
,
astTest
)
{
exprSerializeTest2
();
//
exprSerializeTest2();
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录