Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[native] Fix TaskManagerTest.buildSpillDirectoryFailure #23098

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,26 @@ namespace facebook::presto {

namespace {

// Repeatedly calls for cleanOldTasks() for a while to ensure that we overcome a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for cleanOldTasks() -->= cleanOldTasks()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
Let's fix this some other time.
Now it is important to land this to remove the noise.

// potential race condition where we call cleanOldTasks() before some Tasks are
// ready to be cleaned.
void waitForAllOldTasksToBeCleaned(
TaskManager* taskManager,
uint64_t maxWaitUs) {
taskManager->cleanOldTasks();

uint64_t waitUs = 0;
while (taskManager->getNumTasks() > 0) {
constexpr uint64_t kWaitInternalUs = 1'000;
std::this_thread::sleep_for(std::chrono::microseconds(kWaitInternalUs));
waitUs += kWaitInternalUs;
taskManager->cleanOldTasks();
if (waitUs >= maxWaitUs) {
break;
}
}
}

// Generates task ID in Presto-compatible format.
class TaskIdGenerator {
public:
Expand Down Expand Up @@ -1531,7 +1551,7 @@ TEST_F(TaskManagerTest, buildSpillDirectoryFailure) {
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
}
taskManager_->cleanOldTasks();
waitForAllOldTasksToBeCleaned(taskManager_.get(), 3'000'000);
velox::exec::test::waitForAllTasksToBeDeleted(3'000'000);
ASSERT_TRUE(taskManager_->tasks().empty());
}
Expand Down
Loading