v.24.1Improvement

Prohibit Mutable Operations on Read-Only/Write-Once Storage in ClickHouse

Prohibit mutable operations (INSERT/ALTER/OPTIMIZE/...) on read-only/write-once storages with a proper TABLE_IS_READ_ONLY error (to avoid leftovers). Avoid leaving left-overs on write-once disks (format_version.txt) on CREATE/ATTACH. Ignore DROP for ReplicatedMergeTree (so as for MergeTree). Fix iterating over s3_plain (MetadataStorageFromPlainObjectStorage::iterateDirectory). Note read-only is web disk, and write-once is s3_plain. #59170 (Azat Khuzhin).
Prohibit mutable operations such as INSERT, ALTER, and OPTIMIZE on read-only and write-once storage types, returning a TABLE_IS_READ_ONLY error to prevent leftover data and maintain storage integrity.

Why it matters

This feature prevents unintended modifications on read-only (like web disk type) and write-once (like s3_plain) storages by disallowing mutable table operations. It addresses issues with leftover files (e.g., format_version.txt) that could occur during CREATE or ATTACH on write-once disks, improving data consistency and operational safety. Additionally, it refines behavior for DROP commands on ReplicatedMergeTree tables and fixes iteration over s3_plain storages.

How to use it

This behavior is automatic for tables defined on read-only and write-once storages such as web and s3_plain disks. Users will receive a TABLE_IS_READ_ONLY error when attempting mutable operations on such tables, requiring them to avoid or relocate modifications to appropriate storage types.