Skip to content

Commit f565e95

Browse files
committed
cleanup export manifests at shutdown
1 parent 6b07680 commit f565e95

File tree

4 files changed

+18
-14
lines changed

4 files changed

+18
-14
lines changed

src/Storages/MergeTree/MergeTreeData.cpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6283,14 +6283,7 @@ void MergeTreeData::killExportPart(const String & transaction_id)
62836283

62846284
std::erase_if(export_manifests, [&](const auto & manifest)
62856285
{
6286-
if (manifest.transaction_id == transaction_id)
6287-
{
6288-
if (manifest.task)
6289-
manifest.task->cancel();
6290-
6291-
return true;
6292-
}
6293-
return false;
6286+
return manifest.transaction_id == transaction_id;
62946287
});
62956288
}
62966289

@@ -9137,17 +9130,13 @@ bool MergeTreeData::scheduleDataMovingJob(BackgroundJobsAssignee & assignee)
91379130
context_copy->setCurrentQueryId(manifest.transaction_id);
91389131
context_copy->setBackgroundOperationTypeForContext(ClientInfo::BackgroundOperationType::EXPORT_PART);
91399132

9140-
auto task = std::make_shared<ExportPartTask>(*this, manifest, context_copy);
9141-
9142-
manifest.in_progress = assignee.scheduleMoveTask(task);
9133+
manifest.in_progress = assignee.scheduleMoveTask(std::make_shared<ExportPartTask>(*this, manifest, context_copy));
91439134

91449135
if (!manifest.in_progress)
91459136
{
91469137
continue;
91479138
}
91489139

9149-
manifest.task = task;
9150-
91519140
return true;
91529141
}
91539142

src/Storages/MergeTree/MergeTreePartExportManifest.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ struct MergeTreePartExportManifest
7373

7474
time_t create_time;
7575
mutable bool in_progress = false;
76-
mutable std::shared_ptr<ExportPartTask> task = nullptr;
7776

7877
bool operator<(const MergeTreePartExportManifest & rhs) const
7978
{

src/Storages/StorageMergeTree.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,11 @@ void StorageMergeTree::shutdown(bool)
256256

257257
if (deduplication_log)
258258
deduplication_log->shutdown();
259+
260+
{
261+
std::lock_guard lock(export_manifests_mutex);
262+
export_manifests.clear();
263+
}
259264
}
260265

261266

src/Storages/StorageReplicatedMergeTree.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6014,6 +6014,17 @@ void StorageReplicatedMergeTree::shutdown(bool)
60146014
/// Wait for all of them
60156015
std::lock_guard lock(data_parts_exchange_ptr->rwlock);
60166016
}
6017+
6018+
{
6019+
std::lock_guard lock(export_manifests_mutex);
6020+
export_manifests.clear();
6021+
}
6022+
6023+
{
6024+
std::lock_guard lock(export_merge_tree_partition_mutex);
6025+
export_merge_tree_partition_task_entries.clear();
6026+
}
6027+
60176028
LOG_TRACE(log, "Shutdown finished");
60186029
}
60196030

0 commit comments

Comments
 (0)