Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
42b23e64
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
42b23e64
编写于
5月 05, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(query): stop tsdb reader asap.
上级
dbf28b43
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
23 addition
and
31 deletion
+23
-31
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+23
-31
未找到文件。
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
42b23e64
...
...
@@ -21,10 +21,9 @@
#define getCurrentKeyInLastBlock(_r) ((_r)->currentKey)
typedef
enum
{
READER_STATUS_SUSPEND
=
0x1
,
READER_STATUS_SHOULD_STOP
=
0x2
,
READER_STATUS_NORMAL
=
0x3
,
}
EReaderExecStatus
;
READER_STATUS_SUSPEND
=
0x1
,
READER_STATUS_NORMAL
=
0x2
,
}
EReaderStatus
;
typedef
enum
{
EXTERNAL_ROWS_PREV
=
0x1
,
...
...
@@ -184,6 +183,7 @@ typedef struct STsdbReaderAttr {
STimeWindow
window
;
bool
freeBlock
;
SVersionRange
verRange
;
int16_t
order
;
}
STsdbReaderAttr
;
typedef
struct
SResultBlockInfo
{
...
...
@@ -196,7 +196,8 @@ struct STsdbReader {
STsdb
*
pTsdb
;
SVersionRange
verRange
;
TdThreadMutex
readerMutex
;
EReaderExecStatus
flag
;
EReaderStatus
flag
;
int32_t
code
;
uint64_t
suid
;
int16_t
order
;
EReadMode
readMode
;
...
...
@@ -2995,9 +2996,9 @@ static int32_t moveToNextFile(STsdbReader* pReader, SBlockNumber* pBlockNum, SAr
while
(
1
)
{
// only check here, since the iterate data in memory is very fast.
if
(
pReader
->
flag
==
READER_STATUS_SHOULD_STOP
)
{
tsdbWarn
(
"tsdb reader is stopped ASAP,
%s"
,
pReader
->
idStr
);
return
TSDB_CODE_SUCCESS
;
if
(
pReader
->
code
!=
TSDB_CODE_SUCCESS
)
{
tsdbWarn
(
"tsdb reader is stopped ASAP,
code:%s, %s"
,
strerror
(
pReader
->
code
)
,
pReader
->
idStr
);
return
pReader
->
code
;
}
bool
hasNext
=
false
;
...
...
@@ -3093,9 +3094,9 @@ static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) {
SSDataBlock
*
pResBlock
=
pReader
->
resBlockInfo
.
pResBlock
;
while
(
1
)
{
if
(
pReader
->
flag
==
READER_STATUS_SHOULD_STOP
)
{
tsdbWarn
(
"tsdb reader is stopped ASAP,
%s"
,
pReader
->
idStr
);
return
TSDB_CODE_SUCCESS
;
if
(
pReader
->
code
==
TSDB_CODE_SUCCESS
)
{
tsdbWarn
(
"tsdb reader is stopped ASAP,
code:%s, %s"
,
strerror
(
pReader
->
code
)
,
pReader
->
idStr
);
return
pReader
->
code
;
}
// load the last data block of current table
...
...
@@ -3246,7 +3247,7 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) {
}
}
return
code
;
return
(
pReader
->
code
!=
TSDB_CODE_SUCCESS
)
?
pReader
->
code
:
code
;
}
static
int32_t
doSumFileBlockRows
(
STsdbReader
*
pReader
,
SDataFReader
*
pFileReader
)
{
...
...
@@ -3395,9 +3396,9 @@ static int32_t buildBlockFromBufferSequentially(STsdbReader* pReader) {
STableUidList
*
pUidList
=
&
pStatus
->
uidList
;
while
(
1
)
{
if
(
pReader
->
flag
==
READER_STATUS_SHOULD_STOP
)
{
tsdbWarn
(
"tsdb reader is stopped ASAP,
%s"
,
pReader
->
idStr
);
return
TSDB_CODE_SUCCESS
;
if
(
pReader
->
code
==
TSDB_CODE_SUCCESS
)
{
tsdbWarn
(
"tsdb reader is stopped ASAP,
code:%s, %s"
,
strerror
(
pReader
->
code
)
,
pReader
->
idStr
);
return
pReader
->
code
;
}
STableBlockScanInfo
**
pBlockScanInfo
=
pStatus
->
pTableIter
;
...
...
@@ -3493,7 +3494,7 @@ static ERetrieveType doReadDataFromLastFiles(STsdbReader* pReader) {
terrno
=
0
;
code
=
doLoadLastBlockSequentially
(
pReader
);
if
(
code
!=
TSDB_CODE_SUCCESS
||
pReader
->
flag
==
READER_STATUS_SHOULD_STOP
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
terrno
=
code
;
return
TSDB_READ_RETURN
;
}
...
...
@@ -3507,8 +3508,7 @@ static ERetrieveType doReadDataFromLastFiles(STsdbReader* pReader) {
code
=
initForFirstBlockInFile
(
pReader
,
pBlockIter
);
// error happens or all the data files are completely checked
if
((
code
!=
TSDB_CODE_SUCCESS
)
||
(
pReader
->
status
.
loadFromFile
==
false
)
||
pReader
->
flag
==
READER_STATUS_SHOULD_STOP
)
{
if
((
code
!=
TSDB_CODE_SUCCESS
)
||
(
pReader
->
status
.
loadFromFile
==
false
))
{
terrno
=
code
;
return
TSDB_READ_RETURN
;
}
...
...
@@ -3536,13 +3536,9 @@ static int32_t buildBlockFromFiles(STsdbReader* pReader) {
}
code
=
doBuildDataBlock
(
pReader
);
if
(
code
!=
TSDB_CODE_SUCCESS
||
pRe
ader
->
flag
==
READER_STATUS_SHOULD_STOP
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
||
pRe
sBlock
->
info
.
rows
>
0
)
{
return
code
;
}
if
(
pResBlock
->
info
.
rows
>
0
)
{
return
TSDB_CODE_SUCCESS
;
}
}
while
(
1
)
{
...
...
@@ -3581,13 +3577,9 @@ static int32_t buildBlockFromFiles(STsdbReader* pReader) {
code
=
doBuildDataBlock
(
pReader
);
}
if
(
code
!=
TSDB_CODE_SUCCESS
||
pRe
ader
->
flag
==
READER_STATUS_SHOULD_STOP
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
||
pRe
sBlock
->
info
.
rows
>
0
)
{
return
code
;
}
if
(
pResBlock
->
info
.
rows
>
0
)
{
return
TSDB_CODE_SUCCESS
;
}
}
}
...
...
@@ -4849,8 +4841,8 @@ int32_t tsdbNextDataBlock(STsdbReader* pReader, bool* hasNext) {
*
hasNext
=
false
;
if
(
isEmptyQueryTimeWindow
(
&
pReader
->
window
)
||
pReader
->
step
==
EXTERNAL_ROWS_NEXT
)
{
return
code
;
if
(
isEmptyQueryTimeWindow
(
&
pReader
->
window
)
||
pReader
->
step
==
EXTERNAL_ROWS_NEXT
||
pReader
->
code
!=
TSDB_CODE_SUCCESS
)
{
return
(
pReader
->
code
!=
TSDB_CODE_SUCCESS
)
?
pReader
->
code
:
code
;
}
SReaderStatus
*
pStatus
=
&
pReader
->
status
;
...
...
@@ -5456,4 +5448,4 @@ void tsdbReaderSetId(STsdbReader* pReader, const char* idstr) {
pReader
->
idStr
=
taosStrdup
(
idstr
);
}
void
tsdbReaderSetCloseFlag
(
STsdbReader
*
pReader
)
{
pReader
->
flag
=
READER_STATUS_SHOULD_STOP
;
}
void
tsdbReaderSetCloseFlag
(
STsdbReader
*
pReader
)
{
pReader
->
code
=
TSDB_CODE_TSC_QUERY_CANCELLED
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录