forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 11
Improvements to partition export #1177
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
Open
arthurpassos
wants to merge
16
commits into
antalya-25.8
Choose a base branch
from
export_replicated_mt_partition_v2
base: antalya-25.8
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
3158c06
keep track of export partition zk requests
arthurpassos ba581eb
vibe coded getexportpartitioninfo
arthurpassos efa0b03
move vibe coded getpartitionexports inside the updating task
arthurpassos acf5fd1
rmv unexistent increment
arthurpassos fadf2f7
lock part inside task
arthurpassos d51d703
tmp
arthurpassos ef5807b
okish
arthurpassos 64accc3
add setting to control locking behavior (inside/outside task), deny e…
arthurpassos a63e05d
Merge branch 'antalya-25.8' into export_replicated_mt_partition_v2
arthurpassos 3817e50
clear part references from partition task when status changes, proper…
arthurpassos 85e14f9
settings history
arthurpassos 0d183bf
improvements
arthurpassos 76b3bd6
Merge branch 'antalya-25.8' into export_replicated_mt_partition_v2
arthurpassos 651d6e4
implement local query to system replicated partition exports
arthurpassos 7a1e741
address comments
arthurpassos 1962e19
glitch
arthurpassos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/Storages/MergeTree/ExportPartFromPartitionExportTask.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| #include <Storages/MergeTree/ExportPartFromPartitionExportTask.h> | ||
| #include <Common/ProfileEvents.h> | ||
|
|
||
| namespace ProfileEvents | ||
| { | ||
| extern const Event ExportPartitionZooKeeperRequests; | ||
| extern const Event ExportPartitionZooKeeperGetChildren; | ||
| extern const Event ExportPartitionZooKeeperCreate; | ||
| } | ||
| namespace DB | ||
| { | ||
|
|
||
| ExportPartFromPartitionExportTask::ExportPartFromPartitionExportTask( | ||
| StorageReplicatedMergeTree & storage_, | ||
| const std::string & key_, | ||
| const MergeTreePartExportManifest & manifest_) | ||
| : storage(storage_), | ||
| key(key_), | ||
| manifest(manifest_) | ||
| { | ||
| export_part_task = std::make_shared<ExportPartTask>(storage, manifest); | ||
| } | ||
|
|
||
| bool ExportPartFromPartitionExportTask::executeStep() | ||
| { | ||
| const auto zk = storage.getZooKeeper(); | ||
| const auto part_name = manifest.data_part->name; | ||
|
|
||
| LOG_INFO(storage.log, "ExportPartFromPartitionExportTask: Attempting to lock part: {}", part_name); | ||
|
|
||
| ProfileEvents::increment(ProfileEvents::ExportPartitionZooKeeperRequests); | ||
| ProfileEvents::increment(ProfileEvents::ExportPartitionZooKeeperCreate); | ||
| if (Coordination::Error::ZOK == zk->tryCreate(fs::path(storage.zookeeper_path) / "exports" / key / "locks" / part_name, storage.replica_name, zkutil::CreateMode::Ephemeral)) | ||
| { | ||
| LOG_INFO(storage.log, "ExportPartFromPartitionExportTask: Locked part: {}", part_name); | ||
| export_part_task->executeStep(); | ||
| return false; | ||
| } | ||
|
|
||
| LOG_INFO(storage.log, "ExportPartFromPartitionExportTask: Failed to lock part {}, skipping", part_name); | ||
| return false; | ||
| } | ||
|
|
||
| void ExportPartFromPartitionExportTask::cancel() noexcept | ||
| { | ||
| export_part_task->cancel(); | ||
| } | ||
|
|
||
| void ExportPartFromPartitionExportTask::onCompleted() | ||
| { | ||
| export_part_task->onCompleted(); | ||
| } | ||
|
|
||
| StorageID ExportPartFromPartitionExportTask::getStorageID() const | ||
| { | ||
| return export_part_task->getStorageID(); | ||
| } | ||
|
|
||
| Priority ExportPartFromPartitionExportTask::getPriority() const | ||
| { | ||
| return export_part_task->getPriority(); | ||
| } | ||
|
|
||
| String ExportPartFromPartitionExportTask::getQueryId() const | ||
| { | ||
| return export_part_task->getQueryId(); | ||
| } | ||
| } |
36 changes: 36 additions & 0 deletions
36
src/Storages/MergeTree/ExportPartFromPartitionExportTask.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| #pragma once | ||
|
|
||
| #include <Storages/MergeTree/IExecutableTask.h> | ||
| #include <Storages/MergeTree/MergeTreePartExportManifest.h> | ||
| #include <Storages/StorageReplicatedMergeTree.h> | ||
| #include <Storages/MergeTree/ExportPartTask.h> | ||
|
|
||
| namespace DB | ||
| { | ||
|
|
||
| /* | ||
| Decorator around the ExportPartTask to lock the part inside the task | ||
| */ | ||
| class ExportPartFromPartitionExportTask : public IExecutableTask | ||
| { | ||
| public: | ||
| explicit ExportPartFromPartitionExportTask( | ||
| StorageReplicatedMergeTree & storage_, | ||
| const std::string & key_, | ||
| const MergeTreePartExportManifest & manifest_); | ||
| bool executeStep() override; | ||
| void onCompleted() override; | ||
| StorageID getStorageID() const override; | ||
| Priority getPriority() const override; | ||
| String getQueryId() const override; | ||
|
|
||
| void cancel() noexcept override; | ||
|
|
||
| private: | ||
| StorageReplicatedMergeTree & storage; | ||
| std::string key; | ||
| MergeTreePartExportManifest manifest; | ||
| std::shared_ptr<ExportPartTask> export_part_task; | ||
| }; | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
ExportReplicatedMergeTreePartitionManifest::fromJsonStringnow unconditionally readslock_inside_the_taskfrommetadata.json. Existing export manifests written by prior versions do not contain this field, so any attempt to inspect existing exports (scheduler startup, status polling, orsystem.replicated_partition_exports) will throw during JSON parsing and abort the query. A backward-compatible default is needed to avoid breaking upgrades until all historical export nodes are rewritten.Useful? React with 👍 / 👎.
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.
This is not being used in production by anyone, it is safe to do it