Merge pull request #25835 from kitaisreal/expression-cache-destruction-fix

ExpressionCache destruction fix
This commit is contained in:
Maksim Kita 2021-06-30 01:47:18 +03:00 committed by GitHub
commit e0d04edade
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -457,6 +457,14 @@ struct ContextSharedPart
{
auto lock = std::lock_guard(mutex);
/** Compiled expressions stored in cache need to be destroyed before destruction of static objects.
* Because CHJIT instance can be static object.
*/
#if USE_EMBEDDED_COMPILER
if (auto * cache = CompiledExpressionCacheFactory::instance().tryGetCache())
cache->reset();
#endif
/// Preemptive destruction is important, because these objects may have a refcount to ContextShared (cyclic reference).
/// TODO: Get rid of this.