-
Notifications
You must be signed in to change notification settings - Fork 3.3k
fix(feature-flags): tolerate transient clickhouse connection errors in enrichment task #91330
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
base: master
Are you sure you want to change the base?
Changes from all commits
c46d706
ed004b6
7e8a674
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,7 @@ | |
| from posthog.clickhouse.client.limit import ConcurrencyLimitExceeded, limit_concurrency | ||
| from posthog.clickhouse.query_tagging import Feature, Product, get_query_tags, tag_queries | ||
| from posthog.cloud_utils import is_cloud | ||
| from posthog.errors import CH_TRANSIENT_ERRORS, CHQueryErrorUnknownTable | ||
| from posthog.errors import CH_TRANSIENT_CONNECTION_ERRORS, CH_TRANSIENT_ERRORS, CHQueryErrorUnknownTable | ||
| from posthog.exceptions import ClickHouseAtCapacity | ||
| from posthog.exceptions_capture import capture_exception | ||
| from posthog.metrics import pushed_metrics_registry | ||
|
|
@@ -1038,6 +1038,14 @@ def find_flags_with_enriched_analytics() -> None: | |
| # Expected on self-hosted instances with an incomplete ClickHouse schema (e.g. missing | ||
| # migrations) - not worth capturing as an exception, just skip this run. | ||
| logger.warning("Find flags with enriched analytics skipped, table missing", error=e) | ||
| except CH_TRANSIENT_CONNECTION_ERRORS as e: | ||
| # A ClickHouse connection dropped at connect time or mid-read. This handler covers the main | ||
| # analytics query and a cold-cache materialized-column registry lookup, which both run inline. | ||
| # A warm-but-stale registry entry refreshes on a background thread (cache_for with | ||
| # background_refresh), so a transient error there stays outside this handler; the task keeps | ||
| # running on the stale value, and the SDK thread hook reports that failure separately. The | ||
| # next 12-hourly run recovers, so skip this one instead of minting an error-tracking issue. | ||
| logger.warning("Find flags with enriched analytics skipped, transient connection error", error=e) | ||
|
Comment on lines
+1041
to
+1048
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Permanent network failures are treated as benignWhy we think it's a valid issue
Issue description
Suggested fixRetry these exceptions for a bounded number of attempts. Capture the final exception and fail the task when all attempts fail. This keeps short resets quiet but reports persistent failures. Prompt to fix with AI (copy-paste)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Confirmed against the current code, and it is a real trade-off rather than an oversight, so I'm leaving it for a human on the feature-flags team to decide rather than changing it unattended. The caught set here is The reason I'm not just applying the suggested bounded retry:
So the decision a human needs to make is whether a persistent ClickHouse connection failure on this task should surface as an error-tracking issue at all, and if so via which of the above — noise reduction vs outage visibility. That's why this is flagged for review rather than fixed here. |
||
| except Exception as e: | ||
| logger.exception("Find flags with enriched analytics failed", error=e) | ||
| capture_exception( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.