Fix data race on global BlockStreamProfileInfo in PullingAsyncPipelineExecutor.

This commit is contained in:
Nikolai Kochetov 2020-11-27 16:50:34 +03:00
parent 1feebe9d73
commit 1c8600bb0a

View File

@ -220,9 +220,15 @@ Block PullingAsyncPipelineExecutor::getExtremesBlock()
BlockStreamProfileInfo & PullingAsyncPipelineExecutor::getProfileInfo() BlockStreamProfileInfo & PullingAsyncPipelineExecutor::getProfileInfo()
{ {
if (lazy_format)
return lazy_format->getProfileInfo();
static BlockStreamProfileInfo profile_info; static BlockStreamProfileInfo profile_info;
return lazy_format ? lazy_format->getProfileInfo() static std::once_flag flag;
: profile_info; /// Calculate rows before limit here to avoid race.
std::call_once(flag, []() { profile_info.getRowsBeforeLimit(); });
return profile_info;
} }
} }