Fix TSAN race in transform

This commit is contained in:
Raúl Marín 2023-11-15 23:10:25 +01:00
parent bf10989515
commit 2508e91856

View File

@ -154,7 +154,7 @@ namespace
ColumnPtr executeImpl(
const ColumnsWithTypeAndName & arguments, const DataTypePtr & result_type, size_t input_rows_count) const override
{
initialize(arguments, result_type);
std::call_once(once, [&] { initialize(arguments, result_type); });
const auto * in = arguments[0].column.get();
@ -672,11 +672,9 @@ namespace
ColumnPtr default_column;
bool is_empty = false;
bool initialized = false;
std::mutex mutex;
};
mutable std::once_flag once;
mutable Cache cache;
@ -706,10 +704,6 @@ namespace
/// Can be called from different threads. It works only on the first call.
void initialize(const ColumnsWithTypeAndName & arguments, const DataTypePtr & result_type) const
{
std::lock_guard lock(cache.mutex);
if (cache.initialized)
return;
const DataTypePtr & from_type = arguments[0].type;
if (from_type->onlyNull())
@ -824,8 +818,6 @@ namespace
}
}
}
cache.initialized = true;
}
};