Skip to content

Retry API request when DNS resolution of sentry.io fails #2763

@yangskyboxlabs

Description

@yangskyboxlabs

Problem Statement

This is a follow-up to #2177: API request failed caused by: [6] Couldn't resolve host name (Could not resolve host: sentry.io)

We are seeing this when uploading symbol files from Linux hosts, with a failure rate of <10% (4 of the previous 50 invocations, at time of writing).

I suspect it is caused by unreliable .io TLD DNS servers that is somehow amplified by some combination of a DNS stack on Linux.

If I'm grokking the retry logic correctly, it only attempts retries on certain HTTP status codes, and does not cover the cases from other parts of the stack:

const RETRY_STATUS_CODES: &[u32] = &[
    http::HTTP_STATUS_502_BAD_GATEWAY,
    http::HTTP_STATUS_503_SERVICE_UNAVAILABLE,
    http::HTTP_STATUS_504_GATEWAY_TIMEOUT,
    http::HTTP_STATUS_507_INSUFFICIENT_STORAGE,
    http::HTTP_STATUS_524_CLOUDFLARE_TIMEOUT,
];

// ...

    pub fn send(mut self) -> ApiResult<ApiResponse> {
        // -- snip --
        loop {
            let mut out = vec![];
            debug!("retry number {retry_number}, max retries: {max_retries}",);

            let mut rv = self.send_into(&mut out)?;
            if retry_number >= max_retries || !RETRY_STATUS_CODES.contains(&rv.status) {
                rv.body = Some(out);
                return Ok(rv);
            }

            // -- snip --
        }
    }

Implementing retry to DNS resolution failure should alleviate this issue.

Solution Brainstorm

No response

Metadata

Metadata

Labels

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions