ContentSquare / chproxy

Open-Source ClickHouse http proxy and load balancer

Home Page:https://www.chproxy.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[QUESTION] concurrent query failed on cancelled requests

tommsawyer opened this issue · comments

Which feature your question relates to?
concurrent requests

Question details
When two identical requests are sent to the CHproxy, it only executes the first one, while the second one waits and sends the same result. If the user cancels the first request, the second one is also canceled with the error "concurrent query failed". Is this expected behavior? It seems to me that in this case the second request should be launched and return the correct result from the clickhouse.

Additional context/motivations
We connected CHProxy to Grafana, and Grafana has a refresh button to reload the data. But sometimes it tries to update itself based on a timer or a html element blur event. In this case, two requests are sent simultaneously, and grafana cancels the first one. CHproxy cancels the second one, so no data is reloaded.

Hi,

The behavior of the "concurrent queries" feature is the one you mentioned: if a query fails, the ones that were run at the same time will fail: https://github.com/ContentSquare/chproxy/blob/master/proxy.go#L396

Thanks for the additional context, we were not aware Grafana was behaving this way.
If the error in case of cancelation is specific, we could have a dedicated behavior for this error.
The core maintainers won't have time in the next months to look at it, so if you have time, feel free to create a PR and we will review it.

I took some time to look into it: my gut feeling is that we need to add an exception to the recoverable status codes for 499 (the status we return from the reverse proxy on cancel). Or maybe we should add the canceled

However, I wasn't able to reproduce it in a test yet. I don't want to create a PR without being able to reproduce it in a test. I'll probably come back to this after the holidays though.