Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
5a033eb7
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5a033eb7
编写于
3月 20, 2015
作者:
A
Alexey Arno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
dbms: Server: fixed issue with query cancellation. [#METR-14410]
上级
3fe14e7b
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
34 addition
and
20 deletion
+34
-20
dbms/include/DB/DataStreams/IProfilingBlockInputStream.h
dbms/include/DB/DataStreams/IProfilingBlockInputStream.h
+4
-4
dbms/include/DB/DataStreams/ParallelAggregatingBlockInputStream.h
...lude/DB/DataStreams/ParallelAggregatingBlockInputStream.h
+2
-1
dbms/include/DB/DataStreams/RemoteBlockInputStream.h
dbms/include/DB/DataStreams/RemoteBlockInputStream.h
+6
-6
dbms/include/DB/DataStreams/UnionBlockInputStream.h
dbms/include/DB/DataStreams/UnionBlockInputStream.h
+3
-2
dbms/include/DB/DataStreams/copyData.h
dbms/include/DB/DataStreams/copyData.h
+2
-1
dbms/src/DataStreams/IProfilingBlockInputStream.cpp
dbms/src/DataStreams/IProfilingBlockInputStream.cpp
+3
-2
dbms/src/DataStreams/copyData.cpp
dbms/src/DataStreams/copyData.cpp
+14
-4
未找到文件。
dbms/include/DB/DataStreams/IProfilingBlockInputStream.h
浏览文件 @
5a033eb7
...
...
@@ -7,9 +7,9 @@
#include <DB/Interpreters/ProcessList.h>
#include <DB/DataStreams/BlockStreamProfileInfo.h>
#include <DB/DataStreams/IBlockInputStream.h>
#include <atomic>
namespace
DB
{
...
...
@@ -96,9 +96,9 @@ public:
/** Требуется ли прервать получение данных.
*/
bool
isCancelled
()
bool
isCancelled
()
const
{
return
is_cancelled
;
return
is_cancelled
.
load
(
std
::
memory_order_seq_cst
)
;
}
/** Какие ограничения (и квоты) проверяются.
...
...
@@ -151,7 +151,7 @@ public:
protected:
BlockStreamProfileInfo
info
;
volatile
bool
is_cancelled
=
false
;
std
::
atomic
<
bool
>
is_cancelled
{
false
}
;
ProgressCallback
progress_callback
;
ProcessList
::
Element
*
process_list_elem
=
nullptr
;
...
...
dbms/include/DB/DataStreams/ParallelAggregatingBlockInputStream.h
浏览文件 @
5a033eb7
...
...
@@ -57,7 +57,8 @@ public:
void
cancel
()
override
{
if
(
!
__sync_bool_compare_and_swap
(
&
is_cancelled
,
false
,
true
))
bool
old_val
=
false
;
if
(
!
is_cancelled
.
compare_exchange_strong
(
old_val
,
true
,
std
::
memory_order_seq_cst
,
std
::
memory_order_relaxed
))
return
;
processor
.
cancel
();
...
...
dbms/include/DB/DataStreams/RemoteBlockInputStream.h
浏览文件 @
5a033eb7
...
...
@@ -80,7 +80,8 @@ public:
void
cancel
()
override
{
if
(
!
__sync_bool_compare_and_swap
(
&
is_cancelled
,
false
,
true
))
bool
old_val
=
false
;
if
(
!
is_cancelled
.
compare_exchange_strong
(
old_val
,
true
,
std
::
memory_order_seq_cst
,
std
::
memory_order_relaxed
))
return
;
if
(
hasNoQueryInProgress
()
||
hasThrownException
())
...
...
@@ -147,6 +148,9 @@ protected:
while
(
true
)
{
if
(
isCancelled
())
return
Block
();
Connection
::
Packet
packet
=
parallel_replicas
->
receivePacket
();
switch
(
packet
.
type
)
...
...
@@ -178,10 +182,6 @@ protected:
* и квот (например, на количество строчек для чтения).
*/
progressImpl
(
packet
.
progress
);
if
(
isQueryInProgress
()
&&
isCancelled
())
cancel
();
break
;
case
Protocol
::
Server
::
ProfileInfo
:
...
...
@@ -281,7 +281,7 @@ private:
void
tryCancel
(
const
char
*
reason
)
{
bool
old_val
=
false
;
if
(
!
was_cancelled
.
compare_exchange_strong
(
old_val
,
true
,
std
::
memory_order_seq_cst
,
std
::
memory_order_
seq_cst
))
if
(
!
was_cancelled
.
compare_exchange_strong
(
old_val
,
true
,
std
::
memory_order_seq_cst
,
std
::
memory_order_
relaxed
))
return
;
LOG_TRACE
(
log
,
"("
<<
parallel_replicas
->
dumpAddresses
()
<<
") "
<<
reason
);
...
...
dbms/include/DB/DataStreams/UnionBlockInputStream.h
浏览文件 @
5a033eb7
...
...
@@ -76,7 +76,8 @@ public:
*/
void
cancel
()
override
{
if
(
!
__sync_bool_compare_and_swap
(
&
is_cancelled
,
false
,
true
))
bool
old_val
=
false
;
if
(
!
is_cancelled
.
compare_exchange_strong
(
old_val
,
true
,
std
::
memory_order_seq_cst
,
std
::
memory_order_relaxed
))
return
;
//std::cerr << "cancelling\n";
...
...
@@ -164,7 +165,7 @@ protected:
void
readSuffix
()
override
{
//std::cerr << "readSuffix\n";
if
(
!
all_read
&&
!
is_cancelled
)
if
(
!
all_read
&&
!
is_cancelled
.
load
(
std
::
memory_order_seq_cst
)
)
throw
Exception
(
"readSuffix called before all data is read"
,
ErrorCodes
::
LOGICAL_ERROR
);
finalize
();
...
...
dbms/include/DB/DataStreams/copyData.h
浏览文件 @
5a033eb7
...
...
@@ -6,6 +6,7 @@
#include <DB/DataStreams/IRowInputStream.h>
#include <DB/DataStreams/IRowOutputStream.h>
#include <atomic>
namespace
DB
{
...
...
@@ -13,7 +14,7 @@ namespace DB
/** Копирует данные из InputStream в OutputStream
* (например, из БД в консоль и т. п.)
*/
void
copyData
(
IBlockInputStream
&
from
,
IBlockOutputStream
&
to
,
volatile
bool
*
is_cancelled
=
nullptr
);
void
copyData
(
IBlockInputStream
&
from
,
IBlockOutputStream
&
to
,
std
::
atomic
<
bool
>
*
is_cancelled
=
nullptr
);
void
copyData
(
IRowInputStream
&
from
,
IRowOutputStream
&
to
);
}
dbms/src/DataStreams/IProfilingBlockInputStream.cpp
浏览文件 @
5a033eb7
...
...
@@ -31,7 +31,7 @@ Block IProfilingBlockInputStream::read()
Block
res
;
if
(
is_cancelled
)
if
(
is_cancelled
.
load
(
std
::
memory_order_seq_cst
)
)
return
res
;
res
=
readImpl
();
...
...
@@ -292,7 +292,8 @@ void IProfilingBlockInputStream::progressImpl(const Progress & value)
void
IProfilingBlockInputStream
::
cancel
()
{
if
(
!
__sync_bool_compare_and_swap
(
&
is_cancelled
,
false
,
true
))
bool
old_val
=
false
;
if
(
!
is_cancelled
.
compare_exchange_strong
(
old_val
,
true
,
std
::
memory_order_seq_cst
,
std
::
memory_order_relaxed
))
return
;
for
(
auto
&
child
:
children
)
...
...
dbms/src/DataStreams/copyData.cpp
浏览文件 @
5a033eb7
...
...
@@ -7,20 +7,30 @@
namespace
DB
{
void
copyData
(
IBlockInputStream
&
from
,
IBlockOutputStream
&
to
,
volatile
bool
*
is_cancelled
)
namespace
{
bool
isAtomicSet
(
std
::
atomic
<
bool
>
*
val
)
{
return
((
val
!=
nullptr
)
&&
val
->
load
(
std
::
memory_order_seq_cst
));
}
}
void
copyData
(
IBlockInputStream
&
from
,
IBlockOutputStream
&
to
,
std
::
atomic
<
bool
>
*
is_cancelled
)
{
from
.
readPrefix
();
to
.
writePrefix
();
while
(
Block
block
=
from
.
read
())
{
if
(
is
_cancelled
&&
*
is_cancelled
)
if
(
is
AtomicSet
(
is_cancelled
)
)
break
;
to
.
write
(
block
);
}
if
(
is
_cancelled
&&
*
is_cancelled
)
if
(
is
AtomicSet
(
is_cancelled
)
)
return
;
/// Для вывода дополнительной информации в некоторых форматах.
...
...
@@ -33,7 +43,7 @@ void copyData(IBlockInputStream & from, IBlockOutputStream & to, volatile bool *
to
.
setExtremes
(
input
->
getExtremes
());
}
if
(
is
_cancelled
&&
*
is_cancelled
)
if
(
is
AtomicSet
(
is_cancelled
)
)
return
;
from
.
readSuffix
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录