Skip to content

Commit

Permalink
[fix](pipelineX) fix nullptr in loca exchange dependency (#27488)
Browse files Browse the repository at this point in the history
fix nullptr in loca exchange dependency
  • Loading branch information
Mryange authored Nov 24, 2023
1 parent ce99de3 commit 126714a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
9 changes: 8 additions & 1 deletion be/src/pipeline/pipeline_x/operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,11 @@ Status PipelineXLocalState<DependencyType>::init(RuntimeState* state, LocalState
_dependency = (DependencyType*)info.dependency.get();
if constexpr (!std::is_same_v<FakeDependency, DependencyType>) {
auto& deps = info.upstream_dependencies;
_dependency->set_shared_state(deps.front()->shared_state());
if constexpr (std::is_same_v<LocalExchangeSourceDependency, DependencyType>) {
_dependency->set_shared_state(info.local_exchange_state);
} else {
_dependency->set_shared_state(deps.front()->shared_state());
}
_shared_state = (typename DependencyType::SharedState*)_dependency->shared_state().get();
_shared_state->ref();
_wait_for_dependency_timer =
Expand Down Expand Up @@ -408,6 +412,9 @@ Status PipelineXSinkLocalState<DependencyType>::init(RuntimeState* state,
if constexpr (!std::is_same_v<FakeDependency, DependencyType>) {
auto& deps = info.dependencys;
_dependency = (DependencyType*)deps.front().get();
if constexpr (std::is_same_v<LocalExchangeSinkDependency, DependencyType>) {
_dependency->set_shared_state(info.local_exchange_state);
}
if (_dependency) {
_shared_state =
(typename DependencyType::SharedState*)_dependency->shared_state().get();
Expand Down
1 change: 1 addition & 0 deletions be/src/pipeline/pipeline_x/operator.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ struct LocalSinkStateInfo {
RuntimeProfile* parent_profile;
const int sender_id;
std::vector<DependencySPtr>& dependencys;
std::shared_ptr<LocalExchangeSharedState> local_exchange_state;
const TDataSink& tsink;
};

Expand Down
28 changes: 18 additions & 10 deletions be/src/pipeline/pipeline_x/pipeline_x_fragment_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,17 +426,25 @@ Status PipelineXFragmentContext::_build_pipeline_tasks(
_runtime_states[i]->set_total_load_streams(request.total_load_streams);
_runtime_states[i]->set_num_local_sink(request.num_local_sink);
std::map<PipelineId, PipelineXTask*> pipeline_id_to_task;
for (size_t pip_idx = 0; pip_idx < _pipelines.size(); pip_idx++) {
auto get_local_exchange_state =
[&](PipelinePtr pipeline) -> std::shared_ptr<LocalExchangeSharedState> {
auto source_id = pipeline->operator_xs().front()->operator_id();
if (auto iter = _op_id_to_le_state.find(source_id); iter != _op_id_to_le_state.end()) {
return iter->second;
}
for (auto sink_to_source_id : pipeline->sink_x()->dests_id()) {
if (auto iter = _op_id_to_le_state.find(sink_to_source_id);
iter != _op_id_to_le_state.end()) {
return iter->second;
}
}
return nullptr;
};
for (auto& pipeline : _pipelines) {
auto task = std::make_unique<PipelineXTask>(
_pipelines[pip_idx], _total_tasks++, _runtime_states[i].get(), this,
_runtime_states[i]->runtime_profile(),
_op_id_to_le_state.contains(
_pipelines[pip_idx]->operator_xs().front()->operator_id())
? _op_id_to_le_state
[_pipelines[pip_idx]->operator_xs().front()->operator_id()]
: nullptr,
i);
pipeline_id_to_task.insert({_pipelines[pip_idx]->id(), task.get()});
pipeline, _total_tasks++, _runtime_states[i].get(), this,
_runtime_states[i]->runtime_profile(), get_local_exchange_state(pipeline), i);
pipeline_id_to_task.insert({pipeline->id(), task.get()});
_tasks[i].emplace_back(std::move(task));
}

Expand Down
2 changes: 1 addition & 1 deletion be/src/pipeline/pipeline_x/pipeline_x_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Status PipelineXTask::prepare(RuntimeState* state, const TPipelineInstanceParams
{
// set sink local state
LocalSinkStateInfo info {_parent_profile, local_params.sender_id,
get_downstream_dependency(), tsink};
get_downstream_dependency(), _local_exchange_state, tsink};
RETURN_IF_ERROR(_sink->setup_local_state(state, info));
}

Expand Down

0 comments on commit 126714a

Please sign in to comment.