Skip to content

Commit 6c714c6

Browse files
authored
Merge pull request ClickHouse#79954 from jkartseva/fix-azure-ro-merges
Respect readonly setting in Azure Blob Storage
2 parents 14b7f64 + 21f638b commit 6c714c6

File tree

5 files changed

+39
-0
lines changed

5 files changed

+39
-0
lines changed

src/Disks/ObjectStorages/AzureBlobStorage/AzureBlobStorageCommon.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ std::unique_ptr<RequestSettings> getRequestSettings(const Poco::Util::AbstractCo
442442

443443
settings->min_bytes_for_seek = config.getUInt64(config_prefix + ".min_bytes_for_seek", 1024 * 1024);
444444
settings->use_native_copy = config.getBool(config_prefix + ".use_native_copy", false);
445+
settings->read_only = config.getBool(config_prefix + ".readonly", false);
445446

446447
settings->max_single_part_upload_size = config.getUInt64(config_prefix + ".max_single_part_upload_size", settings_ref[Setting::azure_max_single_part_upload_size]);
447448
settings->max_single_read_retries = config.getUInt64(config_prefix + ".max_single_read_retries", settings_ref[Setting::azure_max_single_read_retries]);

src/Disks/ObjectStorages/AzureBlobStorage/AzureBlobStorageCommon.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ struct RequestSettings
5050
size_t sdk_retry_max_backoff_ms = 1000;
5151
bool use_native_copy = false;
5252
bool check_objects_after_upload = false;
53+
bool read_only = false;
5354

5455
using CurlOptions = Azure::Core::Http::CurlTransportOptions;
5556
CurlOptions::CurlOptIPResolve curl_ip_resolve = CurlOptions::CURL_IPRESOLVE_WHATEVER;

src/Disks/ObjectStorages/AzureBlobStorage/AzureObjectStorage.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ class AzureObjectStorage : public IObjectStorage
100100
std::shared_ptr<const AzureBlobStorage::RequestSettings> getSettings() const { return settings.get(); }
101101
std::shared_ptr<const AzureBlobStorage::ContainerClient> getAzureBlobStorageClient() const override { return client.get(); }
102102

103+
bool isReadOnly() const override { return settings.get()->read_only; }
104+
103105
bool supportParallelWrite() const override { return true; }
104106

105107
private:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Disk is read only 1
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bash
2+
# Tags: no-fasttest, no-distributed-cache
3+
# Tag no-fasttest: requires Azure
4+
# Tag no-distributed-cache: Not supported auth type
5+
6+
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
7+
# shellcheck source=../shell_config.sh
8+
. "$CUR_DIR"/../shell_config.sh
9+
10+
CONTAINER="cont-$(echo "${CLICKHOUSE_TEST_UNIQUE_NAME}" | tr _ -)"
11+
12+
DISK_NAME="$CONTAINER"
13+
14+
$CLICKHOUSE_CLIENT -m -q "
15+
DROP TABLE IF EXISTS test_azure_readonly;
16+
17+
CREATE TABLE test_azure_readonly (key Int, arr Array(UInt32)) ENGINE=MergeTree() ORDER BY tuple()
18+
SETTINGS
19+
disk = disk(
20+
readonly = true,
21+
type = object_storage,
22+
metadata_type = local,
23+
object_storage_type = azure_blob_storage,
24+
name = '${DISK_NAME}',
25+
path='/var/lib/clickhouse/disks/${CONTAINER}/tables',
26+
container_name = '${CONTAINER}',
27+
endpoint = 'http://localhost:10000/devstoreaccount1/${CONTAINER}/tables',
28+
account_name = 'devstoreaccount1',
29+
account_key = 'Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==');
30+
INSERT INTO test_azure_readonly SELECT *, [] from numbers(1); -- { serverError TABLE_IS_READ_ONLY }
31+
OPTIMIZE TABLE test_azure_readonly FINAL; -- { serverError TABLE_IS_READ_ONLY }
32+
SELECT 'Disk is read only', is_read_only FROM system.disks WHERE name = '${DISK_NAME}';
33+
DROP TABLE test_azure_readonly SYNC;
34+
"

0 commit comments

Comments
 (0)