From 255f0bb3f67b93d148f5e0293486bdd4c147e431 Mon Sep 17 00:00:00 2001 From: Mikhail Filimonov Date: Wed, 28 Jan 2026 23:26:27 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20zero=E2=80=91copy=20unlock=20check=20befo?= =?UTF-8?q?re=20part=20dir=20move?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Storages/MergeTree/DataPartStorageOnDiskBase.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Storages/MergeTree/DataPartStorageOnDiskBase.cpp b/src/Storages/MergeTree/DataPartStorageOnDiskBase.cpp index 034343d47c87..d81b50d3a855 100644 --- a/src/Storages/MergeTree/DataPartStorageOnDiskBase.cpp +++ b/src/Storages/MergeTree/DataPartStorageOnDiskBase.cpp @@ -747,6 +747,11 @@ void DataPartStorageOnDiskBase::remove( try { + /// Evaluate can_remove_callback before moving the directory so zero-copy reference checks + /// use the current (existing) path. We intentionally don't update part_dir to avoid races. + if (!can_remove_description) + can_remove_description.emplace(can_remove_callback()); + disk->moveDirectory(from, to); /// NOTE: we intentionally don't update part_dir here because it would cause a data race /// with concurrent readers (e.g. system.parts table queries calling getFullPath()).