ClickHouse icon indicating copy to clipboard operation
ClickHouse copied to clipboard

Usage of internal table's disks

Open CheSema opened this issue 1 year ago • 1 comments

Clickhouse could create a disk from a description inside a create table definition. It is a good powerful feature. It looks like this:

create table test (a Int32) engine = MergeTree() order by tuple()
settings disk=disk(
                   name='custom_disk',
                   type = object_storage,
                   object_storage_type = s3,
                   endpoint = 'http://localhost:11111/test/common/',
                   access_key_id = ***,
                   secret_access_key = ***);

It is possible to refer a configured in the config disk without disk function, like that:

create table test (a Int32) engine = MergeTree() order by tuple()
settings disk='s3_disk_02963';

The disk function should not be used as a reference to a disk. For eaxample

create table test (a Int32) engine = MergeTree() order by tuple()
settings disk=disk(name='s3_disk_02963'); -- { serverError BAD_ARGUMENTS }

We have 2 different ways to handle this:

  • The custom disks are prohibited to be reused between tables. Only the first table which created it could use it.

or

  • The custom disks could be reused between tables. In that case the disk specification should be the same. it should have exactly the same settings

I like the second one, but they are pretty similar in cases and realisation.

We need to do that otherwise right now tables could reuse the disks with different settings from other tables and it leads to bugs like this https://github.com/ClickHouse/ClickHouse/issues/67478

CheSema avatar Aug 05 '24 12:08 CheSema

https://github.com/ClickHouse/ClickHouse/pull/67684

CheSema avatar Aug 05 '24 18:08 CheSema

I also like the second one, but let's also ask @kssenii

alexey-milovidov avatar Aug 06 '24 02:08 alexey-milovidov

+ for the second one. Also if you do not specify name argument explicitly, then it would already work this way, e.g. the disk will be reused if the set of settings is the same.

kssenii avatar Aug 06 '24 09:08 kssenii