Add mutex for settings

This commit is contained in:
alesapin 2019-08-13 19:34:52 +03:00
parent 031bfc7bf3
commit 96f62fefcc
2 changed files with 4 additions and 1 deletions

View File

@ -1644,7 +1644,7 @@ void MergeTreeData::alterSettings(
const Context & context,
TableStructureWriteLockHolder & table_lock_holder)
{
/// No additional locking required, because we took table_lock_holder
std::unique_lock lock(settings_mutex);
MutableMergeTreeSettingsPtr settings = std::move(*guarded_settings.getPtr()).mutate();
settings->updateFromChanges(new_changes);
IStorage::alterSettings(new_changes, current_database_name, current_table_name, context, table_lock_holder);

View File

@ -662,6 +662,7 @@ public:
/// get consistent settings.
const MergeTreeSettingsPtr getCOWSettings() const
{
std::shared_lock lock(settings_mutex);
return guarded_settings.copyPtr();
}
@ -801,6 +802,8 @@ protected:
std::mutex grab_old_parts_mutex;
/// The same for clearOldTemporaryDirectories.
std::mutex clear_old_temporary_directories_mutex;
/// Mutex for settings usage
mutable std::shared_mutex settings_mutex;
void setPrimaryKeyIndicesAndColumns(const ASTPtr & new_order_by_ast, const ASTPtr & new_primary_key_ast,
const ColumnsDescription & new_columns,