Merge pull request #9383 from excitoon-favorites/attachpart

Added a check for storage policy in `cloneAndLoadDataPartOnSameDisk()`
This commit is contained in:
mergify[bot] 2020-02-26 20:29:30 +00:00 committed by GitHub
commit b655190c2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3591,6 +3591,21 @@ MergeTreeData::MutableDataPartPtr MergeTreeData::cloneAndLoadDataPartOnSameDisk(
const String & tmp_part_prefix,
const MergeTreePartInfo & dst_part_info)
{
/// Check that the storage policy contains the disk where the src_part is located.
bool does_storage_policy_allow_same_disk = false;
for (const DiskPtr & disk : getStoragePolicy()->getDisks())
{
if (disk->getName() == src_part->disk->getName())
{
does_storage_policy_allow_same_disk = true;
break;
}
}
if (!does_storage_policy_allow_same_disk)
throw Exception(
"Could not clone and load part " + quoteString(src_part->getFullPath()) + " because disk does not belong to storage policy", ErrorCodes::LOGICAL_ERROR);
String dst_part_name = src_part->getNewName(dst_part_info);
String tmp_dst_part_name = tmp_part_prefix + dst_part_name;