Added lock for table structure during validation of alter commands in order to fix segfault during coucurrent alter.

This commit is contained in:
Nikolai Kochetov 2018-06-15 19:13:35 +03:00
parent 97f5b3dfaa
commit 9437a1abce
2 changed files with 9 additions and 4 deletions

View File

@ -252,10 +252,15 @@ void AlterCommands::apply(ColumnsDescription & columns_description) const
columns_description = std::move(new_columns_description);
}
void AlterCommands::validate(const IStorage & table, const Context & context)
void AlterCommands::validate(IStorage & table, const Context & context)
{
auto all_columns = table.getColumns().getAll();
auto defaults = table.getColumns().defaults;
NamesAndTypesList all_columns;
ColumnDefaults defaults;
{
auto structure_lock = table.lockStructure(/*will_modify_data = */ false, __PRETTY_FUNCTION__);
all_columns = table.getColumns().getAll();
defaults = table.getColumns().defaults;
}
std::vector<std::pair<NameAndTypePair, AlterCommand *>> defaulted_columns{};

View File

@ -60,7 +60,7 @@ class AlterCommands : public std::vector<AlterCommand>
public:
void apply(ColumnsDescription & columns_description) const;
void validate(const IStorage & table, const Context & context);
void validate(IStorage & table, const Context & context);
};
}