Add mutex to tryGetTable only for materialized table (not nested)

This commit is contained in:
kssenii 2021-04-08 23:38:27 +00:00
parent bd207daa74
commit 3e41c82df1
2 changed files with 3 additions and 0 deletions

View File

@ -122,6 +122,8 @@ StoragePtr DatabaseMaterializePostgreSQL::tryGetTable(const String & name, const
}
}
/// Note: In select query we call MaterializePostgreSQL table and it calls tryGetTable from its nested.
std::lock_guard lock(tables_mutex);
auto table = materialized_tables.find(name);
/// Here it is possible that nested table is temporarily out of reach, but return storage anyway,
/// it will not allow to read if nested is unavailable at the moment

View File

@ -66,6 +66,7 @@ private:
std::shared_ptr<PostgreSQLReplicationHandler> replication_handler;
std::map<std::string, StoragePtr> materialized_tables;
mutable std::mutex tables_mutex;
};
}