Skip to content

Commit cd6431a

Browse files
Jialiang Tanfacebook-github-bot
Jialiang Tan
authored andcommitted
fix: Fix arbitration fuzzer failure (facebookincubator#12005)
Summary: Pull Request resolved: facebookincubator#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
1 parent fa95c4e commit cd6431a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

velox/exec/fuzzer/MemoryArbitrationFuzzer.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -840,9 +840,10 @@ void MemoryArbitrationFuzzer::verify() {
840840
}
841841

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

852853
// Create a thread that randomly abort one worker thread
853854
// every task_abort_interval_ms milliseconds.
855+
auto abortRng = FuzzerGenerator(rng_());
854856
std::thread abortControlThread([&]() {
855857
if (FLAGS_task_abort_interval_ms == 0) {
856858
return;
@@ -860,7 +862,7 @@ void MemoryArbitrationFuzzer::verify() {
860862
std::this_thread::sleep_for(
861863
std::chrono::milliseconds(FLAGS_task_abort_interval_ms));
862864
auto tasksList = Task::getRunningTasks();
863-
auto index = getRandomIndex(rng_, tasksList.size() - 1);
865+
vector_size_t index = getRandomIndex(abortRng, tasksList.size() - 1);
864866
++taskAbortRequestCount;
865867
tasksList[index]->requestAbort();
866868
} catch (const VeloxException& e) {

0 commit comments

Comments
 (0)