mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 01:22:04 +00:00
Merge pull request #47310 from ClickHouse/vdimir/fix_transaction_read_only
Fix MergeTreeTransaction::isReadOnly
This commit is contained in:
commit
ecab007486
@ -168,6 +168,8 @@ void MergeTreeTransaction::addMutation(const StoragePtr & table, const String &
|
||||
bool MergeTreeTransaction::isReadOnly() const
|
||||
{
|
||||
std::lock_guard lock{mutex};
|
||||
if (finalized)
|
||||
return is_read_only;
|
||||
chassert((creating_parts.empty() && removing_parts.empty() && mutations.empty()) == storages.empty());
|
||||
return storages.empty();
|
||||
}
|
||||
@ -318,6 +320,11 @@ bool MergeTreeTransaction::rollback() noexcept
|
||||
void MergeTreeTransaction::afterFinalize()
|
||||
{
|
||||
std::lock_guard lock{mutex};
|
||||
chassert((creating_parts.empty() && removing_parts.empty() && mutations.empty()) == storages.empty());
|
||||
|
||||
/// Remember if it was read-only transaction before we clear storages
|
||||
is_read_only = storages.empty();
|
||||
|
||||
/// Release shared pointers just in case
|
||||
storages.clear();
|
||||
mutations.clear();
|
||||
|
@ -78,6 +78,9 @@ private:
|
||||
|
||||
bool finalized TSA_GUARDED_BY(mutex) = false;
|
||||
|
||||
/// Indicates if transaction was read-only before `afterFinalize`
|
||||
bool is_read_only TSA_GUARDED_BY(mutex) = false;
|
||||
|
||||
/// Lists of changes made by transaction
|
||||
std::unordered_set<StoragePtr> storages TSA_GUARDED_BY(mutex);
|
||||
DataPartsVector creating_parts TSA_GUARDED_BY(mutex);
|
||||
|
Loading…
Reference in New Issue
Block a user