Skip to content

GreptimeDB download: 5-min Client.Timeout causes infinite retry loop on slow connections (150MB > 5min) #57

Description

@wangdengwu

Summary

On a fresh install, tma1-server can get stuck in an infinite GreptimeDB download → 5‑minute‑timeout → retry loop on slower connections, never reaching a healthy state. The dashboard never comes up and the only signal is a repeating failed to install greptimedb ... context deadline exceeded line in the log.

Environment

  • TMA1 v0.2.0-alpha7, macOS (darwin/arm64)
  • GreptimeDB v1.1.1, asset greptime-darwin-arm64-v1.1.1.tar.gz is ~150 MB (content-length: 150472626)
  • Connection throughput during repro: ~27 MB/min

Root cause

server/internal/install/install.go:45

downloadClient = &http.Client{Timeout: 5 * time.Minute}

This Timeout is the total deadline for the whole request, including streaming the response body in downloadAndExtract (install.go:~348):

resp, err := downloadClient.Get(url)
...
_, err = io.Copy(dst, resp.Body)   // <- the 5-min clock is still ticking here

A 150 MB tarball at ~27 MB/min needs ~5.5 min — just over the cap — so io.Copy dies mid‑stream with context deadline exceeded, the partial download is discarded, and EnsureGreptimeDB retries from scratch with no Range/resume and no backoff (observed retry ~2 s after the failure). On any connection where the download is slower than 150 MB / 5 min, this loops forever.

Observed log

18:21:24 INFO  downloading greptimedb version=v1.1.1
18:26:24 ERROR failed to install greptimedb err="install: download .../greptime-darwin-arm64-v1.1.1.tar.gz: context deadline exceeded (Client.Timeout or context cancellation while reading body)"
18:26:26 INFO  downloading greptimedb version=v1.1.1     # immediate retry, restarts at 0 bytes

Steps to reproduce

  1. Throttle the network to < ~30 MB/min (or repro on any moderately slow link).
  2. curl -fsSL https://tma1.ai/install.sh | TMA1_VERSION=v0.2.0-alpha7 bash
  3. Watch ~/Library/Logs/tma1-server.log — the download fails at the 5‑min mark and retries indefinitely; curl http://localhost:14318/health never returns ok.

Impact

First‑run experience hard‑fails for anyone on a slower connection, with no actionable message (just a repeating timeout). Likely to grow as the GreptimeDB binary gets larger.

Workaround

Download the tarball out of band, drop greptime into ~/.tma1/bin/greptime (chmod +x), write v1.1.1 to ~/.tma1/bin/.version, and restart the service — EnsureGreptimeDB then sees the binary and skips the download.

Suggested fixes (any subset)

  1. Don't cap body read with a wall‑clock total timeout. Drop Client.Timeout for the download client and instead enforce a stall timeout (idle/read deadline) so a slow‑but‑progressing transfer isn't killed. e.g. http.Transport{ResponseHeaderTimeout: ...} + a stall‑detecting reader, or a context you reset on progress.
  2. Resumable download via HTTP Range so a retry continues from the partial file instead of restarting at 0.
  3. Backoff + attempt cap between retries, with a clear terminal error after N attempts instead of an infinite silent loop.
  4. Progress / clearer messaging (bytes downloaded, total) so a stuck/slow download is diagnosable from the log.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions