Write to first non-readonly disk

This commit is contained in:
Antonio Andelic 2022-11-17 14:52:35 +00:00
parent 926b35b7c4
commit d324e8cc3e

View File

@ -312,13 +312,19 @@ MergeTreeData::MergeTreeData(
if (!attach || !read_format_version)
{
format_version = min_format_version;
auto disk = getStoragePolicy()->getAnyDisk();
// try to write to first non-readonly disk
for (const auto & disk : getStoragePolicy()->getDisks())
{
if (!disk->isReadOnly())
{
auto buf = disk->writeFile(format_version_path, DBMS_DEFAULT_BUFFER_SIZE, WriteMode::Rewrite, context_->getWriteSettings());
writeIntText(format_version.toUnderType(), *buf);
if (getContext()->getSettingsRef().fsync_metadata)
buf->sync();
break;
}
}
}
else