Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
47becc0b
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,发现更多精彩内容 >>
提交
47becc0b
编写于
2月 21, 2018
作者:
V
Vitaliy Lyudvichenko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Try to reduce false positive of sanity check. More detail dignostics. [#CLICKHOUSE-3571]
上级
963c4a97
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
65 addition
and
16 deletion
+65
-16
dbms/src/Storages/MergeTree/MergeTreePartInfo.h
dbms/src/Storages/MergeTree/MergeTreePartInfo.h
+4
-0
dbms/src/Storages/StorageReplicatedMergeTree.cpp
dbms/src/Storages/StorageReplicatedMergeTree.cpp
+58
-13
dbms/tests/integration/test_random_inserts/test.sh
dbms/tests/integration/test_random_inserts/test.sh
+3
-3
未找到文件。
dbms/src/Storages/MergeTree/MergeTreePartInfo.h
浏览文件 @
47becc0b
...
...
@@ -40,6 +40,10 @@ struct MergeTreePartInfo
String
getPartName
()
const
;
String
getPartNameV0
(
DayNum_t
left_date
,
DayNum_t
right_date
)
const
;
UInt64
getBlocksCount
()
const
{
return
static_cast
<
UInt64
>
(
max_block
-
min_block
+
1
);
}
static
MergeTreePartInfo
fromPartName
(
const
String
&
part_name
,
MergeTreeDataFormatVersion
format_version
);
...
...
dbms/src/Storages/StorageReplicatedMergeTree.cpp
浏览文件 @
47becc0b
...
...
@@ -741,6 +741,7 @@ void StorageReplicatedMergeTree::checkParts(bool skip_sanity_checks)
/// Which local parts to added into ZK.
MergeTreeData
::
DataPartsVector
parts_to_add
;
UInt64
parts_to_add_rows
=
0
;
/// Which parts should be taken from other replicas.
Strings
parts_to_fetch
;
...
...
@@ -756,6 +757,7 @@ void StorageReplicatedMergeTree::checkParts(bool skip_sanity_checks)
{
parts_to_add
.
push_back
(
containing
);
unexpected_parts
.
erase
(
containing
);
parts_to_add_rows
+=
containing
->
rows_count
;
}
}
else
...
...
@@ -768,21 +770,53 @@ void StorageReplicatedMergeTree::checkParts(bool skip_sanity_checks)
for
(
const
String
&
name
:
parts_to_fetch
)
expected_parts
.
erase
(
name
);
/** To check the adequacy, for the parts that are in the FS, but not in ZK, we will only consider not the most recent parts.
* Because unexpected new parts usually arise only because they did not have time to enroll in ZK with a rough restart of the server.
* It also occurs from deduplicated parts that did not have time to retire.
*/
size_t
unexpected_parts_nonnew
=
0
;
UInt64
unexpected_parts_nonnew_rows
=
0
;
UInt64
unexpected_parts_rows
=
0
;
for
(
const
auto
&
part
:
unexpected_parts
)
{
if
(
part
->
info
.
level
>
0
)
{
++
unexpected_parts_nonnew
;
unexpected_parts_nonnew_rows
+=
part
->
rows_count
;
}
unexpected_parts_rows
+=
part
->
rows_count
;
}
/// Additional helpful statistics
auto
get_blocks_count_in_data_part
=
[
&
]
(
const
String
&
part_name
)
->
UInt64
{
MergeTreePartInfo
part_info
;
if
(
MergeTreePartInfo
::
tryParsePartName
(
part_name
,
&
part_info
,
data
.
format_version
))
return
part_info
.
getBlocksCount
();
LOG_ERROR
(
log
,
"Unexpected part name: "
<<
part_name
);
return
0
;
};
UInt64
parts_to_fetch_blocks
=
0
;
for
(
const
String
&
name
:
parts_to_fetch
)
parts_to_fetch_blocks
+=
get_blocks_count_in_data_part
(
name
);
UInt64
expected_parts_blocks
=
0
;
for
(
const
String
&
name
:
expected_parts
)
expected_parts_blocks
+=
get_blocks_count_in_data_part
(
name
);
String
sanity_report
=
"There are "
+
toString
(
unexpected_parts
.
size
())
+
" unexpected parts ("
+
toString
(
unexpected_parts_nonnew
)
+
" of them is not just-written), "
+
toString
(
parts_to_add
.
size
())
+
" unexpectedly merged parts, "
+
toString
(
expected_parts
.
size
())
+
" missing obsolete parts, "
+
toString
(
parts_to_fetch
.
size
())
+
" missing parts"
;
std
::
stringstream
sanity_report
;
sanity_report
<<
"There are "
<<
unexpected_parts
.
size
()
<<
" unexpected parts with "
<<
unexpected_parts_rows
<<
" rows ("
<<
unexpected_parts_nonnew
<<
" of them is not just-written with "
<<
unexpected_parts_rows
<<
" rows), "
<<
parts_to_add
.
size
()
<<
" unexpectedly merged parts with "
<<
parts_to_add_rows
<<
" rows, "
<<
expected_parts
.
size
()
<<
" missing obsolete parts (with "
<<
expected_parts_blocks
<<
" blocks), "
<<
parts_to_fetch
.
size
()
<<
" missing parts (with "
<<
parts_to_fetch_blocks
<<
" blocks)."
;
/** We can automatically synchronize data,
* if the ratio of the total number of errors to the total number of parts (minimum - on the local filesystem or in ZK)
...
...
@@ -793,17 +827,28 @@ void StorageReplicatedMergeTree::checkParts(bool skip_sanity_checks)
* In this case, the protection mechanism does not allow the server to start.
*/
size_t
min_parts_local_or_expected
=
std
::
min
(
expected_parts_vec
.
size
(),
parts
.
size
());
size_t
total_difference
=
parts_to_add
.
size
()
+
unexpected_parts_nonnew
+
parts_to_fetch
.
size
();
UInt64
total_rows_on_filesystem
=
0
;
for
(
const
auto
&
part
:
parts
)
total_rows_on_filesystem
+=
part
->
rows_count
;
UInt64
total_suspicious_rows
=
parts_to_add_rows
+
unexpected_parts_rows
;
UInt64
total_suspicious_rows_no_new
=
parts_to_add_rows
+
unexpected_parts_nonnew_rows
;
bool
insane
=
total_
difference
>
min_parts_local_or_expected
*
data
.
settings
.
replicated_max_ratio_of_wrong_parts
;
bool
insane
=
total_
suspicious_rows
>
total_rows_on_filesystem
*
data
.
settings
.
replicated_max_ratio_of_wrong_parts
;
if
(
insane
&&
!
skip_sanity_checks
)
throw
Exception
(
"The local set of parts of table "
+
getTableName
()
+
" doesn't look like the set of parts in ZooKeeper. "
+
sanity_report
,
ErrorCodes
::
TOO_MANY_UNEXPECTED_DATA_PARTS
);
{
std
::
stringstream
why
;
why
<<
"The local set of parts of table "
<<
database_name
<<
"."
<<
table_name
<<
" doesn't look like the set of parts "
<<
"in ZooKeeper: "
<<
formatReadableQuantity
(
total_suspicious_rows
)
<<
" rows of "
<<
formatReadableQuantity
(
total_rows_on_filesystem
)
<<
" total rows in filesystem are suspicious."
;
throw
Exception
(
why
.
str
()
+
" "
+
sanity_report
.
str
(),
ErrorCodes
::
TOO_MANY_UNEXPECTED_DATA_PARTS
);
}
if
(
total_
difference
>
0
)
LOG_WARNING
(
log
,
sanity_report
);
if
(
total_
suspicious_rows_no_new
>
0
)
LOG_WARNING
(
log
,
sanity_report
.
str
()
);
/// Add information to the ZK about the parts that cover the missing parts.
for
(
const
MergeTreeData
::
DataPartPtr
&
part
:
parts_to_add
)
...
...
dbms/tests/integration/test_random_inserts/test.sh
浏览文件 @
47becc0b
...
...
@@ -2,9 +2,9 @@
#set -e
[[
-n
"
$1
"
]]
&&
host
=
"
$1
"
||
host
=
"localhost"
[[
-n
"
$2
"
]]
&&
min_timestamp
=
"
$2
"
||
min_timestamp
=
$((
$(
date
+%s
)
-
1
0
))
[[
-n
"
$3
"
]]
&&
max_timestamp
=
"
$3
"
||
max_timestamp
=
$((
$(
date
+%s
)
+
1
0
))
[[
-n
"
$4
"
]]
&&
iters_per_timestamp
=
"
$4
"
||
iters_per_timestamp
=
1
[[
-n
"
$2
"
]]
&&
min_timestamp
=
"
$2
"
||
min_timestamp
=
$((
$(
date
+%s
)
-
6
0
))
[[
-n
"
$3
"
]]
&&
max_timestamp
=
"
$3
"
||
max_timestamp
=
$((
$(
date
+%s
)
+
6
0
))
[[
-n
"
$4
"
]]
&&
iters_per_timestamp
=
"
$4
"
||
iters_per_timestamp
=
5
timestamps
=
`
seq
$min_timestamp
$max_timestamp
`
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录