@@ -22,13 +22,11 @@ namespace ErrorCodes
2222RemoteQueryExecutorReadContext::RemoteQueryExecutorReadContext (
2323 RemoteQueryExecutor & executor_,
2424 bool suspend_when_query_sent_,
25- bool read_packet_type_separately_,
26- bool allow_retries_in_cluster_requests_)
25+ bool read_packet_type_separately_)
2726 : AsyncTaskExecutor(std::make_unique<Task>(*this ))
2827 , executor(executor_)
2928 , suspend_when_query_sent(suspend_when_query_sent_)
3029 , read_packet_type_separately(read_packet_type_separately_)
31- , allow_retries_in_cluster_requests(allow_retries_in_cluster_requests_)
3230{
3331 if (-1 == pipe2 (pipe_fd, O_NONBLOCK))
3432 throw ErrnoException (ErrorCodes::CANNOT_OPEN_FILE, " Cannot create pipe" );
@@ -63,46 +61,38 @@ void RemoteQueryExecutorReadContext::Task::run(AsyncCallback async_callback, Sus
6361 {
6462 while (true )
6563 {
66- try
67- {
68- read_context.has_read_packet_part = PacketPart::None;
69-
70- if (read_context.read_packet_type_separately )
71- {
72- read_context.packet .type = read_context.executor .getConnections ().receivePacketTypeUnlocked (async_callback);
73- read_context.has_read_packet_part = PacketPart::Type;
74- suspend_callback ();
75- }
76- read_context.packet = read_context.executor .getConnections ().receivePacketUnlocked (async_callback);
77- read_context.has_read_packet_part = PacketPart::Body;
78- if (read_context.packet .type == Protocol::Server::Data)
79- read_context.has_data_packets = true ;
80- }
81- catch (const Exception & e)
64+ read_context.has_read_packet_part = PacketPart::None;
65+
66+ if (read_context.read_packet_type_separately )
8267 {
83- // / If cluster node unxepectedly shutted down (kill/segfault/power off/etc.) socket just closes.
84- // / If initiator did not process any data packets before, this fact can be ignored.
85- // / Unprocessed tasks will be executed on other nodes.
86- if (e.code () == ErrorCodes::ATTEMPT_TO_READ_AFTER_EOF
87- && !read_context.has_data_packets .load () && read_context.executor .skipUnavailableShards ())
88- {
89- read_context.has_read_packet_part = PacketPart::None;
90- }
91- else
92- throw ;
68+ read_context.packet .type = read_context.executor .getConnections ().receivePacketTypeUnlocked (async_callback);
69+ read_context.has_read_packet_part = PacketPart::Type;
70+ suspend_callback ();
9371 }
72+ read_context.packet = read_context.executor .getConnections ().receivePacketUnlocked (async_callback);
73+ read_context.has_read_packet_part = PacketPart::Body;
74+ if (read_context.packet .type == Protocol::Server::Data)
75+ read_context.has_data_packets = true ;
9476
9577 suspend_callback ();
9678 }
9779 }
98- catch (const Exception &)
80+ catch (const Exception & e )
9981 {
100- if (!read_context.allow_retries_in_cluster_requests )
82+ // / If cluster node unxepectedly shutted down (kill/segfault/power off/etc.) socket just closes.
83+ // / If initiator did not process any data packets before, this fact can be ignored.
84+ // / Unprocessed tasks will be executed on other nodes.
85+ if (e.code () == ErrorCodes::ATTEMPT_TO_READ_AFTER_EOF
86+ && !read_context.has_data_packets .load ()
87+ && read_context.executor .skipUnavailableShards ())
88+ {
89+ read_context.packet .type = Protocol::Server::ConnectionLost;
90+ read_context.packet .exception = std::make_unique<Exception>(getCurrentExceptionMessageAndPattern (true ), getCurrentExceptionCode ());
91+ read_context.has_read_packet_part = PacketPart::Body;
92+ suspend_callback ();
93+ }
94+ else
10195 throw ;
102- read_context.packet .type = Protocol::Server::ConnectionLost;
103- read_context.packet .exception = std::make_unique<Exception>(getCurrentExceptionMessageAndPattern (true ), getCurrentExceptionCode ());
104- read_context.has_read_packet_part = PacketPart::Body;
105- suspend_callback ();
10696 }
10797}
10898
0 commit comments