Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
1d212862
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,发现更多精彩内容 >>
未验证
提交
1d212862
编写于
12月 28, 2019
作者:
A
alexey-milovidov
提交者:
GitHub
12月 28, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #8318 from excitoon-favorites/replicatedalterttl
Fixed ALTER TTL for replicated tables
上级
9e8c3acf
4569a68e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
83 addition
and
1 deletion
+83
-1
dbms/src/Storages/StorageReplicatedMergeTree.cpp
dbms/src/Storages/StorageReplicatedMergeTree.cpp
+1
-1
dbms/tests/integration/test_ttl_move/test.py
dbms/tests/integration/test_ttl_move/test.py
+82
-0
未找到文件。
dbms/src/Storages/StorageReplicatedMergeTree.cpp
浏览文件 @
1d212862
...
...
@@ -534,7 +534,7 @@ void StorageReplicatedMergeTree::setTableStructure(ColumnsDescription new_column
if
(
metadata_diff
.
ttl_table_changed
)
{
Parser
Expression
parser
;
Parser
TTLExpressionList
parser
;
new_ttl_table_ast
=
parseQuery
(
parser
,
metadata_diff
.
new_ttl_table
,
0
);
}
...
...
dbms/tests/integration/test_ttl_move/test.py
浏览文件 @
1d212862
...
...
@@ -538,3 +538,85 @@ def test_ttls_do_not_work_after_alter(started_cluster, name, engine, positive):
finally
:
node1
.
query
(
"DROP TABLE IF EXISTS {}"
.
format
(
name
))
@
pytest
.
mark
.
parametrize
(
"name,engine,positive"
,
[
(
"mt_test_alter_multiple_ttls_positive"
,
"MergeTree()"
,
True
),
(
"mt_replicated_test_alter_multiple_ttls_positive"
,
"ReplicatedMergeTree('/clickhouse/replicated_test_alter_multiple_ttls_positive', '1')"
,
True
),
(
"mt_test_alter_multiple_ttls_negative"
,
"MergeTree()"
,
False
),
(
"mt_replicated_test_alter_multiple_ttls_negative"
,
"ReplicatedMergeTree('/clickhouse/replicated_test_alter_multiple_ttls_negative', '1')"
,
False
),
])
def
test_alter_multiple_ttls
(
started_cluster
,
name
,
engine
,
positive
):
"""Copyright 2019, Altinity LTD
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License."""
"""Check that when multiple TTL expressions are set
and before any parts are inserted the TTL expressions
are changed with ALTER command then all old
TTL expressions are removed and the
the parts are moved to the specified disk or volume or
deleted if the new TTL expression is triggered
and are not moved or deleted when it is not.
"""
now
=
time
.
time
()
try
:
node1
.
query
(
"""
CREATE TABLE {name} (
p1 Int64,
s1 String,
d1 DateTime
) ENGINE = {engine}
ORDER BY tuple()
PARTITION BY p1
TTL d1 + INTERVAL 30 SECOND TO DISK 'jbod2',
d1 + INTERVAL 60 SECOND TO VOLUME 'external'
SETTINGS storage_policy='jbods_with_external', merge_with_ttl_timeout=0
"""
.
format
(
name
=
name
,
engine
=
engine
))
node1
.
query
(
"""
ALTER TABLE {name} MODIFY
TTL d1 + INTERVAL 0 SECOND TO DISK 'jbod2',
d1 + INTERVAL 5 SECOND TO VOLUME 'external',
d1 + INTERVAL 10 SECOND DELETE
"""
.
format
(
name
=
name
))
for
p
in
range
(
3
):
data
=
[]
# 6MB in total
now
=
time
.
time
()
for
i
in
range
(
2
):
p1
=
p
s1
=
get_random_string
(
1024
*
1024
)
# 1MB
d1
=
now
-
1
if
i
>
0
or
positive
else
now
+
300
data
.
append
(
"({}, '{}', toDateTime({}))"
.
format
(
p1
,
s1
,
d1
))
node1
.
query
(
"INSERT INTO {name} (p1, s1, d1) VALUES {values}"
.
format
(
name
=
name
,
values
=
","
.
join
(
data
)))
used_disks
=
get_used_disks_for_table
(
node1
,
name
)
assert
set
(
used_disks
)
==
{
"jbod2"
}
if
positive
else
{
"jbod1"
,
"jbod2"
}
assert
node1
.
query
(
"SELECT count() FROM {name}"
.
format
(
name
=
name
)).
splitlines
()
==
[
"6"
]
time
.
sleep
(
5
)
used_disks
=
get_used_disks_for_table
(
node1
,
name
)
assert
set
(
used_disks
)
==
{
"external"
}
if
positive
else
{
"jbod1"
,
"jbod2"
}
assert
node1
.
query
(
"SELECT count() FROM {name}"
.
format
(
name
=
name
)).
splitlines
()
==
[
"6"
]
time
.
sleep
(
5
)
node1
.
query
(
"OPTIMIZE TABLE {name} FINAL"
.
format
(
name
=
name
))
assert
node1
.
query
(
"SELECT count() FROM {name}"
.
format
(
name
=
name
)).
splitlines
()
==
[
"0"
]
if
positive
else
[
"3"
]
finally
:
node1
.
query
(
"DROP TABLE IF EXISTS {name}"
.
format
(
name
=
name
))
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录