Skip to content

Commit 9ac4c8b

Browse files
committed
Fix leaving connection in a broken state after preliminary cancellation distributed queries
The problem is that some places in the code (i.e. RemoteSource::onUpdatePorts()), can call finish() even before sendQueryAsync() finishes sending the query, and so if after it will try to call finish() again (after sendQueryAsync() finishes) it will be no-op. The problem pops up after #92807, since RemoteSource has these (anti-)pattern.
1 parent 6378841 commit 9ac4c8b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/QueryPipeline/RemoteQueryExecutor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -778,9 +778,6 @@ void RemoteQueryExecutor::finish()
778778
{
779779
LockAndBlocker guard(was_cancelled_mutex);
780780

781-
/// To make sure finish is only called once
782-
SCOPE_EXIT({ finished = true; });
783-
784781
/** If one of:
785782
* - nothing started to do;
786783
* - received all packets before EndOfStream;
@@ -791,6 +788,9 @@ void RemoteQueryExecutor::finish()
791788
if (!isQueryPending() || hasThrownException())
792789
return;
793790

791+
/// To make sure finish is only called once
792+
SCOPE_EXIT({ finished = true; });
793+
794794
/** If you have not read all the data yet, but they are no longer needed.
795795
* This may be due to the fact that the data is sufficient (for example, when using LIMIT).
796796
*/

0 commit comments

Comments
 (0)