Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
636a3817
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
636a3817
编写于
3月 07, 2020
作者:
A
alexey-milovidov
提交者:
GitHub
3月 07, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #9552 from ClickHouse/fix-race-condition-queue-task
Fixed race condition on queue_task_handle
上级
32b37c64
d4a724dc
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
30 addition
and
6 deletion
+30
-6
dbms/src/Storages/MergeTree/BackgroundProcessingPool.cpp
dbms/src/Storages/MergeTree/BackgroundProcessingPool.cpp
+11
-3
dbms/src/Storages/MergeTree/BackgroundProcessingPool.h
dbms/src/Storages/MergeTree/BackgroundProcessingPool.h
+6
-1
dbms/src/Storages/StorageReplicatedMergeTree.cpp
dbms/src/Storages/StorageReplicatedMergeTree.cpp
+13
-2
未找到文件。
dbms/src/Storages/MergeTree/BackgroundProcessingPool.cpp
浏览文件 @
636a3817
...
...
@@ -60,19 +60,27 @@ BackgroundProcessingPool::BackgroundProcessingPool(int size_,
}
BackgroundProcessingPool
::
TaskHandle
BackgroundProcessingPool
::
add
Task
(
const
Task
&
task
)
BackgroundProcessingPool
::
TaskHandle
BackgroundProcessingPool
::
create
Task
(
const
Task
&
task
)
{
TaskHandle
res
=
std
::
make_shared
<
TaskInfo
>
(
*
this
,
task
);
return
std
::
make_shared
<
TaskInfo
>
(
*
this
,
task
);
}
void
BackgroundProcessingPool
::
startTask
(
const
TaskHandle
&
task
)
{
Poco
::
Timestamp
current_time
;
{
std
::
unique_lock
lock
(
tasks_mutex
);
res
->
iterator
=
tasks
.
emplace
(
current_time
,
res
);
task
->
iterator
=
tasks
.
emplace
(
current_time
,
task
);
}
wake_event
.
notify_all
();
}
BackgroundProcessingPool
::
TaskHandle
BackgroundProcessingPool
::
addTask
(
const
Task
&
task
)
{
TaskHandle
res
=
createTask
(
task
);
startTask
(
res
);
return
res
;
}
...
...
dbms/src/Storages/MergeTree/BackgroundProcessingPool.h
浏览文件 @
636a3817
...
...
@@ -82,9 +82,14 @@ public:
return
size
;
}
///
The task is started immediately
.
///
Create task and start it
.
TaskHandle
addTask
(
const
Task
&
task
);
/// Create task but not start it.
TaskHandle
createTask
(
const
Task
&
task
);
/// Start the task that was created but not started. Precondition: task was not started.
void
startTask
(
const
TaskHandle
&
task
);
void
removeTask
(
const
TaskHandle
&
task
);
~
BackgroundProcessingPool
();
...
...
dbms/src/Storages/StorageReplicatedMergeTree.cpp
浏览文件 @
636a3817
...
...
@@ -2902,9 +2902,20 @@ void StorageReplicatedMergeTree::startup()
/// Wait while restarting_thread initializes LeaderElection (and so on) or makes first attmept to do it
startup_event
.
wait
();
queue_task_handle
=
global_context
.
getBackgroundPool
().
addTask
([
this
]
{
return
queueTask
();
});
/// If we don't separate create/start steps, race condition will happen
/// between the assignment of queue_task_handle and queueTask that use the queue_task_handle.
{
auto
&
pool
=
global_context
.
getBackgroundPool
();
queue_task_handle
=
pool
.
createTask
([
this
]
{
return
queueTask
();
});
pool
.
startTask
(
queue_task_handle
);
}
if
(
areBackgroundMovesNeeded
())
move_parts_task_handle
=
global_context
.
getBackgroundMovePool
().
addTask
([
this
]
{
return
movePartsTask
();
});
{
auto
&
pool
=
global_context
.
getBackgroundMovePool
();
move_parts_task_handle
=
pool
.
createTask
([
this
]
{
return
movePartsTask
();
});
pool
.
startTask
(
move_parts_task_handle
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录