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

GH-44526: [C++][Acero] Fix crash when thread in asof_join is not running #44584

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion cpp/src/arrow/acero/asof_join_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,9 @@ class AsofJoinNode : public ExecNode {
virtual ~AsofJoinNode() {
#ifdef ARROW_ENABLE_THREADING
PushProcess(false);
process_thread_.join();
if (process_thread_.joinable()) {
process_thread_.join();
}
#endif
}

Expand Down
32 changes: 32 additions & 0 deletions cpp/src/arrow/acero/asof_join_node_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1732,5 +1732,37 @@ TEST(AsofJoinTest, RhsEmptinessRaceEmptyBy) {
AssertExecBatchesEqualIgnoringOrder(result.schema, {exp_batch}, result.batches);
}

// Reproduction of GH-44526: Provoke destruction of not started asofjoin node by providing
zanmato1984 marked this conversation as resolved.
Show resolved Hide resolved
// a sink that fails on creation
TEST(AsofJoinTest, DetroyNotStartedAsofJoinNode) {
auto left_batch = ExecBatchFromJSON({int64()}, R"([[1], [2], [3]])");
auto right_batch =
ExecBatchFromJSON({utf8(), int64()}, R"([["Z", 2], ["B", 3], ["A", 4]])");

Declaration left{"exec_batch_source",
ExecBatchSourceNodeOptions(schema({field("on", int64())}),
{std::move(left_batch)})};
Declaration right{
"exec_batch_source",
ExecBatchSourceNodeOptions(schema({field("colVals", utf8()), field("on", int64())}),
{std::move(right_batch)})};
AsofJoinNodeOptions asof_join_opts({{{"on"}, {}}, {{"on"}, {}}}, 1);
Declaration asof_join{
"asofjoin", {std::move(left), std::move(right)}, std::move(asof_join_opts)};

// Setting invalid arguments, such as nullptr in generator or schema in SinkNodeOptions,
// causes the execution plan to terminate before the asofjoin node is started.
arrow::acero::SinkNodeOptions sink_node_options{/*generator=*/nullptr,
/*schema=*/nullptr};
arrow::acero::Declaration sink =
arrow::acero::Declaration::Sequence({asof_join, {"sink", sink_node_options}});

EXPECT_RAISES_WITH_MESSAGE_THAT(
Invalid,
::testing::HasSubstr(
"`generator` is a required SinkNode option and cannot be null"),
DeclarationToStatus(std::move(sink)));
}
zanmato1984 marked this conversation as resolved.
Show resolved Hide resolved

} // namespace acero
} // namespace arrow
Loading