Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
f20f3f21
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,发现更多精彩内容 >>
提交
f20f3f21
编写于
1月 15, 2018
作者:
V
Vitaliy Lyudvichenko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update clusters in SYSTEM DROP DNS query. [#CLICKHOUSE-3478]
上级
9ed1fdbb
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
30 addition
and
10 deletion
+30
-10
dbms/src/Interpreters/Context.cpp
dbms/src/Interpreters/Context.cpp
+12
-6
dbms/src/Interpreters/Context.h
dbms/src/Interpreters/Context.h
+1
-0
dbms/src/Interpreters/InterpreterSystemQuery.cpp
dbms/src/Interpreters/InterpreterSystemQuery.cpp
+2
-0
dbms/tests/integration/test_system_queries/test.py
dbms/tests/integration/test_system_queries/test.py
+15
-4
未找到文件。
dbms/src/Interpreters/Context.cpp
浏览文件 @
f20f3f21
...
...
@@ -1348,15 +1348,21 @@ std::shared_ptr<Cluster> Context::tryGetCluster(const std::string & cluster_name
}
void
Context
::
reloadClusterConfig
()
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
shared
->
clusters_mutex
);
auto
&
config
=
shared
->
clusters_config
?
*
shared
->
clusters_config
:
getConfigRef
();
shared
->
clusters
=
std
::
make_unique
<
Clusters
>
(
config
,
settings
);
}
Clusters
&
Context
::
getClusters
()
const
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
shared
->
clusters_mutex
);
if
(
!
shared
->
clusters
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
shared
->
clusters_mutex
);
if
(
!
shared
->
clusters
)
{
auto
&
config
=
shared
->
clusters_config
?
*
shared
->
clusters_config
:
getConfigRef
();
shared
->
clusters
=
std
::
make_unique
<
Clusters
>
(
config
,
settings
);
}
auto
&
config
=
shared
->
clusters_config
?
*
shared
->
clusters_config
:
getConfigRef
();
shared
->
clusters
=
std
::
make_unique
<
Clusters
>
(
config
,
settings
);
}
return
*
shared
->
clusters
;
...
...
dbms/src/Interpreters/Context.h
浏览文件 @
f20f3f21
...
...
@@ -318,6 +318,7 @@ public:
Clusters
&
getClusters
()
const
;
std
::
shared_ptr
<
Cluster
>
getCluster
(
const
std
::
string
&
cluster_name
)
const
;
std
::
shared_ptr
<
Cluster
>
tryGetCluster
(
const
std
::
string
&
cluster_name
)
const
;
void
reloadClusterConfig
();
void
setClustersConfig
(
const
ConfigurationPtr
&
config
);
Compiler
&
getCompiler
();
...
...
dbms/src/Interpreters/InterpreterSystemQuery.cpp
浏览文件 @
f20f3f21
...
...
@@ -75,6 +75,8 @@ BlockIO InterpreterSystemQuery::execute()
break
;
case
Type
::
DROP_DNS_CACHE
:
DNSCache
::
instance
().
drop
();
/// Reinitialize clusters to update their resolved_addresses
context
.
reloadClusterConfig
();
break
;
case
Type
::
DROP_MARK_CACHE
:
context
.
dropMarkCache
();
...
...
dbms/tests/integration/test_system_queries/test.py
浏览文件 @
f20f3f21
...
...
@@ -9,6 +9,7 @@ from contextlib import contextmanager
sys
.
path
.
insert
(
0
,
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))))
from
helpers.cluster
import
ClickHouseCluster
from
helpers.test_tools
import
TSV
from
helpers.client
import
QueryRuntimeException
@
pytest
.
fixture
(
scope
=
"module"
)
...
...
@@ -24,10 +25,12 @@ def started_cluster():
instance
.
query
(
'CREATE DATABASE dictionaries ENGINE = Dictionary'
)
instance
.
query
(
'CREATE TABLE dictionary_source (id UInt64, value UInt8) ENGINE = Memory'
)
#print instance.query('SELECT * FROM system.dictionaries FORMAT Vertical')
print
"Started "
,
instance
.
ip_address
yield
cluster
finally
:
pass
cluster
.
shutdown
()
...
...
@@ -54,13 +57,21 @@ def test_SYSTEM_RELOAD_DICTIONARY(started_cluster):
def
test_DROP_DNS_CACHE
(
started_cluster
):
instance
=
cluster
.
instances
[
'ch1'
]
with
pytest
.
raises
(
Exception
):
instance
.
query
(
"SELECT * FROM remote('aperol', 'system', 'one')"
)
instance
.
exec_in_container
([
'bash'
,
'-c'
,
'echo 127.255.255.255 lost_host > /etc/hosts'
],
privileged
=
True
,
user
=
'root'
)
instance
.
exec_in_container
([
'bash'
,
'-c'
,
'echo 127.0.0.1 aperol >> /etc/hosts'
],
privileged
=
True
,
user
=
'root'
)
with
pytest
.
raises
(
QueryRuntimeException
):
instance
.
query
(
"SELECT * FROM remote('lost_host', 'system', 'one')"
)
instance
.
query
(
"CREATE TABLE distributed_lost_host (dummy UInt8) ENGINE = Distributed(lost_host_cluster, 'system', 'one')"
)
with
pytest
.
raises
(
QueryRuntimeException
):
instance
.
query
(
"SELECT * FROM distributed_lost_host"
)
instance
.
exec_in_container
([
'bash'
,
'-c'
,
'echo 127.0.0.1 lost_host > /etc/hosts'
],
privileged
=
True
,
user
=
'root'
)
instance
.
query
(
"SYSTEM DROP DNS CACHE"
)
instance
.
query
(
"SELECT * FROM remote('aperol', 'system', 'one')"
)
instance
.
query
(
"SELECT * FROM remote('lost_host', 'system', 'one')"
)
instance
.
query
(
"SELECT * FROM distributed_lost_host"
)
assert
TSV
(
instance
.
query
(
"SELECT DISTINCT host_name, host_address FROM system.clusters"
))
==
TSV
(
"lost_host
\t
127.0.0.1
\n
"
)
if
__name__
==
'__main__'
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录