From 0a9793849bfdd4c94b93aeafaaa0d813470e2ae2 Mon Sep 17 00:00:00 2001 From: Xiaoxuan Meng Date: Mon, 7 Oct 2024 16:54:26 -0700 Subject: [PATCH] Fix data race in cache eviction path Summary: The cache entry init code path (thread) logs an error message with cache entry size when allocation fails. This happens after it releases the cache entry which could be race with cache eviction code path which clears to zero. The fix is to print out the allocated pages instead of bytes in cache error message to prevent. Differential Revision: D64014938 --- velox/common/caching/AsyncDataCache.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/velox/common/caching/AsyncDataCache.cpp b/velox/common/caching/AsyncDataCache.cpp index 6da669daed66..cd8dc97b28ec 100644 --- a/velox/common/caching/AsyncDataCache.cpp +++ b/velox/common/caching/AsyncDataCache.cpp @@ -130,8 +130,8 @@ void AsyncDataCacheEntry::initialize(FileCacheKey key) { // No memory to cover 'this'. release(); VELOX_CACHE_ERROR(fmt::format( - "Failed to allocate {} bytes for cache: {}", - size_, + "Failed to allocate {} pages for cache: {}", + sizePages, cache->allocator()->getAndClearFailureMessage())); } }