Fix bug with existing part

This commit is contained in:
alesapin 2022-02-07 12:33:37 +03:00
parent c028269e6f
commit bb361e3b01

View File

@ -7196,9 +7196,19 @@ bool StorageReplicatedMergeTree::unlockSharedData(const IMergeTreeDataPart & par
if (!disk || !disk->supportZeroCopyReplication())
return true;
auto ref_count = disk->getRefCount(fs::path(part.getFullRelativePath()) / IMergeTreeDataPart::FILE_FOR_REFERENCES_CHECK);
if (ref_count > 0) /// Keep part shard info for frozen backups
return false;
/// If part is temporary refcount file may be absent
auto ref_count_path = fs::path(part.getFullRelativePath()) / IMergeTreeDataPart::FILE_FOR_REFERENCES_CHECK;
if (disk->exists(ref_count_path))
{
auto ref_count = disk->getRefCount(ref_count_path);
if (ref_count > 0) /// Keep part shard info for frozen backups
return false;
}
else
{
/// Temporary part with some absent file cannot be locked in shared mode
return true;
}
return unlockSharedDataByID(part.getUniqueId(), getTableSharedID(), name, replica_name, disk, getZooKeeper(), *getSettings(), log,
zookeeper_path);