Skip to content

Graceful shutdown can be unsuccess #1521

@ianton-ru

Description

@ianton-ru

Describe the bug
Graceful is not graceful sometimes

Description
Sometimes exception can be catched before graceful logic, and code tried to cancel the query

2026.03.12 20:23:02.713412 [ 261 ] {bdffe52f-3542-4cae-9d86-12e917b159f1} <Debug> ReadBuffer: ReadBuffer is canceled by the exception: Code: 210. DB::NetException: Connection reset by peer, while reading from socket (peer: 172.16.1.11:9000, local: 172.16.1.9:56884). (NETWORK_ERROR), Stack trace (when copying this message, always include the lines below):

0. ./contrib/llvm-project/libcxx/include/__exception/exception.h:113: Poco::Exception::Exception(String const&, int) @ 0x000000002ec81620
1. ./ci/tmp/build/./src/Common/Exception.cpp:136: DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x0000000016382778
2. ./src/Common/Exception.h:172: DB::Exception::Exception(String&&, int, String, bool) @ 0x0000000009b09aae
3. ./src/Common/NetException.h:26: DB::NetException::NetException<String, String, String>(int, FormatStringHelperImpl<std::type_identity<String>::type, std::type_identity<String>::type, std::type_identity<String>::type>, String&&, String&&, String&&) @ 0x000000001666aaaa
4. ./ci/tmp/build/./src/IO/ReadBufferFromPocoSocket.cpp:84: DB::ReadBufferFromPocoSocketBase::socketReceiveBytesImpl(char*, unsigned long) @ 0x00000000166698b2
5. ./ci/tmp/build/./src/IO/ReadBufferFromPocoSocket.cpp:108: DB::ReadBufferFromPocoSocketBase::nextImpl() @ 0x000000001666a114
6. ./ci/tmp/build/./src/IO/ReadBufferFromPocoSocketChunked.cpp:103: DB::ReadBufferFromPocoSocketChunked::nextImpl() @ 0x00000000261a61ef
7. ./ci/tmp/build/./src/IO/ReadBuffer.cpp:96: DB::ReadBuffer::next() @ 0x00000000164bfd04
8. ./src/IO/ReadBuffer.h:81: DB::Connection::receivePacket() @ 0x000000002619941c
9. ./ci/tmp/build/./src/Client/MultiplexedConnections.cpp:398: DB::MultiplexedConnections::receivePacketUnlocked(std::function<void (int, Poco::Timespan, DB::AsyncEventTimeoutType, String const&, unsigned int)>) @ 0x0000000026210eb9
10. ./ci/tmp/build/./src/QueryPipeline/RemoteQueryExecutorReadContext.cpp:72: DB::RemoteQueryExecutorReadContext::Task::run(std::function<void (int, Poco::Timespan, DB::AsyncEventTimeoutType, String const&, unsigned int)>, std::function<void ()>) @ 0x000000001e4f5b0e
11. ./ci/tmp/build/./src/Common/AsyncTaskExecutor.cpp:89: DB::AsyncTaskExecutor::Routine::operator()(std::function<void ()>) @ 0x000000001e4f3fd1
12. ./src/Common/Fiber.h:76: boost::context::detail::fiber_capture_record<boost::context::fiber, FiberStack&, Fiber::RoutineImpl<DB::AsyncTaskExecutor::Routine>>::run() @ 0x000000001e4f3a64
13. ./contrib/boost/boost/context/fiber_ucontext.hpp:81: void boost::context::detail::fiber_entry_func<boost::context::detail::fiber_capture_record<boost::context::fiber, FiberStack&, Fiber::RoutineImpl<DB::AsyncTaskExecutor::Routine>>>(unsigned int, unsigned int) @ 0x000000001e4f2ba3
 (version 26.1.3.20001.altinityantalya)

and cancel failed

2026.03.12 20:23:02.865667 [ 261 ] {bdffe52f-3542-4cae-9d86-12e917b159f1} <Error> RemoteSource: Error occurs on cancellation.: Code: 210. DB::Exception: Connection to s0_1_0:9000 terminated. (NETWORK_ERROR), Stack trace (when copying this message, always include the lines below):

0. ./contrib/llvm-project/libcxx/include/__exception/exception.h:113: Poco::Exception::Exception(String const&, int) @ 0x000000002ec81620
1. ./ci/tmp/build/./src/Common/Exception.cpp:136: DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x0000000016382778
2. ./src/Common/Exception.h:172: DB::Exception::Exception(String&&, int, String, bool) @ 0x0000000009b09aae
3. ./src/Common/Exception.h:58: DB::Exception::Exception(PreformattedMessage&&, int) @ 0x0000000009b0925a
4. ./src/Common/Exception.h:190: DB::Exception::Exception<String const&>(int, FormatStringHelperImpl<std::type_identity<String const&>::type>, String const&) @ 0x0000000009b227c0
5. ./ci/tmp/build/./src/Client/Connection.cpp:1033: DB::Connection::sendCancel() @ 0x00000000261927a0
6. ./ci/tmp/build/./src/Client/MultiplexedConnections.cpp:283: DB::MultiplexedConnections::sendCancel() @ 0x000000002621172b
7. ./ci/tmp/build/./src/QueryPipeline/RemoteQueryExecutor.cpp:985: DB::RemoteQueryExecutor::tryCancel(char const*) @ 0x000000001e4cd5a0
8. ./ci/tmp/build/./src/QueryPipeline/RemoteQueryExecutor.cpp:900: DB::RemoteQueryExecutor::cancelUnlocked() @ 0x000000001e4cb8a6
9. ./ci/tmp/build/./src/QueryPipeline/RemoteQueryExecutor.cpp:883: DB::RemoteQueryExecutor::cancel() @ 0x000000001e4cdd58
10. ./ci/tmp/build/./src/Processors/Sources/RemoteSource.cpp:242: DB::RemoteSource::onCancel() @ 0x0000000026b90b71
11. ./ci/tmp/build/./src/Processors/IProcessor.cpp:73: DB::IProcessor::cancel() @ 0x000000002659153d
12. ./ci/tmp/build/./src/Processors/Executors/ExecutingGraph.cpp:421: DB::ExecutingGraph::cancel(bool) @ 0x00000000265b6837
13. ./ci/tmp/build/./src/Processors/Executors/PipelineExecutor.cpp:104: DB::PipelineExecutor::executeStepImpl(unsigned long, DB::IAcquiredSlot*, std::atomic<bool>*) @ 0x00000000265acda0
14. ./ci/tmp/build/./src/Processors/Executors/PipelineExecutor.cpp:279: void std::__function::__policy_func<void ()>::__call_func[abi:ne210105]<DB::PipelineExecutor::spawnThreads(std::shared_ptr<DB::IAcquiredSlot>)::$_0>(std::__function::__policy_storage const*) @ 0x00000000265af162
15. ./contrib/llvm-project/libcxx/include/__functional/function.h:508: ? @ 0x00000000165551e5
16. ./contrib/llvm-project/libcxx/include/__type_traits/invoke.h:0: ThreadFromGlobalPoolImpl<false, true>::ThreadFromGlobalPoolImpl<void (ThreadPoolImpl<ThreadFromGlobalPoolImpl<false, true>>::ThreadFromThreadPool::*)(), ThreadPoolImpl<ThreadFromGlobalPoolImpl<false, true>>::ThreadFromThreadPool*>(void (ThreadPoolImpl<ThreadFromGlobalPoolImpl<false, true>>::ThreadFromThreadPool::*&&)(), ThreadPoolImpl<ThreadFromGlobalPoolImpl<false, true>>::ThreadFromThreadPool*&&)::'lambda'()::operator()() @ 0x000000001655e705
17. ./contrib/llvm-project/libcxx/include/__type_traits/invoke.h:87: void std::__function::__policy_func<void ()>::__call_func[abi:ne210105]<ThreadFromGlobalPoolImpl<false, true>::ThreadFromGlobalPoolImpl<void (ThreadPoolImpl<ThreadFromGlobalPoolImpl<false, true>>::ThreadFromThreadPool::*)(), ThreadPoolImpl<ThreadFromGlobalPoolImpl<false, true>>::ThreadFromThreadPool*>(void (ThreadPoolImpl<ThreadFromGlobalPoolImpl<false, true>>::ThreadFromThreadPool::*&&)(), ThreadPoolImpl<ThreadFromGlobalPoolImpl<false, true>>::ThreadFromThreadPool*&&)::'lambda'()>(std::__function::__policy_storage const*) @ 0x000000001655e622
18. ./contrib/llvm-project/libcxx/include/__functional/function.h:508: ? @ 0x00000000165510f1
19. ./contrib/llvm-project/libcxx/include/__type_traits/invoke.h:0: void* std::__thread_proxy[abi:ne210105]<std::tuple<std::unique_ptr<std::__thread_struct, std::default_delete<std::__thread_struct>>, void (ThreadPoolImpl<std::thread>::ThreadFromThreadPool::*)(), ThreadPoolImpl<std::thread>::ThreadFromThreadPool*>>(void*) @ 0x000000001655b1dc
20. __tsan_thread_start_func @ 0x0000000009a73d68
21. ? @ 0x0000000000094ac3
22. ? @ 0x00000000001268c0
 (version 26.1.3.20001.altinityantalya)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions