From b27a5f7878c18a8fba2965bf487a61187c3a333e Mon Sep 17 00:00:00 2001 From: Pedro Eugenio Rocha Pedreira Date: Tue, 17 Dec 2024 20:04:52 -0800 Subject: [PATCH] Fix FuzzSimple and FuzzComplex VeloxReaderTests Summary: With the recent change in D66741079, WriterOptions keeps a keep alive to the executor, what prevents an executor from being destructed. Fixing the destruction order of these variables to prevent this situation in these two tests. Reviewed By: darrenfu Differential Revision: D67374064 --- dwio/nimble/velox/tests/VeloxReaderTests.cpp | 21 +++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/dwio/nimble/velox/tests/VeloxReaderTests.cpp b/dwio/nimble/velox/tests/VeloxReaderTests.cpp index 8f67b59..76283b9 100644 --- a/dwio/nimble/velox/tests/VeloxReaderTests.cpp +++ b/dwio/nimble/velox/tests/VeloxReaderTests.cpp @@ -2429,8 +2429,11 @@ TEST_F(VeloxReaderTests, FuzzSimple) { for (auto parallelismFactor : {0U, 1U, std::thread::hardware_concurrency()}) { LOG(INFO) << "Parallelism Factor: " << parallelismFactor; - nimble::VeloxWriterOptions writerOptions; + + // Executor needs to outlive writerOptions since the latter has a keepAlive + // on the former. std::shared_ptr executor; + nimble::VeloxWriterOptions writerOptions; if (parallelismFactor > 0) { executor = @@ -2493,11 +2496,6 @@ TEST_F(VeloxReaderTests, FuzzComplex) { : folly::Random::rand32(); LOG(INFO) << "seed: " << seed; - nimble::VeloxWriterOptions writerOptions; - writerOptions.dictionaryArrayColumns.insert("nested_map_array1"); - writerOptions.dictionaryArrayColumns.insert("nested_map_array2"); - writerOptions.dictionaryArrayColumns.insert("dict_array"); - writerOptions.deduplicatedMapColumns.insert("dict_map"); // Small batches creates more edge cases. size_t batchSize = 10; velox::VectorFuzzer noNulls( @@ -2528,9 +2526,18 @@ TEST_F(VeloxReaderTests, FuzzComplex) { auto batches = 20; std::mt19937 rng{seed}; + // Executor needs to outlive writerOptions since the latter has a keepAlive on + // the former. + std::shared_ptr executor; + for (auto parallelismFactor : {0U, 1U, std::thread::hardware_concurrency()}) { LOG(INFO) << "Parallelism Factor: " << parallelismFactor; - std::shared_ptr executor; + + nimble::VeloxWriterOptions writerOptions; + writerOptions.dictionaryArrayColumns.insert("nested_map_array1"); + writerOptions.dictionaryArrayColumns.insert("nested_map_array2"); + writerOptions.dictionaryArrayColumns.insert("dict_array"); + writerOptions.deduplicatedMapColumns.insert("dict_map"); if (parallelismFactor > 0) { executor =