| 302 | } |
| 303 | |
| 304 | RemoteQueryExecutor::~RemoteQueryExecutor() |
| 305 | { |
| 306 | /// We should finish establishing connections to disconnect it later, |
| 307 | /// so these connections won't be in the out-of-sync state. |
| 308 | if (read_context && !established) |
| 309 | { |
| 310 | /// Set was_cancelled, so the query won't be sent after creating connections. |
| 311 | was_cancelled = true; |
| 312 | |
| 313 | /// Cancellation may throw (i.e. some timeout), and in case of pipeline |
| 314 | /// had not been properly created properly (EXCEPTION_BEFORE_START) |
| 315 | /// cancel will not be sent, so cancellation will be done from dtor and |
| 316 | /// will throw. |
| 317 | try |
| 318 | { |
| 319 | read_context->cancel(); |
| 320 | } |
| 321 | catch (...) |
| 322 | { |
| 323 | tryLogCurrentException(log ? log : getLogger("RemoteQueryExecutor")); |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | /** If interrupted in the middle of the loop of communication with replicas, then interrupt |
| 328 | * all connections, then read and skip the remaining packets to make sure |
| 329 | * these connections did not remain hanging in the out-of-sync state. |
| 330 | */ |
| 331 | if (established || (isQueryPending() && connections)) |
| 332 | { |
| 333 | /// May also throw (so as cancel() above) |
| 334 | try |
| 335 | { |
| 336 | connections->disconnect(); |
| 337 | } |
| 338 | catch (...) |
| 339 | { |
| 340 | tryLogCurrentException(log ? log : getLogger("RemoteQueryExecutor")); |
| 341 | } |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | /** If we receive a block with slightly different column types, or with excessive columns, |
| 346 | * we will adapt it to expected structure. |
nothing calls this directly
no test coverage detected