From 89144ba8438aec054a408a1249925fe33e08b694 Mon Sep 17 00:00:00 2001 From: kssenii Date: Mon, 3 May 2021 22:06:21 +0000 Subject: [PATCH] Try adding lock for storage --- src/Storages/PostgreSQL/PostgreSQLReplicationHandler.cpp | 3 ++- src/Storages/PostgreSQL/StorageMaterializePostgreSQL.cpp | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Storages/PostgreSQL/PostgreSQLReplicationHandler.cpp b/src/Storages/PostgreSQL/PostgreSQLReplicationHandler.cpp index 1675bf5870f..5b6e0ceb16c 100644 --- a/src/Storages/PostgreSQL/PostgreSQLReplicationHandler.cpp +++ b/src/Storages/PostgreSQL/PostgreSQLReplicationHandler.cpp @@ -467,11 +467,12 @@ void PostgreSQLReplicationHandler::reloadFromSnapshot(const std::vectorlockForShare(String(), context->getSettingsRef().lock_acquire_timeout); InterpreterRenameQuery(ast_rename, nested_context).execute(); { auto nested_storage = DatabaseCatalog::instance().getTable(StorageID(table_id.database_name, table_id.table_name), nested_context); - auto table_lock = nested_storage->lockForShare(String(), context->getSettingsRef().lock_acquire_timeout); + auto nested_table_lock = nested_storage->lockForShare(String(), context->getSettingsRef().lock_acquire_timeout); auto nested_table_id = nested_storage->getStorageID(); materialized_storage->setNestedStorageID(nested_table_id); diff --git a/src/Storages/PostgreSQL/StorageMaterializePostgreSQL.cpp b/src/Storages/PostgreSQL/StorageMaterializePostgreSQL.cpp index 11a44f7d022..38d4790a826 100644 --- a/src/Storages/PostgreSQL/StorageMaterializePostgreSQL.cpp +++ b/src/Storages/PostgreSQL/StorageMaterializePostgreSQL.cpp @@ -24,7 +24,6 @@ #include #include -/// TODO: Add test for allow_automatic_update setting in case of single storage. namespace DB { @@ -75,7 +74,7 @@ StorageMaterializePostgreSQL::StorageMaterializePostgreSQL( metadata_path, getContext(), replication_settings->materialize_postgresql_max_block_size.value, - replication_settings->materialize_postgresql_allow_automatic_update.value, false); + /* allow_automatic_update */ false, /* is_materialize_postgresql_database */false); } @@ -252,6 +251,7 @@ Pipe StorageMaterializePostgreSQL::read( size_t max_block_size, unsigned num_streams) { + auto materialized_table_lock = lockForShare(String(), context_->getSettingsRef().lock_acquire_timeout); auto nested_table = getNested(); return readFinalFromNestedStorage(nested_table, column_names, metadata_snapshot, query_info, context_, processed_stage, max_block_size, num_streams);