mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-12-02 21:00:13 -05:00
test: let tp_heavy's work finish before destroying each pool
~ThreadPool cancels its workers without draining the queue. Queued work normally still runs because a worker acts on the cancellation only when it blocks waiting for work, but that is a race: under load tp_heavy_repeated_construct_destroy lost some of its 400 tasks in about one run in ten. Nothing in mergerfs destroys a pool that still has work: an in-flight readdir keeps its implementation alive and waits for its own tasks. Wait for the tasks before each pool goes out of scope instead of relying on the destructor.
This commit is contained in:
parent
e954f42751
commit
6846ee2674
1 changed files with 5 additions and 0 deletions
|
|
@ -2450,6 +2450,11 @@ test_tp_heavy_repeated_construct_destroy()
|
|||
std::this_thread::sleep_for(std::chrono::microseconds(25));
|
||||
counter.fetch_add(1);
|
||||
});
|
||||
|
||||
// ~ThreadPool cancels its workers without draining the queue,
|
||||
// so let the work finish before the pool is destroyed.
|
||||
TEST_CHECK(wait_until([&counter]() { return counter.load() == 400; },
|
||||
30000));
|
||||
}
|
||||
|
||||
TEST_CHECK(counter.load() == 400);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue