Skip to content

fix(replacer): log HTTP driver exception chains - #8378

Closed
sentry-junior[bot] wants to merge 4 commits into
masterfrom
fix/replacer-log-http-driver-exception
Closed

fix(replacer): log HTTP driver exception chains#8378
sentry-junior[bot] wants to merge 4 commits into
masterfrom
fix/replacer-log-http-driver-exception

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Why

errors-replacer dies with:

Unexpected Http Driver Exception
Caught exception, shutting down...

and nothing useful after that.

Two reasons the real failure is invisible:

  1. clickhouse-connect logs Unexpected Http Driver Exception without the urllib3/socket cause.
  2. Snuba LOG_FORMAT is %(asctime)s %(message)s, so arroyo's logger.exception traceback often never shows up in Cloud Logging.

What

  • Fold the exception cause chain into a single-line detail string in the ClickHouse client (OperationalError / StreamFailureError).
  • Log that detail with host/port before re-raising as ClickhouseError.
  • Log terminal replacement failures once in flush_batch (after retries/fallback), with type/project/host.
  • Do not log inside run_query: that path is retried by ShardedExecutor and can fall back to the query node.

This does not fix the slow shard / timeout root cause. It only makes the next crash tell us whether we hit ReadTimeout, connection reset, protocol error, etc.

Test plan

  • tests/clickhouse/test_connect.py covers chain formatting + driver/stream error logging
  • ruff/mypy clean on changed files
  • After deploy, confirm the next replacer crash log includes ClickHouse HTTP driver error ... detail=... | caused by: ...

Requested by PDPM.

--

View Junior Session in Sentry

sentry-junior Bot and others added 2 commits August 22, 2026 02:27
clickhouse-connect only emits "Unexpected Http Driver Exception" without
the urllib3/socket cause, and snuba's LOG_FORMAT drops multi-line
tracebacks in Cloud Logging. Fold the cause chain into one-line errors
on the ClickHouse client and replacer paths so we can see timeouts vs
connection resets.

Co-Authored-By: PDPM <pierre.massat@sentry.io>
@phacops
phacops marked this pull request as ready for review August 22, 2026 02:38
@phacops
phacops requested a review from a team as a code owner August 22, 2026 02:38
Co-Authored-By: PDPM <pierre.massat@sentry.io>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1c99c5e. Configure here.

Comment thread snuba/replacer.py Outdated
run_query sits under ShardedExecutor retries and query-node fallback.
ERROR there made recoverable replica failures look fatal. Keep the
single-line crash log in flush_batch after retries are exhausted.

Co-Authored-By: PDPM <pierre.massat@sentry.io>
@phacops phacops closed this Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant