Skip to content

Commit

Permalink
fix: Fix arbitration fuzzer failure (#12005)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #12005

Arbitration fuzzer fails because concurrent access of the rng_ member variable from multiple threads. This change fixes it by creating additional rand gens for different threads.

Reviewed By: xiaoxmeng, zation99

Differential Revision: D67770533

fbshipit-source-id: 4dce619fe600d4f0f91dd15b099cc5e3613223a9
  • Loading branch information
Jialiang Tan authored and facebook-github-bot committed Jan 2, 2025
1 parent fa95c4e commit cd6431a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions velox/exec/fuzzer/MemoryArbitrationFuzzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -840,9 +840,10 @@ void MemoryArbitrationFuzzer::verify() {
}

// Inject global arbitration.
auto shrinkRng = FuzzerGenerator(rng_());
std::thread globalShrinkThread([&]() {
while (!stop) {
if (getRandomIndex(rng_, 99) < FLAGS_global_arbitration_pct) {
if (getRandomIndex(shrinkRng, 99) < FLAGS_global_arbitration_pct) {
memory::memoryManager()->shrinkPools();
}
std::this_thread::sleep_for(std::chrono::seconds(1));
Expand All @@ -851,6 +852,7 @@ void MemoryArbitrationFuzzer::verify() {

// Create a thread that randomly abort one worker thread
// every task_abort_interval_ms milliseconds.
auto abortRng = FuzzerGenerator(rng_());
std::thread abortControlThread([&]() {
if (FLAGS_task_abort_interval_ms == 0) {
return;
Expand All @@ -860,7 +862,7 @@ void MemoryArbitrationFuzzer::verify() {
std::this_thread::sleep_for(
std::chrono::milliseconds(FLAGS_task_abort_interval_ms));
auto tasksList = Task::getRunningTasks();
auto index = getRandomIndex(rng_, tasksList.size() - 1);
vector_size_t index = getRandomIndex(abortRng, tasksList.size() - 1);
++taskAbortRequestCount;
tasksList[index]->requestAbort();
} catch (const VeloxException& e) {
Expand Down

0 comments on commit cd6431a

Please sign in to comment.