fix: prevent prolonged ClickHouse read hangs - #5993
Draft
disintegrator wants to merge 1 commit into
Draft
Conversation
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
QueryandQueryRowonce when a transport failure occurs before any result is exposed. The retry opens a separate ClickHouse client so it dials a fresh connection.Selectis deadline-bounded but not retried because it may partially mutate its destination, and failures after row consumption begins are returned directly.Motivation
An alert identified a burst of six telemetry API failures. Every request ended as an Nginx 504 after almost exactly 180 seconds, indicating that work was remaining in flight until the proxy deadline rather than failing promptly in the application.
The investigation correlated the failures with a ClickHouse Cloud rolling node replacement around a scheduled backup. Server logs showed native ClickHouse connections receiving EOF while reading the first result block from connections established to nodes leaving service. The client configured a 60-second server-side execution limit, but left
clickhouse-go's socket read timeout unset; the driver therefore used its 300-second default. A stalled socket could consequently outlive the 180-second HTTP request limit and hold request capacity until Nginx terminated it.The mitigation establishes an application-owned failure budget below the proxy deadline and gives idempotent reads one chance to recover on a newly dialed connection. Persistent or non-transport failures still return within that budget instead of accumulating as 180-second requests.
Summary by cubic
Fixes ClickHouse read hangs that caused telemetry API 504s by bounding read timeouts and retrying transport failures before results are exposed.
QueryandQueryRowonce on transport failure using a freshly dialed connection.Selectare not retried;Selectcan partially mutate its destination and failures after rows are consumed are returned directly.Written for commit 3248e1d. Summary will update on new commits.