Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
a4c1a4ee
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 搜索 >>
提交
a4c1a4ee
编写于
8月 10, 2017
作者:
V
Vitaliy Lyudvichenko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add requested changes. [#CLICKHOUSE-3207]
上级
7e90f34c
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
17 addition
and
14 deletion
+17
-14
dbms/src/Storages/MergeTree/ReplicatedMergeTreeCleanupThread.cpp
...c/Storages/MergeTree/ReplicatedMergeTreeCleanupThread.cpp
+16
-13
dbms/src/Storages/MergeTree/ReplicatedMergeTreeCleanupThread.h
...src/Storages/MergeTree/ReplicatedMergeTreeCleanupThread.h
+1
-1
未找到文件。
dbms/src/Storages/MergeTree/ReplicatedMergeTreeCleanupThread.cpp
浏览文件 @
a4c1a4ee
...
...
@@ -97,7 +97,7 @@ void ReplicatedMergeTreeCleanupThread::clearOldLogs()
{
ops
.
emplace_back
(
std
::
make_unique
<
zkutil
::
Op
::
Remove
>
(
storage
.
zookeeper_path
+
"/log/"
+
entries
[
i
],
-
1
));
if
(
ops
.
size
()
>
4
00
||
i
+
1
==
entries
.
size
())
if
(
ops
.
size
()
>
4
*
zkutil
::
MULTI_BATCH_SIZE
||
i
+
1
==
entries
.
size
())
{
/// Simultaneously with clearing the log, we check to see if replica was added since we received replicas list.
ops
.
emplace_back
(
std
::
make_unique
<
zkutil
::
Op
::
Check
>
(
storage
.
zookeeper_path
+
"/replicas"
,
stat
.
version
));
...
...
@@ -109,13 +109,15 @@ void ReplicatedMergeTreeCleanupThread::clearOldLogs()
LOG_DEBUG
(
log
,
"Removed "
<<
entries
.
size
()
<<
" old log entries: "
<<
entries
.
front
()
<<
" - "
<<
entries
.
back
());
}
namespace
{
/// Just a subset of zkutil::Stat fields required for the cache
struct
RequiredStat
{
Int64
ctime
;
int
numChildren
;
int64_t
ctime
=
0
;
int
32_t
numChildren
=
0
;
RequiredStat
()
=
default
;
RequiredStat
(
const
RequiredStat
&
)
=
default
;
...
...
@@ -125,12 +127,7 @@ struct RequiredStat
}
class
ReplicatedMergeTreeCleanupThread
::
NodesStatCache
:
public
std
::
map
<
String
,
RequiredStat
>
{
};
/// Just a node name with its ZooKeeper's stat
struct
ReplicatedMergeTreeCleanupThread
::
NodeWithStat
{
String
node
;
...
...
@@ -141,10 +138,14 @@ struct ReplicatedMergeTreeCleanupThread::NodeWithStat
static
bool
greaterByTime
(
const
NodeWithStat
&
lhs
,
const
NodeWithStat
&
rhs
)
{
return
(
lhs
.
stat
.
ctime
!=
rhs
.
stat
.
ctime
)
?
lhs
.
stat
.
ctime
>
rhs
.
stat
.
ctime
:
lhs
.
node
>
rhs
.
node
;
return
std
::
greater
<
void
>
()(
std
::
forward_as_tuple
(
lhs
.
stat
.
ctime
,
lhs
.
node
),
std
::
forward_as_tuple
(
rhs
.
stat
.
ctime
,
rhs
.
node
))
;
}
};
/// Use simple map node_name -> zkutil::Stat (only required fields) as the cache
/// It is not declared in the header explicitly to hide extra implementation dependent structs like RequiredStat
class
ReplicatedMergeTreeCleanupThread
::
NodesStatCache
:
public
std
::
map
<
String
,
RequiredStat
>
{};
void
ReplicatedMergeTreeCleanupThread
::
clearOldBlocks
()
{
...
...
@@ -158,7 +159,9 @@ void ReplicatedMergeTreeCleanupThread::clearOldBlocks()
/// Use ZooKeeper's first node (last according to time) timestamp as "current" time.
Int64
current_time
=
timed_blocks
.
front
().
stat
.
ctime
;
Int64
time_threshold
=
std
::
max
(
0L
,
current_time
-
static_cast
<
Int64
>
(
storage
.
data
.
settings
.
replicated_deduplication_window_seconds
));
Int64
time_threshold
=
std
::
max
(
0L
,
current_time
-
static_cast
<
Int64
>
(
1000
*
storage
.
data
.
settings
.
replicated_deduplication_window_seconds
));
/// Virtual node, all nodes that are "greater" than this one will be deleted
NodeWithStat
block_threshold
(
""
,
RequiredStat
(
time_threshold
));
size_t
current_deduplication_window
=
std
::
min
(
timed_blocks
.
size
(),
storage
.
data
.
settings
.
replicated_deduplication_window
);
...
...
@@ -208,7 +211,7 @@ void ReplicatedMergeTreeCleanupThread::clearOldBlocks()
if
(
num_nodes_not_deleted
)
{
LOG_ERROR
(
log
,
"There was a problem with deleting "
<<
num_nodes_not_deleted
<<
" (
from
"
<<
num_nodes_to_delete
<<
")"
LOG_ERROR
(
log
,
"There was a problem with deleting "
<<
num_nodes_not_deleted
<<
" (
of
"
<<
num_nodes_to_delete
<<
")"
<<
" old blocks from ZooKeeper, error: "
<<
zkutil
::
ZooKeeper
::
error2string
(
last_error_code
));
}
else
...
...
dbms/src/Storages/MergeTree/ReplicatedMergeTreeCleanupThread.h
浏览文件 @
a4c1a4ee
...
...
@@ -40,7 +40,7 @@ private:
struct
NodeWithStat
;
std
::
unique_ptr
<
NodesStatCache
>
cached_block_stats
;
/// Returns list of blocks
with stat sorted by ctime
/// Returns list of blocks
(with their stat) sorted by ctime in descending order
void
getBlocksSortedByTime
(
std
::
shared_ptr
<
zkutil
::
ZooKeeper
>
&
zookeeper
,
std
::
vector
<
NodeWithStat
>
&
timed_blocks
);
/// TODO Removing old quorum/failed_parts
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录