This is an automated email from the ASF dual-hosted git repository.
liaoxin01 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 5d62cb9c084 [fix](test) wait on finalizers instead of pending_count in
the async cache write UT (#67901)
5d62cb9c084 is described below
commit 5d62cb9c084bc62912e05ccd9d0ac012dbe47e33
Author: Mingyu Chen (Rayner) <[email protected]>
AuthorDate: Sun Sep 13 11:46:15 2026 +0800
[fix](test) wait on finalizers instead of pending_count in the async cache
write UT (#67901)
### What problem does this PR solve?
Issue Number: close #xxx
Related PR: #65658
Problem Summary:
`AsyncCacheWriteManagerTest.PendingLimitDecreaseKeepsReplacingOldestQueuedTask`
is flaky in BE UT (e.g. TeamCity build 83717 on #66729):
```
../test/io/cache/async_cache_write_manager_test.cpp:1611
Expected equality of these values:
finalized_count
Which is: 0
1
```
`AsyncCacheWriteManager::_complete_active_task` decrements
`_pending_count` under the queue mutex and only afterwards calls
`task.finalize()`. The test polled `pending_count() == 0` and then
immediately asserted that every finalizer had run, so a worker that had
already dropped the counter but not yet invoked the callback made the
assertion fail.
The finalizers in this test already notify a condition variable, so wait
on "all finalizers fired" instead of the pending counter;
`pending_count()`/`pending_bytes()` are asserted afterwards, at which
point they are deterministically zero.
---
be/test/io/cache/async_cache_write_manager_test.cpp | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/be/test/io/cache/async_cache_write_manager_test.cpp
b/be/test/io/cache/async_cache_write_manager_test.cpp
index 2e3532bfed0..b3d027e86dc 100644
--- a/be/test/io/cache/async_cache_write_manager_test.cpp
+++ b/be/test/io/cache/async_cache_write_manager_test.cpp
@@ -1602,14 +1602,17 @@ TEST_F(AsyncCacheWriteManagerTest,
PendingLimitDecreaseKeepsReplacingOldestQueue
released_entries = std::numeric_limits<size_t>::max();
}
cv.notify_all();
- for (int attempt = 0; attempt < 5000 && manager->pending_count() != 0;
++attempt) {
- std::this_thread::sleep_for(std::chrono::milliseconds(1));
+ // The worker drops the task from the pending counters before it invokes
the finalizer, so
+ // wait on the finalizers themselves rather than on pending_count()
reaching zero.
+ {
+ std::unique_lock lock(mutex);
+ ASSERT_TRUE(cv.wait_for(lock, std::chrono::seconds(5), [&]() {
+ return std::all_of(finalized.begin(), finalized.end(),
+ [](size_t count) { return count == 1; });
+ }));
}
ASSERT_EQ(manager->pending_count(), 0);
ASSERT_EQ(manager->pending_bytes(), 0);
- for (size_t finalized_count : finalized) {
- EXPECT_EQ(finalized_count, 1);
- }
EXPECT_FALSE(is_cache_range_downloaded(cache.get(), first_evicted_hash));
EXPECT_FALSE(is_cache_range_downloaded(cache.get(), second_evicted_hash));
EXPECT_FALSE(is_cache_range_downloaded(cache.get(), third_evicted_hash));
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]