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
main
Akanksha Mahajan 3 years ago committed by Facebook GitHub Bot
parent 7ea26abb8b
commit 3fc2eaf561
  1. 16
      file/prefetch_test.cc

@ -1099,8 +1099,12 @@ TEST_F(PrefetchTest2, ReadAsyncWithPosixFS) {
} }
int buff_prefetch_count = 0; int buff_prefetch_count = 0;
bool read_async_called = false;
SyncPoint::GetInstance()->SetCallBack("FilePrefetchBuffer::Prefetch:Start", SyncPoint::GetInstance()->SetCallBack("FilePrefetchBuffer::Prefetch:Start",
[&](void*) { buff_prefetch_count++; }); [&](void*) { buff_prefetch_count++; });
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"UpdateResults::io_uring_result",
[&](void* /*arg*/) { read_async_called = true; });
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing(); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
// Read the keys. // Read the keys.
@ -1123,11 +1127,13 @@ TEST_F(PrefetchTest2, ReadAsyncWithPosixFS) {
{ {
HistogramData async_read_bytes; HistogramData async_read_bytes;
options.statistics->histogramData(ASYNC_READ_BYTES, &async_read_bytes); options.statistics->histogramData(ASYNC_READ_BYTES, &async_read_bytes);
#if defined(ROCKSDB_IOURING_PRESENT) // Not all platforms support iouring. In that case, ReadAsync in posix
ASSERT_GT(async_read_bytes.count, 0); // won't submit async requests.
#else if (read_async_called) {
ASSERT_EQ(async_read_bytes.count, 0); ASSERT_GT(async_read_bytes.count, 0);
#endif } else {
ASSERT_EQ(async_read_bytes.count, 0);
}
} }
} }

Loading…
Cancel
Save