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

Fix a bug that MPP tasks may leak threads forever (#4241) #4645

Merged
11 changes: 5 additions & 6 deletions dbms/src/Flash/Mpp/MPPTunnel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// TODO: remove this include after move MPPTask to a single file
#include <Flash/Mpp/MPPHandler.h>
#include <Flash/Mpp/MPPTunnel.h>
#include <Flash/Mpp/Utils.h>
#include <Flash/Mpp/TaskStatus.h>
#include <Flash/Mpp/Utils.h>
#include <fmt/core.h>

namespace DB
Expand All @@ -15,8 +15,7 @@ namespace FailPoints
extern const char exception_during_mpp_close_tunnel[];
} // namespace FailPoints

MPPTunnel::MPPTunnel(
const mpp::TaskMeta & receiver_meta_,
MPPTunnel::MPPTunnel(const mpp::TaskMeta & receiver_meta_,
const mpp::TaskMeta & sender_meta_,
const std::chrono::seconds timeout_,
const std::shared_ptr<MPPTask> & current_task_)
Expand All @@ -26,8 +25,7 @@ MPPTunnel::MPPTunnel(
current_task(current_task_),
tunnel_id(fmt::format("tunnel{}+{}", sender_meta_.task_id(), receiver_meta_.task_id())),
log(&Logger::get(tunnel_id))
{
}
{}

MPPTunnel::~MPPTunnel()
{
Expand Down Expand Up @@ -112,6 +110,8 @@ void MPPTunnel::connect(::grpc::ServerWriter<::mpp::MPPDataPacket> * writer_)
{
throw Exception("has connected");
}
if (finished)
throw Exception("has finished");
LOG_DEBUG(log, "ready to connect");
connected = true;
writer = writer_;
Expand Down Expand Up @@ -149,4 +149,3 @@ void MPPTunnel::finishWithLock()
}

} // namespace DB