Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e0046dbb
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
e0046dbb
编写于
7月 27, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-5175]<fix>: refactor the retry procedure while the error caused by tablemeta cache occurs.
上级
3ee29d8a
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
95 addition
and
140 deletion
+95
-140
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+2
-0
src/client/src/tscAsync.c
src/client/src/tscAsync.c
+12
-90
src/client/src/tscServer.c
src/client/src/tscServer.c
+33
-43
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+32
-7
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+16
-0
未找到文件。
src/client/inc/tscUtil.h
浏览文件 @
e0046dbb
...
@@ -354,6 +354,8 @@ char* strdup_throw(const char* str);
...
@@ -354,6 +354,8 @@ char* strdup_throw(const char* str);
bool
vgroupInfoIdentical
(
SNewVgroupInfo
*
pExisted
,
SVgroupMsg
*
src
);
bool
vgroupInfoIdentical
(
SNewVgroupInfo
*
pExisted
,
SVgroupMsg
*
src
);
SNewVgroupInfo
createNewVgroupInfo
(
SVgroupMsg
*
pVgroupMsg
);
SNewVgroupInfo
createNewVgroupInfo
(
SVgroupMsg
*
pVgroupMsg
);
void
tscRemoveTableMetaBuf
(
STableMetaInfo
*
pTableMetaInfo
,
uint64_t
id
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
src/client/src/tscAsync.c
浏览文件 @
e0046dbb
...
@@ -325,61 +325,6 @@ void tscAsyncResultOnError(SSqlObj* pSql) {
...
@@ -325,61 +325,6 @@ void tscAsyncResultOnError(SSqlObj* pSql) {
int
tscSendMsgToServer
(
SSqlObj
*
pSql
);
int
tscSendMsgToServer
(
SSqlObj
*
pSql
);
static
int32_t
updateMetaBeforeRetryQuery
(
SSqlObj
*
pSql
,
STableMetaInfo
*
pTableMetaInfo
,
SQueryInfo
*
pQueryInfo
)
{
// handle the invalid table error code for super table.
// update the pExpr info, colList info, number of table columns
// TODO Re-parse this sql and issue the corresponding subquery as an alternative for this case.
if
(
pSql
->
retryReason
==
TSDB_CODE_TDB_INVALID_TABLE_ID
)
{
int32_t
numOfExprs
=
(
int32_t
)
tscNumOfExprs
(
pQueryInfo
);
int32_t
numOfCols
=
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
);
int32_t
numOfTags
=
tscGetNumOfTags
(
pTableMetaInfo
->
pTableMeta
);
SSchema
*
pSchema
=
tscGetTableSchema
(
pTableMetaInfo
->
pTableMeta
);
SSchema
*
pTagSchema
=
tscGetTableTagSchema
(
pTableMetaInfo
->
pTableMeta
);
for
(
int32_t
i
=
0
;
i
<
numOfExprs
;
++
i
)
{
SSqlExpr
*
pExpr
=
&
(
tscExprGet
(
pQueryInfo
,
i
)
->
base
);
// update the table uid
pExpr
->
uid
=
pTableMetaInfo
->
pTableMeta
->
id
.
uid
;
if
(
pExpr
->
colInfo
.
colIndex
>=
0
)
{
int32_t
index
=
pExpr
->
colInfo
.
colIndex
;
if
((
TSDB_COL_IS_NORMAL_COL
(
pExpr
->
colInfo
.
flag
)
&&
index
>=
numOfCols
)
||
(
TSDB_COL_IS_TAG
(
pExpr
->
colInfo
.
flag
)
&&
(
index
<
0
||
index
>=
numOfTags
)))
{
return
pSql
->
retryReason
;
}
if
(
TSDB_COL_IS_TAG
(
pExpr
->
colInfo
.
flag
))
{
if
((
pTagSchema
[
pExpr
->
colInfo
.
colIndex
].
colId
!=
pExpr
->
colInfo
.
colId
)
&&
strcasecmp
(
pExpr
->
colInfo
.
name
,
pTagSchema
[
pExpr
->
colInfo
.
colIndex
].
name
)
!=
0
)
{
return
pSql
->
retryReason
;
}
}
else
if
(
TSDB_COL_IS_NORMAL_COL
(
pExpr
->
colInfo
.
flag
))
{
if
((
pSchema
[
pExpr
->
colInfo
.
colIndex
].
colId
!=
pExpr
->
colInfo
.
colId
)
&&
strcasecmp
(
pExpr
->
colInfo
.
name
,
pSchema
[
pExpr
->
colInfo
.
colIndex
].
name
)
!=
0
)
{
return
pSql
->
retryReason
;
}
}
else
{
// do nothing for udc
}
}
}
// validate the table columns information
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pQueryInfo
->
colList
);
++
i
)
{
SColumn
*
pCol
=
taosArrayGetP
(
pQueryInfo
->
colList
,
i
);
if
(
pCol
->
columnIndex
>=
numOfCols
)
{
return
pSql
->
retryReason
;
}
}
}
else
{
// do nothing
}
return
TSDB_CODE_SUCCESS
;
}
void
tscTableMetaCallBack
(
void
*
param
,
TAOS_RES
*
res
,
int
code
)
{
void
tscTableMetaCallBack
(
void
*
param
,
TAOS_RES
*
res
,
int
code
)
{
SSqlObj
*
pSql
=
(
SSqlObj
*
)
taosAcquireRef
(
tscObjRef
,
(
int64_t
)
param
);
SSqlObj
*
pSql
=
(
SSqlObj
*
)
taosAcquireRef
(
tscObjRef
,
(
int64_t
)
param
);
if
(
pSql
==
NULL
)
return
;
if
(
pSql
==
NULL
)
return
;
...
@@ -391,7 +336,7 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
...
@@ -391,7 +336,7 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
pRes
->
code
=
code
;
pRes
->
code
=
code
;
SSqlObj
*
sub
=
(
SSqlObj
*
)
res
;
SSqlObj
*
sub
=
(
SSqlObj
*
)
res
;
const
char
*
msg
=
(
sub
->
cmd
.
command
==
TSDB_SQL_STABLEVGROUP
)
?
"vgroup-list"
:
"
table-m
eta"
;
const
char
*
msg
=
(
sub
->
cmd
.
command
==
TSDB_SQL_STABLEVGROUP
)
?
"vgroup-list"
:
"
[multi-]tableM
eta"
;
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tscError
(
"0x%"
PRIx64
" get %s failed, code:%s"
,
pSql
->
self
,
msg
,
tstrerror
(
code
));
tscError
(
"0x%"
PRIx64
" get %s failed, code:%s"
,
pSql
->
self
,
msg
,
tstrerror
(
code
));
goto
_error
;
goto
_error
;
...
@@ -401,31 +346,11 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
...
@@ -401,31 +346,11 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
if
(
pSql
->
pStream
==
NULL
)
{
if
(
pSql
->
pStream
==
NULL
)
{
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
pCmd
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
pCmd
);
// check if it is a sub-query of super table query first, if true, enter another routine
// assert(TSDB_QUERY_HAS_TYPE(pQueryInfo->type, (TSDB_QUERY_TYPE_STABLE_SUBQUERY | TSDB_QUERY_TYPE_SUBQUERY | TSDB_QUERY_TYPE_TAG_FILTER_QUERY)) == 0);
if
(
TSDB_QUERY_HAS_TYPE
(
pQueryInfo
->
type
,
(
TSDB_QUERY_TYPE_STABLE_SUBQUERY
|
TSDB_QUERY_TYPE_SUBQUERY
|
TSDB_QUERY_TYPE_TAG_FILTER_QUERY
)))
{
tscDebug
(
"0x%"
PRIx64
" update cached table-meta, continue to process sql and send the corresponding query"
,
pSql
->
self
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
code
=
tscGetTableMeta
(
pSql
,
pTableMetaInfo
);
assert
(
code
==
TSDB_CODE_TSC_ACTION_IN_PROGRESS
||
code
==
TSDB_CODE_SUCCESS
);
if
(
code
==
TSDB_CODE_TSC_ACTION_IN_PROGRESS
)
{
taosReleaseRef
(
tscObjRef
,
pSql
->
self
);
return
;
}
assert
((
tscGetNumOfTags
(
pTableMetaInfo
->
pTableMeta
)
!=
0
));
code
=
updateMetaBeforeRetryQuery
(
pSql
,
pTableMetaInfo
,
pQueryInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
// tscBuildAndSendRequest can add error into async res
// super table subquery failure will be ignored
tscBuildAndSendRequest
(
pSql
,
NULL
);
// if (!TSDB_QUERY_HAS_TYPE(pQueryInfo->type, (TSDB_QUERY_TYPE_STABLE_SUBQUERY | TSDB_QUERY_TYPE_SUBQUERY |
taosReleaseRef
(
tscObjRef
,
pSql
->
self
);
// TSDB_QUERY_TYPE_TAG_FILTER_QUERY))) {
return
;
}
else
{
// continue to process normal async query
if
(
TSDB_QUERY_HAS_TYPE
(
pQueryInfo
->
type
,
TSDB_QUERY_TYPE_INSERT
))
{
if
(
TSDB_QUERY_HAS_TYPE
(
pQueryInfo
->
type
,
TSDB_QUERY_TYPE_INSERT
))
{
tscDebug
(
"0x%"
PRIx64
" continue parse sql after get table-meta"
,
pSql
->
self
);
tscDebug
(
"0x%"
PRIx64
" continue parse sql after get table-meta"
,
pSql
->
self
);
...
@@ -437,7 +362,7 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
...
@@ -437,7 +362,7 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
goto
_error
;
goto
_error
;
}
}
if
(
TSDB_QUERY_HAS_TYPE
(
pCmd
->
insertParam
.
insertType
,
TSDB_QUERY_TYPE_STMT_INSERT
))
{
if
(
TSDB_QUERY_HAS_TYPE
(
pCmd
->
insertParam
.
insertType
,
TSDB_QUERY_TYPE_STMT_INSERT
))
{
// stmt insert
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
code
=
tscGetTableMeta
(
pSql
,
pTableMetaInfo
);
code
=
tscGetTableMeta
(
pSql
,
pTableMetaInfo
);
if
(
code
==
TSDB_CODE_TSC_ACTION_IN_PROGRESS
)
{
if
(
code
==
TSDB_CODE_TSC_ACTION_IN_PROGRESS
)
{
...
@@ -448,17 +373,14 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
...
@@ -448,17 +373,14 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
}
}
(
*
pSql
->
fp
)(
pSql
->
param
,
pSql
,
code
);
(
*
pSql
->
fp
)(
pSql
->
param
,
pSql
,
code
);
}
else
{
}
else
if
(
TSDB_QUERY_HAS_TYPE
(
pCmd
->
insertParam
.
insertType
,
TSDB_QUERY_TYPE_FILE_INSERT
))
{
// file insert
if
(
TSDB_QUERY_HAS_TYPE
(
pCmd
->
insertParam
.
insertType
,
TSDB_QUERY_TYPE_FILE_INSERT
))
{
tscImportDataFromFile
(
pSql
);
tscImportDataFromFile
(
pSql
);
}
else
{
// sql string insert
}
else
{
tscHandleMultivnodeInsert
(
pSql
);
tscHandleMultivnodeInsert
(
pSql
);
}
}
}
}
else
{
}
else
{
if
(
pSql
->
retryReason
!=
TSDB_CODE_SUCCESS
)
{
if
(
pSql
->
retryReason
!=
TSDB_CODE_SUCCESS
)
{
tscDebug
(
"0x%"
PRIx64
" update cached table-meta, re-validate sql statement and send query again"
,
tscDebug
(
"0x%"
PRIx64
" update cached table-meta, re-validate sql statement and send query again"
,
pSql
->
self
);
pSql
->
self
);
tscResetSqlCmd
(
pCmd
,
false
);
tscResetSqlCmd
(
pCmd
,
false
);
pSql
->
retryReason
=
TSDB_CODE_SUCCESS
;
pSql
->
retryReason
=
TSDB_CODE_SUCCESS
;
}
else
{
}
else
{
...
@@ -479,7 +401,7 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
...
@@ -479,7 +401,7 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
taosReleaseRef
(
tscObjRef
,
pSql
->
self
);
taosReleaseRef
(
tscObjRef
,
pSql
->
self
);
return
;
return
;
}
//
}
}
else
{
// stream computing
}
else
{
// stream computing
tscDebug
(
"0x%"
PRIx64
" stream:%p meta is updated, start new query, command:%d"
,
pSql
->
self
,
pSql
->
pStream
,
pCmd
->
command
);
tscDebug
(
"0x%"
PRIx64
" stream:%p meta is updated, start new query, command:%d"
,
pSql
->
self
,
pSql
->
pStream
,
pCmd
->
command
);
...
...
src/client/src/tscServer.c
浏览文件 @
e0046dbb
...
@@ -390,33 +390,40 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) {
...
@@ -390,33 +390,40 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) {
pSql
->
cmd
.
insertParam
.
schemaAttached
=
1
;
pSql
->
cmd
.
insertParam
.
schemaAttached
=
1
;
}
}
// single table query error need to be handled here.
if
((
cmd
==
TSDB_SQL_SELECT
||
cmd
==
TSDB_SQL_UPDATE_TAGS_VAL
)
&&
if
((
cmd
==
TSDB_SQL_SELECT
||
cmd
==
TSDB_SQL_UPDATE_TAGS_VAL
)
&&
(
rpcMsg
->
code
==
TSDB_CODE_TDB_INVALID_TABLE_ID
||
// change the retry procedure
(
((
rpcMsg
->
code
==
TSDB_CODE_TDB_INVALID_TABLE_ID
||
// change the retry procedure
/*(*/
rpcMsg
->
code
==
TSDB_CODE_VND_INVALID_VGROUP_ID
||
rpcMsg
->
code
==
TSDB_CODE_VND_INVALID_VGROUP_ID
))
||
rpcMsg
->
code
==
TSDB_CODE_RPC_NETWORK_UNAVAIL
||
// change the retry procedure
rpcMsg
->
code
==
TSDB_CODE_RPC_NETWORK_UNAVAIL
||
// change the retry procedure
rpcMsg
->
code
==
TSDB_CODE_APP_NOT_READY
))
{
rpcMsg
->
code
==
TSDB_CODE_APP_NOT_READY
))
{
pSql
->
retry
++
;
tscWarn
(
"0x%"
PRIx64
" it shall renew table meta, code:%s, retry:%d"
,
pSql
->
self
,
tstrerror
(
rpcMsg
->
code
),
pSql
->
retry
);
pSql
->
res
.
code
=
rpcMsg
->
code
;
// keep the previous error code
if
(
TSDB_QUERY_HAS_TYPE
(
pQueryInfo
->
type
,
(
TSDB_QUERY_TYPE_STABLE_SUBQUERY
|
TSDB_QUERY_TYPE_SUBQUERY
|
if
(
pSql
->
retry
>
pSql
->
maxRetry
)
{
TSDB_QUERY_TYPE_TAG_FILTER_QUERY
))
&&
tscError
(
"0x%"
PRIx64
" max retry %d reached, give up"
,
pSql
->
self
,
pSql
->
maxRetry
);
!
TSDB_QUERY_HAS_TYPE
(
pQueryInfo
->
type
,
TSDB_QUERY_TYPE_PROJECTION_QUERY
))
{
}
else
{
// do nothing in case of super table subquery
// wait for a little bit moment and then retry
}
else
{
// todo do not sleep in rpc callback thread, add this process into queue to process
pSql
->
retry
+=
1
;
if
(
rpcMsg
->
code
==
TSDB_CODE_APP_NOT_READY
||
rpcMsg
->
code
==
TSDB_CODE_VND_INVALID_VGROUP_ID
)
{
tscWarn
(
"0x%"
PRIx64
" it shall renew table meta, code:%s, retry:%d"
,
pSql
->
self
,
tstrerror
(
rpcMsg
->
code
),
pSql
->
retry
);
int32_t
duration
=
getWaitingTimeInterval
(
pSql
->
retry
);
taosMsleep
(
duration
);
pSql
->
res
.
code
=
rpcMsg
->
code
;
// keep the previous error code
}
if
(
pSql
->
retry
>
pSql
->
maxRetry
)
{
tscError
(
"0x%"
PRIx64
" max retry %d reached, give up"
,
pSql
->
self
,
pSql
->
maxRetry
);
pSql
->
retryReason
=
rpcMsg
->
code
;
}
else
{
rpcMsg
->
code
=
tscRenewTableMeta
(
pSql
,
0
);
// wait for a little bit moment and then retry
// if there is an error occurring, proceed to the following error handling procedure.
// todo do not sleep in rpc callback thread, add this process into queue to process
if
(
rpcMsg
->
code
==
TSDB_CODE_TSC_ACTION_IN_PROGRESS
)
{
if
(
rpcMsg
->
code
==
TSDB_CODE_APP_NOT_READY
||
rpcMsg
->
code
==
TSDB_CODE_VND_INVALID_VGROUP_ID
)
{
taosReleaseRef
(
tscObjRef
,
handle
);
int32_t
duration
=
getWaitingTimeInterval
(
pSql
->
retry
);
rpcFreeCont
(
rpcMsg
->
pCont
);
taosMsleep
(
duration
);
return
;
}
pSql
->
retryReason
=
rpcMsg
->
code
;
rpcMsg
->
code
=
tscRenewTableMeta
(
pSql
,
0
);
// if there is an error occurring, proceed to the following error handling procedure.
if
(
rpcMsg
->
code
==
TSDB_CODE_TSC_ACTION_IN_PROGRESS
)
{
taosReleaseRef
(
tscObjRef
,
handle
);
rpcFreeCont
(
rpcMsg
->
pCont
);
return
;
}
}
}
}
}
}
}
...
@@ -2521,14 +2528,7 @@ int tscProcessDropDbRsp(SSqlObj *pSql) {
...
@@ -2521,14 +2528,7 @@ int tscProcessDropDbRsp(SSqlObj *pSql) {
int
tscProcessDropTableRsp
(
SSqlObj
*
pSql
)
{
int
tscProcessDropTableRsp
(
SSqlObj
*
pSql
)
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
&
pSql
->
cmd
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
&
pSql
->
cmd
,
0
);
tscRemoveTableMetaBuf
(
pTableMetaInfo
,
pSql
->
self
);
//The cached tableMeta is expired in this case, so clean it in hash table
char
name
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
tNameExtractFullName
(
&
pTableMetaInfo
->
name
,
name
);
taosHashRemove
(
tscTableMetaMap
,
name
,
strnlen
(
name
,
TSDB_TABLE_FNAME_LEN
));
tscDebug
(
"0x%"
PRIx64
" remove table meta after drop table:%s, numOfRemain:%d"
,
pSql
->
self
,
name
,
(
int32_t
)
taosHashGetSize
(
tscTableMetaMap
));
tfree
(
pTableMetaInfo
->
pTableMeta
);
tfree
(
pTableMetaInfo
->
pTableMeta
);
return
0
;
return
0
;
}
}
...
@@ -2915,9 +2915,7 @@ static void freeElem(void* p) {
...
@@ -2915,9 +2915,7 @@ static void freeElem(void* p) {
* @return status code
* @return status code
*/
*/
int
tscRenewTableMeta
(
SSqlObj
*
pSql
,
int32_t
tableIndex
)
{
int
tscRenewTableMeta
(
SSqlObj
*
pSql
,
int32_t
tableIndex
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
&
pSql
->
cmd
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
pCmd
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
tableIndex
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
tableIndex
);
char
name
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
char
name
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
...
@@ -2934,15 +2932,7 @@ int tscRenewTableMeta(SSqlObj *pSql, int32_t tableIndex) {
...
@@ -2934,15 +2932,7 @@ int tscRenewTableMeta(SSqlObj *pSql, int32_t tableIndex) {
}
}
// remove stored tableMeta info in hash table
// remove stored tableMeta info in hash table
size_t
len
=
strlen
(
name
);
tscRemoveTableMetaBuf
(
pTableMetaInfo
,
pSql
->
self
);
taosHashRemove
(
tscTableMetaMap
,
name
,
len
);
if
(
pTableMeta
->
tableType
==
TSDB_SUPER_TABLE
)
{
void
*
pv
=
taosCacheAcquireByKey
(
tscVgroupListBuf
,
name
,
len
);
if
(
pv
!=
NULL
)
{
taosCacheRelease
(
tscVgroupListBuf
,
&
pv
,
true
);
}
}
SArray
*
pNameList
=
taosArrayInit
(
1
,
POINTER_BYTES
);
SArray
*
pNameList
=
taosArrayInit
(
1
,
POINTER_BYTES
);
SArray
*
vgroupList
=
taosArrayInit
(
1
,
POINTER_BYTES
);
SArray
*
vgroupList
=
taosArrayInit
(
1
,
POINTER_BYTES
);
...
...
src/client/src/tscSubquery.c
浏览文件 @
e0046dbb
...
@@ -2704,8 +2704,7 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
...
@@ -2704,8 +2704,7 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
tstrerror
(
pParentSql
->
res
.
code
));
tstrerror
(
pParentSql
->
res
.
code
));
// release allocated resource
// release allocated resource
tscDestroyGlobalMergerEnv
(
trsupport
->
pExtMemBuffer
,
trsupport
->
pOrderDescriptor
,
tscDestroyGlobalMergerEnv
(
trsupport
->
pExtMemBuffer
,
trsupport
->
pOrderDescriptor
,
pState
->
numOfSub
);
pState
->
numOfSub
);
tscFreeRetrieveSup
(
pSql
);
tscFreeRetrieveSup
(
pSql
);
...
@@ -2713,7 +2712,35 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
...
@@ -2713,7 +2712,35 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
&
pParentSql
->
cmd
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
&
pParentSql
->
cmd
);
if
(
!
TSDB_QUERY_HAS_TYPE
(
pQueryInfo
->
type
,
TSDB_QUERY_TYPE_JOIN_SEC_STAGE
))
{
if
(
!
TSDB_QUERY_HAS_TYPE
(
pQueryInfo
->
type
,
TSDB_QUERY_TYPE_JOIN_SEC_STAGE
))
{
(
*
pParentSql
->
fp
)(
pParentSql
->
param
,
pParentSql
,
pParentSql
->
res
.
code
);
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
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
&
pParentSql
->
cmd
,
0
);
tscRemoveTableMetaBuf
(
pTableMetaInfo
,
pParentSql
->
self
);
tscResetSqlCmd
(
&
pParentSql
->
cmd
,
true
);
pParentSql
->
res
.
code
=
TSDB_CODE_SUCCESS
;
pParentSql
->
retry
++
;
tscDebug
(
"0x%"
PRIx64
" retry parse sql and send query, prev error: %s, retry:%d"
,
pParentSql
->
self
,
tstrerror
(
code
),
pParentSql
->
retry
);
code
=
tsParseSql
(
pParentSql
,
true
);
if
(
code
==
TSDB_CODE_TSC_ACTION_IN_PROGRESS
)
{
return
;
}
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
pParentSql
->
res
.
code
=
code
;
tscAsyncResultOnError
(
pParentSql
);
return
;
}
executeQuery
(
pParentSql
,
pQueryInfo
);
}
else
{
(
*
pParentSql
->
fp
)(
pParentSql
->
param
,
pParentSql
,
pParentSql
->
res
.
code
);
}
}
else
{
// regular super table query
}
else
{
// regular super table query
if
(
pParentSql
->
res
.
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
pParentSql
->
res
.
code
!=
TSDB_CODE_SUCCESS
)
{
tscAsyncResultOnError
(
pParentSql
);
tscAsyncResultOnError
(
pParentSql
);
...
@@ -2996,7 +3023,7 @@ void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) {
...
@@ -2996,7 +3023,7 @@ void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) {
if
(
taos_errno
(
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
taos_errno
(
pSql
)
!=
TSDB_CODE_SUCCESS
)
{
assert
(
code
==
taos_errno
(
pSql
));
assert
(
code
==
taos_errno
(
pSql
));
if
(
trsupport
->
numOfRetry
++
<
MAX_NUM_OF_SUBQUERY_RETRY
)
{
if
(
trsupport
->
numOfRetry
++
<
MAX_NUM_OF_SUBQUERY_RETRY
&&
(
code
!=
TSDB_CODE_TDB_INVALID_TABLE_ID
)
)
{
tscError
(
"0x%"
PRIx64
" sub:0x%"
PRIx64
" failed code:%s, retry:%d"
,
pParentSql
->
self
,
pSql
->
self
,
tstrerror
(
code
),
trsupport
->
numOfRetry
);
tscError
(
"0x%"
PRIx64
" sub:0x%"
PRIx64
" failed code:%s, retry:%d"
,
pParentSql
->
self
,
pSql
->
self
,
tstrerror
(
code
),
trsupport
->
numOfRetry
);
int32_t
sent
=
0
;
int32_t
sent
=
0
;
...
@@ -3005,7 +3032,7 @@ void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) {
...
@@ -3005,7 +3032,7 @@ void tscRetrieveDataRes(void *param, TAOS_RES *tres, int code) {
return
;
return
;
}
}
}
else
{
}
else
{
tscError
(
"0x%"
PRIx64
" sub:0x%"
PRIx64
" reach the max retry times, set global code:%s"
,
pParentSql
->
self
,
pSql
->
self
,
tstrerror
(
code
));
tscError
(
"0x%"
PRIx64
" sub:0x%"
PRIx64
" reach the max retry times
or no need to retry
, set global code:%s"
,
pParentSql
->
self
,
pSql
->
self
,
tstrerror
(
code
));
atomic_val_compare_exchange_32
(
&
pParentSql
->
res
.
code
,
TSDB_CODE_SUCCESS
,
code
);
// set global code and abort
atomic_val_compare_exchange_32
(
&
pParentSql
->
res
.
code
,
TSDB_CODE_SUCCESS
,
code
);
// set global code and abort
}
}
...
@@ -3129,8 +3156,6 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows)
...
@@ -3129,8 +3156,6 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows)
}
}
pParentObj
->
res
.
code
=
TSDB_CODE_SUCCESS
;
pParentObj
->
res
.
code
=
TSDB_CODE_SUCCESS
;
// pParentObj->cmd.parseFinished = false;
tscResetSqlCmd
(
&
pParentObj
->
cmd
,
false
);
tscResetSqlCmd
(
&
pParentObj
->
cmd
,
false
);
// in case of insert, redo parsing the sql string and build new submit data block for two reasons:
// in case of insert, redo parsing the sql string and build new submit data block for two reasons:
...
...
src/client/src/tscUtil.c
浏览文件 @
e0046dbb
...
@@ -4857,3 +4857,19 @@ SNewVgroupInfo createNewVgroupInfo(SVgroupMsg *pVgroupMsg) {
...
@@ -4857,3 +4857,19 @@ SNewVgroupInfo createNewVgroupInfo(SVgroupMsg *pVgroupMsg) {
return
info
;
return
info
;
}
}
void
tscRemoveTableMetaBuf
(
STableMetaInfo
*
pTableMetaInfo
,
uint64_t
id
)
{
char
fname
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
tNameExtractFullName
(
&
pTableMetaInfo
->
name
,
fname
);
int32_t
len
=
(
int32_t
)
strnlen
(
fname
,
TSDB_TABLE_FNAME_LEN
);
if
(
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
void
*
pv
=
taosCacheAcquireByKey
(
tscVgroupListBuf
,
fname
,
len
);
if
(
pv
!=
NULL
)
{
taosCacheRelease
(
tscVgroupListBuf
,
&
pv
,
true
);
}
}
taosHashRemove
(
tscTableMetaMap
,
fname
,
len
);
tscDebug
(
"0x%"
PRIx64
" remove table meta %s, numOfRemain:%d"
,
id
,
fname
,
(
int32_t
)
taosHashGetSize
(
tscTableMetaMap
));
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录