Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
4b41c527
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,体验更适合开发者的 AI 搜索 >>
提交
4b41c527
编写于
8月 09, 2016
作者:
A
Alexey Milovidov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Attempt to improve performance of replication queue processing [#METR-22352].
上级
bb5bdd09
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
52 addition
and
6 deletion
+52
-6
dbms/include/DB/Storages/StorageReplicatedMergeTree.h
dbms/include/DB/Storages/StorageReplicatedMergeTree.h
+7
-0
dbms/src/Storages/StorageReplicatedMergeTree.cpp
dbms/src/Storages/StorageReplicatedMergeTree.cpp
+45
-6
未找到文件。
dbms/include/DB/Storages/StorageReplicatedMergeTree.h
浏览文件 @
4b41c527
...
...
@@ -419,6 +419,13 @@ private:
*/
String
findReplicaHavingPart
(
const
String
&
part_name
,
bool
active
);
/** Find replica having specified part or any part that covers it.
* If active = true, consider only active replicas.
* If found, returns replica name and set 'out_covering_part_name' to name of found largest covering part.
* If not found, returns empty string.
*/
String
findReplicaHavingCoveringPart
(
const
String
&
part_name
,
bool
active
,
String
&
out_covering_part_name
);
/** Скачать указанный кусок с указанной реплики.
* Если to_detached, то кусок помещается в директорию detached.
* Если quorum != 0, то обновляется узел для отслеживания кворума.
...
...
dbms/src/Storages/StorageReplicatedMergeTree.cpp
浏览文件 @
4b41c527
...
...
@@ -1208,7 +1208,8 @@ bool StorageReplicatedMergeTree::executeLogEntry(const LogEntry & entry, Backgro
try
{
replica
=
findReplicaHavingPart
(
entry
.
new_part_name
,
true
);
String
covering_part
;
replica
=
findReplicaHavingCoveringPart
(
entry
.
new_part_name
,
true
,
covering_part
);
if
(
replica
.
empty
()
&&
entry
.
type
==
LogEntry
::
ATTACH_PART
)
{
...
...
@@ -1223,7 +1224,7 @@ bool StorageReplicatedMergeTree::executeLogEntry(const LogEntry & entry, Backgro
/// Подождём, пока реплика-инициатор подцепит кусок.
waitForReplicaToProcessLogEntry
(
entry
.
source_replica
,
entry
);
replica
=
findReplicaHaving
Part
(
entry
.
new_part_name
,
true
);
replica
=
findReplicaHaving
CoveringPart
(
entry
.
new_part_name
,
true
,
covering_part
);
}
if
(
replica
.
empty
())
...
...
@@ -1351,11 +1352,11 @@ bool StorageReplicatedMergeTree::executeLogEntry(const LogEntry & entry, Backgro
if
(
replica
.
empty
())
{
ProfileEvents
::
increment
(
ProfileEvents
::
ReplicatedPartFailedFetches
);
throw
Exception
(
"No active replica has part "
+
entry
.
new_part_name
,
ErrorCodes
::
NO_REPLICA_HAS_PART
);
throw
Exception
(
"No active replica has part "
+
entry
.
new_part_name
+
" or covering part"
,
ErrorCodes
::
NO_REPLICA_HAS_PART
);
}
}
fetchPart
(
entry
.
new_part_name
,
zookeeper_path
+
"/replicas/"
+
replica
,
false
,
entry
.
quorum
);
fetchPart
(
covering_part
,
zookeeper_path
+
"/replicas/"
+
replica
,
false
,
entry
.
quorum
);
if
(
entry
.
type
==
LogEntry
::
MERGE_PARTS
)
ProfileEvents
::
increment
(
ProfileEvents
::
ReplicatedPartFetchesOfMerged
);
...
...
@@ -1872,7 +1873,7 @@ String StorageReplicatedMergeTree::findReplicaHavingPart(const String & part_nam
auto
zookeeper
=
getZooKeeper
();
Strings
replicas
=
zookeeper
->
getChildren
(
zookeeper_path
+
"/replicas"
);
///
Из реплик, у которых есть кусок, выберем одну равновероятно
.
///
Select replicas in uniformly random order
.
std
::
random_shuffle
(
replicas
.
begin
(),
replicas
.
end
());
for
(
const
String
&
replica
:
replicas
)
...
...
@@ -1884,7 +1885,45 @@ String StorageReplicatedMergeTree::findReplicaHavingPart(const String & part_nam
/// Конечно, реплика может перестать быть активной или даже перестать существовать после возврата из этой функции.
}
return
""
;
return
{};
}
String
StorageReplicatedMergeTree
::
findReplicaHavingCoveringPart
(
const
String
&
part_name
,
bool
active
,
String
&
out_covering_part_name
)
{
auto
zookeeper
=
getZooKeeper
();
Strings
replicas
=
zookeeper
->
getChildren
(
zookeeper_path
+
"/replicas"
);
/// Select replicas in uniformly random order.
std
::
random_shuffle
(
replicas
.
begin
(),
replicas
.
end
());
for
(
const
String
&
replica
:
replicas
)
{
if
(
active
&&
!
zookeeper
->
exists
(
zookeeper_path
+
"/replicas/"
+
replica
+
"/is_active"
))
continue
;
String
largest_part_found
;
Strings
parts
=
zookeeper
->
getChildren
(
zookeeper_path
+
"/replicas/"
+
replica
+
"/parts"
);
for
(
const
String
&
part_on_replica
:
parts
)
{
if
(
part_on_replica
==
part_name
||
ActiveDataPartSet
::
contains
(
part_on_replica
,
part_name
))
{
if
(
largest_part_found
.
empty
()
||
ActiveDataPartSet
::
contains
(
part_on_replica
,
largest_part_found
))
{
largest_part_found
=
part_on_replica
;
}
}
}
if
(
!
largest_part_found
.
empty
())
{
out_covering_part_name
=
largest_part_found
;
return
replica_name
;
}
}
return
{};
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录