Skip to content

Fix 01457_create_as_table_function_structure#28428

Merged
kssenii merged 6 commits intoClickHouse:masterfrom
kssenii:fix-database-ordinary-test
Sep 4, 2021
Merged

Fix 01457_create_as_table_function_structure#28428
kssenii merged 6 commits intoClickHouse:masterfrom
kssenii:fix-database-ordinary-test

Conversation

@kssenii
Copy link
Copy Markdown
Member

@kssenii kssenii commented Aug 31, 2021

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Was broken only for DatabaseOrdinary by #25251.

@robot-clickhouse robot-clickhouse added the pr-not-for-changelog This PR should not be mentioned in the changelog label Aug 31, 2021
@kssenii kssenii requested a review from tavplubix August 31, 2021 17:19
@kssenii kssenii force-pushed the fix-database-ordinary-test branch from ca6a028 to 185d294 Compare August 31, 2021 17:51
Comment on lines +143 to +148
StoragePolicyPtr getStoragePolicy() const override
{
if (nested)
return StorageProxy::getStoragePolicy();
return IStorage::getStoragePolicy();
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may work incorrectly, because caller may expect that getStoragePolicy() returns actual storage policy of nested storage.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(on the other hand, currently there is no way to create a table with non-empty storage policy from table function, so we will never sight that it does not work, but it looks tricky anyway)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw it is already used this way

void renameInMemory(const StorageID & new_table_id) override
{
std::lock_guard lock{nested_mutex};
if (nested)
StorageProxy::renameInMemory(new_table_id);
else
IStorage::renameInMemory(new_table_id);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not precisely renameInMemory has a bit different semantics. If nested storage is already loaded, then update both storage names, but if nested storage is not loaded yet (so we cannot update it), then update proxy storage name and set nested storage name on future loading.


StoragePolicyPtr getStoragePolicy() const override
{
if (nested)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a race condition

@tavplubix tavplubix self-assigned this Sep 3, 2021
@kssenii kssenii merged commit 04b26d2 into ClickHouse:master Sep 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-not-for-changelog This PR should not be mentioned in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants