Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
a8974f87
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,发现更多精彩内容 >>
提交
a8974f87
编写于
8月 27, 2018
作者:
V
VadimPE
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
CLICKHOUSE-3847 add Coordinator
上级
be2d8216
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
19 addition
and
19 deletion
+19
-19
dbms/src/Storages/MergeTree/ReplicatedMergeTreeCleanupThread.cpp
...c/Storages/MergeTree/ReplicatedMergeTreeCleanupThread.cpp
+6
-6
dbms/src/Storages/StorageReplicatedMergeTree.cpp
dbms/src/Storages/StorageReplicatedMergeTree.cpp
+12
-12
dbms/src/Storages/StorageReplicatedMergeTree.h
dbms/src/Storages/StorageReplicatedMergeTree.h
+1
-1
未找到文件。
dbms/src/Storages/MergeTree/ReplicatedMergeTreeCleanupThread.cpp
浏览文件 @
a8974f87
...
...
@@ -104,7 +104,7 @@ void ReplicatedMergeTreeCleanupThread::clearOldLogs()
for
(
const
String
&
replica
:
replicas
)
{
zkutil
::
Stat
host_stat
;
Coordination
::
Stat
host_stat
;
zookeeper
->
get
(
storage
.
zookeeper_path
+
"/replicas/"
+
replica
+
"/host"
,
&
host_stat
);
String
pointer
=
zookeeper
->
get
(
storage
.
zookeeper_path
+
"/replicas/"
+
replica
+
"/log_pointer"
);
if
(
pointer
.
empty
())
...
...
@@ -163,7 +163,7 @@ void ReplicatedMergeTreeCleanupThread::clearOldLogs()
min_saved_log_pointer
=
std
::
min
(
min_saved_log_pointer
,
log_pointer
);
}
if
(
recovering_replicas
.
size
()
!=
0
)
if
(
!
recovering_replicas
.
empty
()
)
min_saved_log_pointer
=
std
::
min
(
min_saved_log_pointer
,
min_inactive_log_pointer
);
/// We will not touch the last `min_replicated_logs_to_keep` records.
...
...
@@ -205,17 +205,17 @@ void ReplicatedMergeTreeCleanupThread::markLostReplicas(const std::unordered_map
struct
LostReplicaInfo
{
String
name
;
zkutil
::
Requests
requests
;
Coordination
::
Requests
requests
;
};
std
::
vector
<
zkutil
::
Requests
>
requests
;
std
::
vector
<
Coordination
::
Requests
>
requests
;
std
::
vector
<
LostReplicaInfo
>
lost_replicas_info
;
std
::
vector
<
std
::
pair
<
LostReplicaInfo
,
zkutil
::
ZooKeeper
::
FutureMulti
>>
info_and_future
;
for
(
auto
pair
:
log_pointers_lost_replicas
)
{
String
replica
=
pair
.
first
;
zkutil
::
Requests
ops
;
Coordination
::
Requests
ops
;
/// If host changed version we can not mark replicas, because replica started to be active.
ops
.
emplace_back
(
zkutil
::
makeCheckRequest
(
storage
.
zookeeper_path
+
"/replicas/"
+
replica
+
"/host"
,
host_versions_inactive_replicas
.
at
(
replica
)));
ops
.
emplace_back
(
zkutil
::
makeSetRequest
(
storage
.
zookeeper_path
+
"/replicas/"
+
replica
+
"/is_lost"
,
"1"
,
-
1
));
...
...
@@ -231,7 +231,7 @@ void ReplicatedMergeTreeCleanupThread::markLostReplicas(const std::unordered_map
for
(
auto
&
pair
:
info_and_future
)
{
auto
multi_responses
=
pair
.
second
.
get
();
if
(
multi_responses
.
responses
[
0
]
->
error
==
ZooKeeperImpl
::
ZooKeepe
r
::
ZBADVERSION
)
if
(
multi_responses
.
responses
[
0
]
->
error
==
Coordination
::
Erro
r
::
ZBADVERSION
)
throw
Exception
(
pair
.
first
.
name
+
" became active, when we clear log"
,
DB
::
ErrorCodes
::
REPLICA_STATUS_CHANGED
);
zkutil
::
KeeperMultiException
::
check
(
multi_responses
.
error
,
pair
.
first
.
requests
,
multi_responses
.
responses
);
}
...
...
dbms/src/Storages/StorageReplicatedMergeTree.cpp
浏览文件 @
a8974f87
...
...
@@ -596,13 +596,13 @@ void StorageReplicatedMergeTree::createReplica()
do
{
zkutil
::
Stat
replicas_stat
;
Coordination
::
Stat
replicas_stat
;
String
last_added_replica
=
zookeeper
->
get
(
zookeeper_path
+
"/replicas"
,
&
replicas_stat
);
String
is_lost_value
=
last_added_replica
==
""
?
"0"
:
"1"
;
zkutil
::
Requests
ops
;
zkutil
::
Responses
resps
;
Coordination
::
Requests
ops
;
Coordination
::
Responses
resps
;
ops
.
emplace_back
(
zkutil
::
makeCreateRequest
(
replica_path
,
""
,
zkutil
::
CreateMode
::
Persistent
));
ops
.
emplace_back
(
zkutil
::
makeCreateRequest
(
replica_path
+
"/host"
,
""
,
zkutil
::
CreateMode
::
Persistent
));
ops
.
emplace_back
(
zkutil
::
makeCreateRequest
(
replica_path
+
"/log_pointer"
,
""
,
zkutil
::
CreateMode
::
Persistent
));
...
...
@@ -615,13 +615,13 @@ void StorageReplicatedMergeTree::createReplica()
ops
.
emplace_back
(
zkutil
::
makeSetRequest
(
zookeeper_path
+
"/replicas"
,
"last added replica: "
+
replica_name
,
replicas_stat
.
version
));
code
=
zookeeper
->
tryMulti
(
ops
,
resps
);
if
(
code
==
ZooKeeperImpl
::
ZooKeepe
r
::
ZNODEEXISTS
)
if
(
code
==
Coordination
::
Erro
r
::
ZNODEEXISTS
)
throw
Exception
(
"Replica "
+
replica_path
+
" already exists."
,
ErrorCodes
::
REPLICA_IS_ALREADY_EXIST
);
else
if
(
code
==
ZooKeeperImpl
::
ZooKeepe
r
::
ZBADVERSION
)
else
if
(
code
==
Coordination
::
Erro
r
::
ZBADVERSION
)
LOG_ERROR
(
log
,
"Retry createReplica(), because some replicas were created"
);
else
zkutil
::
KeeperMultiException
::
check
(
code
,
ops
,
resps
);
}
while
(
code
==
ZooKeeperImpl
::
ZooKeepe
r
::
ZBADVERSION
);
}
while
(
code
==
Coordination
::
Erro
r
::
ZBADVERSION
);
}
...
...
@@ -1950,7 +1950,7 @@ bool StorageReplicatedMergeTree::executeReplaceRange(const LogEntry & entry)
}
void
StorageReplicatedMergeTree
::
cloneReplica
(
const
String
&
source_replica
,
zkutil
::
Stat
source_is_lost_stat
,
zkutil
::
ZooKeeperPtr
&
zookeeper
)
void
StorageReplicatedMergeTree
::
cloneReplica
(
const
String
&
source_replica
,
Coordination
::
Stat
source_is_lost_stat
,
zkutil
::
ZooKeeperPtr
&
zookeeper
)
{
LOG_INFO
(
log
,
"Will mimic "
<<
source_replica
);
...
...
@@ -1981,7 +1981,7 @@ void StorageReplicatedMergeTree::cloneReplica(const String & source_replica, zku
String
raw_log_pointer
=
zookeeper
->
get
(
source_path
+
"/log_pointer"
);
zkutil
::
Requests
ops
;
Coordination
::
Requests
ops
;
ops
.
push_back
(
zkutil
::
makeSetRequest
(
replica_path
+
"/log_pointer"
,
raw_log_pointer
,
-
1
));
/// For support old versions CH.
...
...
@@ -1993,12 +1993,12 @@ void StorageReplicatedMergeTree::cloneReplica(const String & source_replica, zku
else
ops
.
push_back
(
zkutil
::
makeCheckRequest
(
source_path
+
"/is_lost"
,
source_is_lost_stat
.
version
));
zkutil
::
Responses
resp
;
Coordination
::
Responses
resp
;
auto
error
=
zookeeper
->
tryMulti
(
ops
,
resp
);
if
(
error
==
ZooKeeperImpl
::
ZooKeepe
r
::
ZBADVERSION
)
if
(
error
==
Coordination
::
Erro
r
::
ZBADVERSION
)
throw
Exception
(
"Can not clone replica, because a "
+
source_path
+
" became lost"
,
ErrorCodes
::
REPLICA_STATUS_CHANGED
);
else
if
(
error
==
ZooKeeperImpl
::
ZooKeepe
r
::
ZNODEEXISTS
)
else
if
(
error
==
Coordination
::
Erro
r
::
ZNODEEXISTS
)
throw
Exception
(
"Can not clone replica, because the ClickHouse server updated to new version"
,
ErrorCodes
::
REPLICA_STATUS_CHANGED
);
else
zkutil
::
KeeperMultiException
::
check
(
error
,
ops
,
resp
);
...
...
@@ -2060,7 +2060,7 @@ void StorageReplicatedMergeTree::cloneReplicaIfNeeded(zkutil::ZooKeeperPtr zooke
}
String
source_replica
;
zkutil
::
Stat
source_is_lost_stat
;
Coordination
::
Stat
source_is_lost_stat
;
source_is_lost_stat
.
version
=
-
1
;
for
(
const
String
&
replica_name
:
zookeeper
->
getChildren
(
zookeeper_path
+
"/replicas"
))
...
...
dbms/src/Storages/StorageReplicatedMergeTree.h
浏览文件 @
a8974f87
...
...
@@ -402,7 +402,7 @@ private:
/** Clone data from another replica.
* If replica can not be cloned throw Exception.
*/
void
cloneReplica
(
const
String
&
source_replica
,
zkutil
::
Stat
source_is_lost_stat
,
zkutil
::
ZooKeeperPtr
&
zookeeper
);
void
cloneReplica
(
const
String
&
source_replica
,
Coordination
::
Stat
source_is_lost_stat
,
zkutil
::
ZooKeeperPtr
&
zookeeper
);
/// Clone replica if it is lost.
void
cloneReplicaIfNeeded
(
zkutil
::
ZooKeeperPtr
zookeeper
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录