Fix inconsistency in zookeeper metadata and disable adaptive granularity for old format

This commit is contained in:
alesapin 2019-06-17 13:34:25 +03:00
parent e73cdbae90
commit 3a4dcfbacd
3 changed files with 14 additions and 10 deletions

View File

@ -106,7 +106,6 @@ MergeTreeData::MergeTreeData(
bool attach,
BrokenPartCallback broken_part_callback_)
: global_context(context_),
index_granularity_info(settings_, full_path_),
merging_params(merging_params_),
settings(settings_),
partition_by_ast(partition_by_ast_),
@ -198,7 +197,7 @@ MergeTreeData::MergeTreeData(
"MergeTree data format version on disk doesn't support custom partitioning",
ErrorCodes::METADATA_MISMATCH);
}
index_granularity_info.init(settings, format_version, full_path);
}
@ -226,23 +225,27 @@ std::optional<std::string> MergeTreeData::IndexGranularityInfo::getMrkExtensionF
return {};
}
MergeTreeData::IndexGranularityInfo::IndexGranularityInfo(const MergeTreeSettings & settings, const std::string & full_path)
: fixed_index_granularity(settings.index_granularity)
, index_granularity_bytes(settings.index_granularity_bytes)
void MergeTreeData::IndexGranularityInfo::init(
const MergeTreeSettings & settings,
const MergeTreeDataFormatVersion & format_version,
const std::string & full_path)
{
fixed_index_granularity = settings.index_granularity;
auto mrk_ext = getMrkExtensionFromFS(full_path);
/// Granularity is fixed
if (index_granularity_bytes == 0 || (mrk_ext && *mrk_ext == "mrk"))
if (index_granularity_bytes == 0 || (mrk_ext && *mrk_ext == "mrk") || format_version < MERGE_TREE_DATA_MIN_FORMAT_VERSION_WITH_CUSTOM_PARTITIONING)
{
is_adaptive = false;
mark_size_in_bytes = sizeof(UInt64) * 2;
marks_file_extension = ".mrk";
index_granularity_bytes = 0;
}
else
{
is_adaptive = true;
mark_size_in_bytes = sizeof(UInt64) * 3;
marks_file_extension = ".mrk2";
index_granularity_bytes = settings.index_granularity_bytes;
}
}

View File

@ -304,7 +304,7 @@ public:
/// Approximate bytes size of one granule
size_t index_granularity_bytes;
IndexGranularityInfo(const MergeTreeSettings & settings, const std::string & full_path);
void init(const MergeTreeSettings & settings, const MergeTreeDataFormatVersion & format_version, const std::string & full_path);
String getMarksFilePath(const String & column_path) const
{

View File

@ -45,9 +45,9 @@ ReplicatedMergeTreeTableMetadata::ReplicatedMergeTreeTableMetadata(const MergeTr
if (data.format_version >= MERGE_TREE_DATA_MIN_FORMAT_VERSION_WITH_CUSTOM_PARTITIONING)
partition_key = formattedAST(MergeTreeData::extractKeyExpressionList(data.partition_by_ast));
ttl_table = formattedAST(data.ttl_table_ast);
skip_indices = data.getIndices().toString();
index_granularity_bytes = data.index_granularity_info.index_granularity_bytes;
ttl_table = formattedAST(data.ttl_table_ast);
}
void ReplicatedMergeTreeTableMetadata::write(WriteBuffer & out) const
@ -107,6 +107,9 @@ void ReplicatedMergeTreeTableMetadata::read(ReadBuffer & in)
if (checkString("sorting key: ", in))
in >> sorting_key >> "\n";
if (checkString("ttl: ", in))
in >> ttl_table >> "\n";
if (checkString("indices: ", in))
in >> skip_indices >> "\n";
@ -115,8 +118,6 @@ void ReplicatedMergeTreeTableMetadata::read(ReadBuffer & in)
else
index_granularity_bytes = 0;
if (checkString("ttl: ", in))
in >> ttl_table >> "\n";
}
ReplicatedMergeTreeTableMetadata ReplicatedMergeTreeTableMetadata::parse(const String & s)