mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 09:32:01 +00:00
fix data race
This commit is contained in:
parent
d83cf03c30
commit
86119dbc3f
@ -349,7 +349,7 @@ MergeTreeData::DataPart::Checksums Service::sendPartFromDisk(
|
||||
return data_checksums;
|
||||
}
|
||||
|
||||
bool wait_loop(UInt32 wait_timeout_ms, std::function<bool()> pred)
|
||||
bool wait_loop(UInt32 wait_timeout_ms, const std::function<bool()> & pred)
|
||||
{
|
||||
static const UInt32 loop_delay_ms = 5;
|
||||
|
||||
@ -360,6 +360,7 @@ bool wait_loop(UInt32 wait_timeout_ms, std::function<bool()> pred)
|
||||
return true;
|
||||
|
||||
Stopwatch timer;
|
||||
sleepForMilliseconds(loop_delay_ms);
|
||||
while (!pred() && timer.elapsedMilliseconds() < wait_timeout_ms)
|
||||
{
|
||||
sleepForMilliseconds(loop_delay_ms);
|
||||
@ -387,8 +388,13 @@ MergeTreeData::DataPartPtr Service::findPart(const String & name)
|
||||
/// do not expose PreActive parts for zero-copy
|
||||
|
||||
static const UInt32 wait_timeout_ms = 1000;
|
||||
bool pred_result = wait_loop(wait_timeout_ms, [&] () { return part->getState() != MergeTreeDataPartState::PreActive; });
|
||||
auto pred = [&] ()
|
||||
{
|
||||
auto lock = data.lockParts();
|
||||
return part->getState() != MergeTreeDataPartState::PreActive;
|
||||
};
|
||||
|
||||
bool pred_result = wait_loop(wait_timeout_ms, pred);
|
||||
if (!pred_result)
|
||||
throw Exception(
|
||||
ErrorCodes::ABORTED,
|
||||
|
@ -22,5 +22,5 @@ insert into tableIn values(2);
|
||||
system sync replica tableOut;
|
||||
select count() from tableOut;
|
||||
|
||||
drop table tableIn
|
||||
drop table tableOut
|
||||
drop table tableIn;
|
||||
drop table tableOut;
|
||||
|
Loading…
Reference in New Issue
Block a user