Try adding lock for storage

This commit is contained in:
kssenii 2021-05-03 22:06:21 +00:00
parent eff26f9d54
commit 89144ba843
2 changed files with 4 additions and 3 deletions

View File

@ -467,11 +467,12 @@ void PostgreSQLReplicationHandler::reloadFromSnapshot(const std::vector<std::pai
try
{
auto materialized_table_lock = materialized_storage->lockForShare(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);

View File

@ -24,7 +24,6 @@
#include <Storages/ReadFinalForExternalReplicaStorage.h>
#include <Core/PostgreSQL/PostgreSQLConnectionPool.h>
/// 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);