Skip to content

Commit 779dcb8

Browse files
Miscellaneous
1 parent c4a523b commit 779dcb8

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

src/Interpreters/ThreadStatusExt.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,21 @@ ThreadGroupSwitcher::ThreadGroupSwitcher(ThreadGroupPtr thread_group)
151151
/// might be nullptr
152152
prev_thread_group = CurrentThread::getGroup();
153153

154-
CurrentThread::detachFromGroupIfNotDetached();
155-
CurrentThread::attachToGroup(thread_group);
154+
if (thread_group != prev_thread_group)
155+
{
156+
CurrentThread::detachFromGroupIfNotDetached();
157+
CurrentThread::attachToGroup(thread_group);
158+
}
156159
}
157160

158161
ThreadGroupSwitcher::~ThreadGroupSwitcher()
159162
{
160-
CurrentThread::detachFromGroupIfNotDetached();
161-
if (prev_thread_group)
162-
CurrentThread::attachToGroup(prev_thread_group);
163+
if (CurrentThread::getGroup() != prev_thread_group)
164+
{
165+
CurrentThread::detachFromGroupIfNotDetached();
166+
if (prev_thread_group)
167+
CurrentThread::attachToGroup(prev_thread_group);
168+
}
163169
}
164170

165171
void ThreadStatus::attachInternalProfileEventsQueue(const InternalProfileEventsQueuePtr & profile_queue)

src/Storages/MergeTree/MergePlainMergeTreeTask.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,17 @@ bool MergePlainMergeTreeTask::executeStep()
3838
/// Make out memory tracker a parent of current thread memory tracker
3939
std::optional<ThreadGroupSwitcher> switcher;
4040
if (merge_list_entry)
41-
{
4241
switcher.emplace((*merge_list_entry)->thread_group);
43-
}
4442

4543
switch (state)
4644
{
47-
case State::NEED_PREPARE :
45+
case State::NEED_PREPARE:
4846
{
4947
prepare();
5048
state = State::NEED_EXECUTE;
5149
return true;
5250
}
53-
case State::NEED_EXECUTE :
51+
case State::NEED_EXECUTE:
5452
{
5553
try
5654
{
@@ -66,7 +64,7 @@ bool MergePlainMergeTreeTask::executeStep()
6664
throw;
6765
}
6866
}
69-
case State::NEED_FINISH :
67+
case State::NEED_FINISH:
7068
{
7169
finish();
7270

src/Storages/MergeTree/MergeTask.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ using MergeTaskPtr = std::shared_ptr<MergeTask>;
5656
class MergeTask
5757
{
5858
public:
59-
6059
MergeTask(
6160
FutureMergedMutatedPartPtr future_part_,
6261
StorageMetadataPtr metadata_snapshot_,

src/Storages/MergeTree/MutateTask.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,6 @@ using MutationContextPtr = std::shared_ptr<MutationContext>;
10051005
class MergeProjectionPartsTask : public IExecutableTask
10061006
{
10071007
public:
1008-
10091008
MergeProjectionPartsTask(
10101009
String name_,
10111010
MergeTreeData::MutableDataPartsVector && parts_,

src/Storages/MergeTree/ReplicatedMergeMutateTaskBase.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ bool ReplicatedMergeMutateTaskBase::executeImpl()
161161
return false;
162162
};
163163

164-
165164
auto execute_fetch = [&] (bool need_to_check_missing_part) -> bool
166165
{
167166
if (storage.executeFetch(entry, need_to_check_missing_part))
@@ -170,10 +169,9 @@ bool ReplicatedMergeMutateTaskBase::executeImpl()
170169
return false;
171170
};
172171

173-
174172
switch (state)
175173
{
176-
case State::NEED_PREPARE :
174+
case State::NEED_PREPARE:
177175
{
178176
{
179177
auto res = checkExistingPart();
@@ -193,7 +191,7 @@ bool ReplicatedMergeMutateTaskBase::executeImpl()
193191
state = State::NEED_EXECUTE_INNER_MERGE;
194192
return true;
195193
}
196-
case State::NEED_EXECUTE_INNER_MERGE :
194+
case State::NEED_EXECUTE_INNER_MERGE:
197195
{
198196
try
199197
{
@@ -212,7 +210,7 @@ bool ReplicatedMergeMutateTaskBase::executeImpl()
212210

213211
return true;
214212
}
215-
case State::NEED_FINALIZE :
213+
case State::NEED_FINALIZE:
216214
{
217215
try
218216
{
@@ -228,7 +226,7 @@ bool ReplicatedMergeMutateTaskBase::executeImpl()
228226

229227
return remove_processed_entry();
230228
}
231-
case State::SUCCESS :
229+
case State::SUCCESS:
232230
{
233231
throw Exception(ErrorCodes::LOGICAL_ERROR, "Do not call execute on previously succeeded task");
234232
}

0 commit comments

Comments
 (0)