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

[bugfix](becore) has to use value to capture lambda value to avoid core during callback #32132

Merged
merged 1 commit into from
Mar 12, 2024
Merged
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
10 changes: 6 additions & 4 deletions be/src/vec/sink/writer/vtablet_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,18 +357,20 @@ Status VNodeChannel::init(RuntimeState* state) {
_cur_add_block_request->set_eos(false);

// add block closure
// Has to using value to capture _task_exec_ctx because tablet writer may destroyed during callback.
_send_block_callback = WriteBlockCallback<PTabletWriterAddBlockResult>::create_shared();
_send_block_callback->addFailedHandler([this](bool is_last_rpc) {
auto ctx_lock = _task_exec_ctx.lock();
_send_block_callback->addFailedHandler([&, task_exec_ctx = _task_exec_ctx](bool is_last_rpc) {
auto ctx_lock = task_exec_ctx.lock();
if (ctx_lock == nullptr) {
return;
}
_add_block_failed_callback(is_last_rpc);
});

_send_block_callback->addSuccessHandler(
[this](const PTabletWriterAddBlockResult& result, bool is_last_rpc) {
auto ctx_lock = _task_exec_ctx.lock();
[&, task_exec_ctx = _task_exec_ctx](const PTabletWriterAddBlockResult& result,
bool is_last_rpc) {
auto ctx_lock = task_exec_ctx.lock();
if (ctx_lock == nullptr) {
return;
}
Expand Down
Loading