Merge pull request #8440 from excitoon-favorites/bettercheckforpartsonanotherdisks

Improved check for parts on different disks
This commit is contained in:
alexey-milovidov 2019-12-29 00:10:47 +03:00 committed by GitHub
commit 6830d7fa2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 1 deletions

View File

@ -208,6 +208,30 @@ StoragePolicy::StoragePolicy(String name_, Volumes volumes_, double move_factor_
}
bool StoragePolicy::isDefaultPolicy() const
{
/// Guessing if this policy is default, not 100% correct though.
if (getName() != "default")
return false;
if (volumes.size() != 1)
return false;
if (volumes[0]->getName() != "default")
return false;
const auto & disks = volumes[0]->disks;
if (disks.size() != 1)
return false;
if (disks[0]->getName() != "default")
return false;
return true;
}
Disks StoragePolicy::getDisks() const
{
Disks res;

View File

@ -103,6 +103,8 @@ public:
StoragePolicy(String name_, Volumes volumes_, double move_factor_);
bool isDefaultPolicy() const;
/// Returns disks ordered by volumes priority
Disks getDisks() const;

View File

@ -823,7 +823,8 @@ void MergeTreeData::loadDataParts(bool skip_sanity_checks)
auto disks = storage_policy->getDisks();
if (getStoragePolicy()->getName() != "default")
/// Only check if user did touch storage configuration for this table.
if (!getStoragePolicy()->isDefaultPolicy() && !skip_sanity_checks)
{
/// Check extra parts at different disks, in order to not allow to miss data parts at undefined disks.
std::unordered_set<String> defined_disk_names;