-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Volumes related refactorings #12670
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Volumes related refactorings #12670
Conversation
1. Implemented MultiDiskReservation to maintain multiple reservations under one 2. Implemented VolumeRAID1 as child of VolumeJBOD (since RAID1 is quite similar) 3. Implemented createVolumeFromConfig
1. SingleDiskVolume for temporary volumes 2. Generic VolumePtr in StoragePolicies 3. Removed max_data_part_size in system.storage_policies, added volume_type
alesapin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least, we need to disable RAID1 for users until it will be ready.
src/Disks/VolumeRAID1.h
Outdated
| }; | ||
|
|
||
| using VolumeRAID1Ptr = std::shared_ptr<VolumeRAID1>; | ||
| using VolumesRAID1Ptr = std::vector<VolumeRAID1Ptr>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a pointer: VolumesRAID1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove that line completely.
src/Disks/IVolume.cpp
Outdated
|
|
||
| void MultiDiskReservation::update(UInt64 new_size) | ||
| { | ||
| for (auto &r: reservations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/Disks/IVolume.cpp
Outdated
| throw Exception("At least one reservation must be provided to MultiDiskReservation", ErrorCodes::NO_RESERVATIONS_PROVIDED); | ||
| } | ||
|
|
||
| for (auto &r: reservations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/Disks/IVolume.cpp
Outdated
| return res; | ||
| } | ||
|
|
||
| MultiDiskReservation::MultiDiskReservation(Reservations &reservations_, UInt64 size_) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/Interpreters/Aggregator.cpp
Outdated
| void Aggregator::writeToTemporaryFile(AggregatedDataVariants & data_variants) | ||
| { | ||
| return writeToTemporaryFile(data_variants, params.tmp_volume->getNextDisk()->getPath()); | ||
| return writeToTemporaryFile(data_variants, params.tmp_volume->getDisk()->getPath()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we have different logic here and https://github.com/ClickHouse/ClickHouse/pull/12670/files#diff-bafb5527e76244c7f83100af0572d862R771 here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no such thing as getNextDisk() in IVolume. What shall we do? @NanoBjorn
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did as you advised, but that looks ugly. Can we use some of polymorphism here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did as you advised, but that looks ugly. Can we use some of polymorphism here?
I thought about it for a long time, this seems the best way, despite the fact it is a bit ugly. So leave it this way:)
src/Storages/StorageDistributed.cpp
Outdated
| for (const DiskPtr & disk : volume->getDisks()) | ||
| for (const DiskPtr & disk : storage_policy->getDisks()) | ||
| { | ||
| disk->reserve(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we need it now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember making these changes. @excitoon why are you moving back from volume as member class to storage_policy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better if I use reserve() from volume? @NanoBjorn
This is 1b3f5c9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't understand why we needed to move back from volume as member to storage_policy, but maybe it is okay if it works. Why you need reserve here at all? It was fine without it, or not?
| {"volume_name", std::make_shared<DataTypeString>()}, | ||
| {"volume_priority", std::make_shared<DataTypeUInt64>()}, | ||
| {"disks", std::make_shared<DataTypeArray>(std::make_shared<DataTypeString>())}, | ||
| {"max_data_part_size", std::make_shared<DataTypeUInt64>()}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we lost it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess if we want it here then we should move max_data_part_size to IVolume. @alesapin do we want it in IVolume or not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this is sad. @NanoBjorn
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've taken max_data_part_size back. @alesapin please check.
src/Disks/createVolume.cpp
Outdated
| return std::make_shared<VolumeJBOD>(name, config, config_prefix, disk_selector); | ||
| } | ||
| String raid_type = config.getString(config_prefix + ".raid_type"); | ||
| if (raid_type == "RAID 1" || raid_type == "RAID-1" || raid_type == "RAID1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more time: It shouldn't be possible to create RAID1 in config.xml. Also, we need to add a comment that it doesn't work yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we support ambiguity in the name of RAID-1? Let's stick with only one variant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@excitoon just remove all lines devoted to RAID 1, that was my mistake, we don't need it in this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's been almost 2 years since it was added, and it hadn't been implemented yet.
Maybe it's time to remove it? (#36836)
Broken by @blinkov |
|
|
||
| const auto & sharding_key = engine_args.size() >= 4 ? engine_args[3] : nullptr; | ||
| const auto & storage_policy = engine_args.size() >= 5 ? engine_args[4]->as<ASTLiteral &>().value.safeGet<String>() : ""; | ||
| const auto & storage_policy = engine_args.size() >= 5 ? engine_args[4]->as<ASTLiteral &>().value.safeGet<String>() : "default"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually this wasn't the "redundant code" (f5af645), now it uses default storage policy even if the 5-th argument is not passed, while previous behavior creates separate volume with just path from config.xml
I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en
Changelog category (leave one):
Detailed description / Documentation draft:
Generic volume
By adding documentation, you'll allow users to try your new feature immediately, not when someone else will have time to document it later. Documentation is necessary for all features that affect user experience in any way. You can add brief documentation draft above, or add documentation right into your patch as Markdown files in docs folder.
If you are doing this for the first time, it's recommended to read the lightweight Contributing to ClickHouse Documentation guide first.