Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Add workaround for CH query condition cache bug (#6562)

Artur Pata43f714efa534
diff --git a/config/runtime.exs b/config/runtime.exs
index 91f056353d..c78ed517e9 100644
--- a/config/runtime.exs
+++ b/config/runtime.exs
@@ -647,23 +647,36 @@ ch_transport_opts =
ch_transport_opts
end
+# Workaround for a ClickHouse bug where sampled queries poison the query
+# condition cache, causing subsequent unsampled queries to return invalid
+# results. Sampling is EE only, so this is scoped to EE builds.
+# Fixed upstream in ClickHouse/ClickHouse#108488; remove once ClickHouse
+# updated.
+ch_query_condition_cache_settings =
+ if config_env() in [:ce, :ce_dev, :ce_test] do
+ []
+ else
+ [use_query_condition_cache: 0]
+ end
+
config :plausible, Plausible.ClickhouseRepo,
queue_target: 500,
queue_interval: 2000,
timeout: 15_000,
url: ch_db_url,
transport_opts: ch_transport_opts,
- settings: [
- readonly: 1,
- join_algorithm: "direct,parallel_hash,hash",
- # stops queries when :timeout ClickhouseRepo connection :timeout value reached
- cancel_http_readonly_queries_on_client_close: 1,
- # stops queries when they will likely take over 20s
- # NB! when :timeout is overridden to be over 20s,
- # for it to have meaningful effect,
- # this must be overridden as well
- max_execution_time: 20
- ]
+ settings:
+ [
+ readonly: 1,
+ join_algorithm: "direct,parallel_hash,hash",
+ # stops queries when ClickhouseRepo connection :timeout value reached
+ cancel_http_readonly_queries_on_client_close: 1,
+ # stops queries when they will likely take over 20s
+ # NB! when :timeout is overridden to be over 20s,
+ # for it to have meaningful effect,
+ # this must be overridden as well
+ max_execution_time: 20
+ ] ++ ch_query_condition_cache_settings
config :plausible, Plausible.IngestRepo,
queue_target: 500,