This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-2.1 in repository https://gitbox.apache.org/repos/asf/doris.git
commit 5da7cd0fba270f166874b4284cda79abe6b547db Author: yiguolei <[email protected]> AuthorDate: Tue Mar 12 21:17:07 2024 +0800 [bugfix](becore) has to use value to capture lambda value to avoid core during callback (#32132) Co-authored-by: yiguolei <[email protected]> --- be/src/vec/sink/writer/vtablet_writer.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/be/src/vec/sink/writer/vtablet_writer.cpp b/be/src/vec/sink/writer/vtablet_writer.cpp index bfac8e2e7a9..042f736861f 100644 --- a/be/src/vec/sink/writer/vtablet_writer.cpp +++ b/be/src/vec/sink/writer/vtablet_writer.cpp @@ -357,9 +357,10 @@ 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; } @@ -367,8 +368,9 @@ Status VNodeChannel::init(RuntimeState* state) { }); _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; } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
