From 3fc2eaf5612de7077446a55a00ba80744ccd0ce6 Mon Sep 17 00:00:00 2001 From: Akanksha Mahajan Date: Thu, 7 Apr 2022 10:31:50 -0700 Subject: [PATCH] Fix valgrind test failure for async read (#9819) Summary: Since all plaftorms don't support io_uring. So updated the unit test to take that into consideration when testing async reads in unit tests. Pull Request resolved: https://github.com/facebook/rocksdb/pull/9819 Test Plan: valgrind --error-exitcode=2 --leak-check=full ./prefetch_test --gtest_filter=PrefetchTest2.ReadAsyncWithPosixFS CircleCI jobs Reviewed By: pdillinger Differential Revision: D35469959 Pulled By: akankshamahajan15 fbshipit-source-id: b170459ec816487fc0a13b1d55dbbe4f754b2eba --- file/prefetch_test.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/file/prefetch_test.cc b/file/prefetch_test.cc index 3e9bb7156..b9cfa285a 100644 --- a/file/prefetch_test.cc +++ b/file/prefetch_test.cc @@ -1099,8 +1099,12 @@ TEST_F(PrefetchTest2, ReadAsyncWithPosixFS) { } int buff_prefetch_count = 0; + bool read_async_called = false; SyncPoint::GetInstance()->SetCallBack("FilePrefetchBuffer::Prefetch:Start", [&](void*) { buff_prefetch_count++; }); + ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack( + "UpdateResults::io_uring_result", + [&](void* /*arg*/) { read_async_called = true; }); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing(); // Read the keys. @@ -1123,11 +1127,13 @@ TEST_F(PrefetchTest2, ReadAsyncWithPosixFS) { { HistogramData async_read_bytes; options.statistics->histogramData(ASYNC_READ_BYTES, &async_read_bytes); -#if defined(ROCKSDB_IOURING_PRESENT) - ASSERT_GT(async_read_bytes.count, 0); -#else - ASSERT_EQ(async_read_bytes.count, 0); -#endif + // Not all platforms support iouring. In that case, ReadAsync in posix + // won't submit async requests. + if (read_async_called) { + ASSERT_GT(async_read_bytes.count, 0); + } else { + ASSERT_EQ(async_read_bytes.count, 0); + } } }