Add some locks on freeze and support |freezeAll()| for replicated merge-tree.

This commit is contained in:
Ivan Lezhankin 2018-11-12 15:24:15 +03:00
parent aeb0759f22
commit 4eb0f33ec2
2 changed files with 15 additions and 0 deletions

View File

@ -815,6 +815,8 @@ void StorageMergeTree::dropPartition(const ASTPtr & /*query*/, const ASTPtr & pa
void StorageMergeTree::attachPartition(const ASTPtr & partition, bool part, const Context & context)
{
// TODO: should get some locks to prevent race with 'alter … modify column'
String partition_id;
if (part)
@ -869,6 +871,7 @@ void StorageMergeTree::attachPartition(const ASTPtr & partition, bool part, cons
void StorageMergeTree::freezePartition(const ASTPtr & partition, const String & with_name, const Context & context)
{
auto lock = lockStructure(false, __PRETTY_FUNCTION__);
data.freezePartition(partition, with_name, context);
}

View File

@ -3279,6 +3279,15 @@ void StorageReplicatedMergeTree::alter(const AlterCommands & params,
}
}
/// Do freeze of all parts local-only after all other operations.
for (const AlterCommand & param : params)
{
if (param.type == AlterCommand::FREEZE_ALL)
{
data.freezeAll(param.with_name, context);
}
}
LOG_DEBUG(log, "ALTER finished");
}
@ -3427,6 +3436,8 @@ void StorageReplicatedMergeTree::truncate(const ASTPtr & query)
void StorageReplicatedMergeTree::attachPartition(const ASTPtr & partition, bool attach_part, const Context & context)
{
// TODO: should get some locks to prevent race with 'alter … modify column'
assertNotReadonly();
String partition_id;
@ -4156,6 +4167,7 @@ void StorageReplicatedMergeTree::fetchPartition(const ASTPtr & partition, const
void StorageReplicatedMergeTree::freezePartition(const ASTPtr & partition, const String & with_name, const Context & context)
{
auto lock = lockStructure(false, __PRETTY_FUNCTION__);
data.freezePartition(partition, with_name, context);
}