Skip to content

Commit 53dcda0

Browse files
xiaoxmengmeta-codesync[bot]
authored andcommitted
fix: Clear AsyncDataCache in test SetUp to fix flakiness (#16533)
Summary: Pull Request resolved: #16533 Some tests using HiveConnectorTestBase were experiencing flaky failures with "read past EOF" errors in PagedInputStream. This was caused by stale cache entries in AsyncDataCache being returned when temp files were reused between tests (same inode/fileNum leading to cache key collisions). The fix clears all unpinned cache entries at the start of each test to ensure tests start with a clean cache state. This prevents corrupted/stale data from being read when temp file paths or inodes are recycled by the OS. Reviewed By: Yuhta Differential Revision: D94400710 fbshipit-source-id: edaefc1945748f9558289cc34cf8987ef3c31b6d
1 parent 3591d31 commit 53dcda0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

velox/exec/tests/utils/HiveConnectorTestBase.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "velox/exec/tests/utils/HiveConnectorTestBase.h"
1818

19+
#include "velox/common/caching/AsyncDataCache.h"
1920
#include "velox/common/file/FileSystems.h"
2021
#include "velox/common/file/tests/FaultyFileSystem.h"
2122
#include "velox/connectors/hive/HiveConnector.h"
@@ -37,6 +38,13 @@ HiveConnectorTestBase::HiveConnectorTestBase() {
3738

3839
void HiveConnectorTestBase::SetUp() {
3940
OperatorTestBase::SetUp();
41+
42+
// Clear any stale cache entries from previous tests to avoid reading
43+
// corrupted/stale data when temp files are reused (same inode/fileNum).
44+
if (auto* cache = cache::AsyncDataCache::getInstance()) {
45+
cache->clear();
46+
}
47+
4048
connector::hive::HiveConnectorFactory factory;
4149
auto hiveConnector = factory.newConnector(
4250
kHiveConnectorId,

0 commit comments

Comments
 (0)