Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
7d732343
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,发现更多精彩内容 >>
提交
7d732343
编写于
6月 22, 2017
作者:
A
Alexey Milovidov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed error in prev. revision [#CLICKHOUSE-3091].
上级
b845b181
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
24 addition
and
29 deletion
+24
-29
dbms/src/Storages/StorageReplicatedMergeTree.cpp
dbms/src/Storages/StorageReplicatedMergeTree.cpp
+24
-24
dbms/src/Storages/StorageReplicatedMergeTree.h
dbms/src/Storages/StorageReplicatedMergeTree.h
+0
-5
未找到文件。
dbms/src/Storages/StorageReplicatedMergeTree.cpp
浏览文件 @
7d732343
...
...
@@ -1614,31 +1614,12 @@ bool StorageReplicatedMergeTree::queueTask()
}
bool
StorageReplicatedMergeTree
::
canMergeParts
(
static
bool
canMergePartsAccordingToZooKeeperInfo
(
const
MergeTreeData
::
DataPartPtr
&
left
,
const
MergeTreeData
::
DataPartPtr
&
right
)
const
MergeTreeData
::
DataPartPtr
&
right
,
zkutil
::
ZooKeeperPtr
&&
zookeeper
,
const
String
&
zookeeper_path
,
const
MergeTreeData
&
data
)
{
/** It can take a long time to determine whether it is possible to merge two adjacent parts.
* Two adjacent parts can be merged if all block numbers between their numbers are not used (abandoned).
* This means that another part can not be inserted between these parts.
*
* But if the numbers of adjacent blocks differ sufficiently strongly (usually if there are many "abandoned" blocks between them),
* then too many readings are made from ZooKeeper to find out if it's possible to merge them.
*
* Let's use a statement that if a couple of parts were possible to merge, and their merge is not yet planned,
* then now they can be merged, and we will remember this state (if the parameter `memo` is specified),
* not to make many times the same requests to ZooKeeper.
*
* TODO I wonder how this is combined with DROP PARTITION and then ATTACH PARTITION.
*/
/// If any of the parts is already going to be merge into a larger one, do not agree to merge it.
if
(
queue
.
partWillBeMergedOrMergesDisabled
(
left
->
name
)
||
(
left
.
get
()
!=
right
.
get
()
&&
queue
.
partWillBeMergedOrMergesDisabled
(
right
->
name
)))
return
false
;
String
month_name
=
left
->
name
.
substr
(
0
,
6
);
auto
zookeeper
=
getZooKeeper
();
/// You can not merge parts, among which is a part for which the quorum is unsatisfied.
/// Note: theoretically, this could be resolved. But this will make logic more complex.
...
...
@@ -1704,6 +1685,20 @@ bool StorageReplicatedMergeTree::canMergeParts(
}
/** It can take a long time to determine whether it is possible to merge two adjacent parts.
* Two adjacent parts can be merged if all block numbers between their numbers are not used (abandoned).
* This means that another part can not be inserted between these parts.
*
* But if the numbers of adjacent blocks differ much (usually if there are many "abandoned" blocks between them),
* then too many read requests are made to ZooKeeper to find out if it's possible to merge them.
*
* Let's use a statement that if a couple of parts were possible to merge, and their merge is not yet planned,
* then now they can be merged, and we will remember this state,
* not to send multiple identical requests to ZooKeeper.
*
* TODO This works incorrectly with DROP PARTITION and then ATTACH PARTITION.
*/
/** Cache for function, that returns bool.
* If function returned true, cache it forever.
* If function returned false, cache it for exponentially growing time.
...
...
@@ -1784,7 +1779,7 @@ void StorageReplicatedMergeTree::mergeSelectingThread()
auto
uncached_merging_predicate
=
[
this
](
const
MergeTreeData
::
DataPartPtr
&
left
,
const
MergeTreeData
::
DataPartPtr
&
right
)
{
return
canMergeParts
(
left
,
right
);
return
canMergeParts
AccordingToZooKeeperInfo
(
left
,
right
,
getZooKeeper
(),
zookeeper_path
,
data
);
};
auto
merging_predicate_args_to_key
=
[](
const
MergeTreeData
::
DataPartPtr
&
left
,
const
MergeTreeData
::
DataPartPtr
&
right
)
...
...
@@ -1800,6 +1795,11 @@ void StorageReplicatedMergeTree::mergeSelectingThread()
auto
can_merge
=
[
&
]
(
const
MergeTreeData
::
DataPartPtr
&
left
,
const
MergeTreeData
::
DataPartPtr
&
right
)
{
/// If any of the parts is already going to be merge into a larger one, do not agree to merge it.
if
(
queue
.
partWillBeMergedOrMergesDisabled
(
left
->
name
)
||
(
left
.
get
()
!=
right
.
get
()
&&
queue
.
partWillBeMergedOrMergesDisabled
(
right
->
name
)))
return
false
;
return
cached_merging_predicate
.
get
(
now
,
uncached_merging_predicate
,
merging_predicate_args_to_key
,
left
,
right
);
};
...
...
@@ -2424,7 +2424,7 @@ bool StorageReplicatedMergeTree::optimize(const String & partition, bool final,
auto
can_merge
=
[
this
]
(
const
MergeTreeData
::
DataPartPtr
&
left
,
const
MergeTreeData
::
DataPartPtr
&
right
)
{
return
canMergeParts
(
left
,
right
);
return
canMergeParts
AccordingToZooKeeperInfo
(
left
,
right
,
getZooKeeper
(),
zookeeper_path
,
data
);
};
pullLogsToQueue
();
...
...
dbms/src/Storages/StorageReplicatedMergeTree.h
浏览文件 @
7d732343
...
...
@@ -418,11 +418,6 @@ private:
*/
void
mergeSelectingThread
();
/// Is it possible to merge parts in the specified range?
bool
canMergeParts
(
const
MergeTreeData
::
DataPartPtr
&
left
,
const
MergeTreeData
::
DataPartPtr
&
right
);
/** Write the selected parts to merge into the log,
* Call when merge_selecting_mutex is locked.
* Returns false if any part is not in ZK.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录