Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Superfluous query cancelled exception #63593

Open
cangyin opened this issue May 10, 2024 · 3 comments
Open

Superfluous query cancelled exception #63593

cangyin opened this issue May 10, 2024 · 3 comments
Labels

Comments

@cangyin
Copy link
Contributor

cangyin commented May 10, 2024

There are superfluous similar exception messages saying "Query was cancelled or a client has unexpectedly dropped the connection".
These messages are only printed for secondary query (is_initial_query = 0) of distributed query.

2024.05.10 15:36:33.902900 [ 9401 ] {228489da-10f1-4ce3-b610-a82178a555b5} <Information> TCPHandler: Query was cancelled.
2024.05.10 15:36:33.932125 [ 9401 ] {228489da-10f1-4ce3-b610-a82178a555b5} <Information> executeQuery: Code: 394. DB::Exception: Query was cancelled or a client has unexpectedly dropped the connection. (QUERY_WAS_CANCELLED) (version 23.2.4.7) (from 10.244.166.28:36286) (in query: SELECT `recordTime`, `col1`, `col2`, `col3`, `...` FROM `business`.`network_security_log_local` WHERE foo = bar ORDER BY `recordTimestamp` DESC LIMIT 1, 100)

No stacktraces in log. I think it's because the initial server closed connection on enough data for LIMIT 100 and sent cancel packet just at the time when secondary server finished execution and found that query was canceled, here:
https://github.com/ClickHouse/ClickHouse/blob/v23.2.4.12-stable/src/Server/TCPHandler.cpp#L422

@cangyin cangyin added the potential bug To be reviewed by developers and confirmed/rejected. label May 10, 2024
@cangyin
Copy link
Contributor Author

cangyin commented May 10, 2024

This causes the metric FailedQuery to surge.

@Algunenano Algunenano added unexpected behaviour and removed potential bug To be reviewed by developers and confirmed/rejected. labels May 10, 2024
@Algunenano
Copy link
Member

It might be possible to improve this, but it's expected in order to not waste resources.

@filimonov
Copy link
Contributor

filimonov commented May 10, 2024

We also observed the same problem recently. After the upgrade of one of the clusters from 22.3 to 23.8 the number of QUERY_WAS_CANCELLED for non-initial queries jumped high (the same query always).

The real reason was not the LIMIT, but the INNER JOIN where the right side returned the empty set. (after that the left subquery was cancelled, which is good, but it was not obvious - required deeper look to debug / understand).

Initiator-side message was also not transparent enough

StorageDistributed (...): (10.166.2.140:9000) Cancelling query because enough data has been read

@cangyin cangyin changed the title Superfluous query canceled exception Superfluous query cancelled exception May 10, 2024
@alexey-milovidov alexey-milovidov added the minor Priority: minor label May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants