This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-4.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-4.1 by this push:
     new d99bf5f2f0b branch-4.1: [fix](test) wait on finalizers instead of 
pending_count in the async cache write UT #67901 (#67905)
d99bf5f2f0b is described below

commit d99bf5f2f0be0f04f6bb1201692a6e6a535ea963
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Sun Sep 13 18:51:13 2026 +0800

    branch-4.1: [fix](test) wait on finalizers instead of pending_count in the 
async cache write UT #67901 (#67905)
    
    Cherry-picked from #67901
    
    Co-authored-by: Mingyu Chen (Rayner) <[email protected]>
---
 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]

Reply via email to