Skip to content

Commit

Permalink
chore: use setting to fallback to kill query on cluster (#27196)
Browse files Browse the repository at this point in the history
  • Loading branch information
Daesgar authored Dec 31, 2024
1 parent b89b018 commit 1a4c624
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion posthog/clickhouse/cancel.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from statshog.defaults.django import statsd

from posthog import settings
from posthog.api.services.query import logger
from posthog.clickhouse.client import sync_execute
from posthog.clickhouse.client.connection import default_client
Expand Down Expand Up @@ -32,7 +33,7 @@ def cancel_query_on_cluster(team_id: int, client_query_id: str) -> None:
sync_client=client,
)
logger.info("Cancelled query %s for team %s, result: %s", client_query_id, team_id, result)
else:
elif settings.CLICKHOUSE_FALLBACK_CANCEL_QUERY_ON_CLUSTER:
logger.debug("No initiator host found for query %s, cancelling query on cluster", client_query_id)
result = sync_execute(
f"KILL QUERY ON CLUSTER '{CLICKHOUSE_CLUSTER}' WHERE query_id LIKE %(client_query_id)s",
Expand Down
3 changes: 3 additions & 0 deletions posthog/settings/data_stores.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ def postgres_config(host: str) -> dict:
CLICKHOUSE_VERIFY: bool = get_from_env("CLICKHOUSE_VERIFY", True, type_cast=str_to_bool)
CLICKHOUSE_ENABLE_STORAGE_POLICY: bool = get_from_env("CLICKHOUSE_ENABLE_STORAGE_POLICY", False, type_cast=str_to_bool)
CLICKHOUSE_SINGLE_SHARD_CLUSTER: str = os.getenv("CLICKHOUSE_SINGLE_SHARD_CLUSTER", "posthog_single_shard")
CLICKHOUSE_FALLBACK_CANCEL_QUERY_ON_CLUSTER = get_from_env(
"CLICKHOUSE_FALLBACK_CANCEL_QUERY_ON_CLUSTER", default=True, type_cast=str_to_bool
)

CLICKHOUSE_CONN_POOL_MIN: int = get_from_env("CLICKHOUSE_CONN_POOL_MIN", 20, type_cast=int)
CLICKHOUSE_CONN_POOL_MAX: int = get_from_env("CLICKHOUSE_CONN_POOL_MAX", 1000, type_cast=int)
Expand Down

0 comments on commit 1a4c624

Please sign in to comment.