Fix race in wait

This commit is contained in:
Michael Kolupaev 2024-02-19 14:52:19 +00:00
parent 7575115069
commit 279d9c78ee

View File

@ -160,7 +160,7 @@ void RefreshTask::cancel()
void RefreshTask::wait()
{
std::unique_lock lock(mutex);
refresh_cv.wait(lock, [&] { return info.state != RefreshState::Running; });
refresh_cv.wait(lock, [&] { return info.state != RefreshState::Running && !refresh_immediately; });
if (info.last_refresh_result == LastRefreshResult::Error)
throw Exception(ErrorCodes::REFRESH_FAILED, "Refresh failed: {}", info.exception_message);
}