Skip to content

fix(replications): share HTTP transport across remote writes - #27745

Open
devanbenz wants to merge 1 commit into
main-2.xfrom
db/23996/open-repl-clients
Open

devanbenz wants to merge 1 commit into
main-2.xfrom
db/23996/open-repl-clients

Conversation

@devanbenz

@devanbenz devanbenz commented Nov 9, 2026 •

Copy link
Copy Markdown

Closes #23996

Description

Every remote write built a new api client, and influx-cli's NewAPIConfig clones http.DefaultTransport per call. Go pools connections per Transport, so none was ever reused: each write performed a fresh DNS lookup, TCP and TLS handshake, and left an idle connection open for ~90s. While draining a backlog after a remote outage this exhausts the file descriptor limit (too many open files), and in steady state more than half of each stream's bytes on the wire were connection setup (see the analysis in #23996).

PostWrite now swaps in one of two package-level transports (TLS verification on/off, the only per-stream setting a Transport carries). Connections are pooled across all replication streams and the validator path. The api client itself is still built per call; it is cheap and holds no connections.

Testing

  • New TestWrite_ReusesConnections counts server-side new TCP connections over 10 writes. Pre-fix: 10. Post-fix: 1. Also verifies a remote URL change opens exactly one connection to the new remote.
  • go test -race ./replications/... passes.

Severity

Recommend upgrade for users of replication streams, especially over metered or high-latency links.

Note for reviewers

Semantic type: Fix. Supersedes #23997 (which closed idle connections after each write instead of reusing them).

@devanbenz devanbenz changed the title fix(replications): reuse HTTP client across remote writes fix(replications): share HTTP transport across remote writes Nov 9, 2026
@devanbenz
devanbenz force-pushed the db/23996/open-repl-clients branch from 9c59c5c to 5baf57a Compare November 9, 2026 20:57
Every remote write built a new api client, and influx-cli's NewAPIConfig
clones http.DefaultTransport per call. Connections are pooled per
Transport, so none was ever reused: each write did a fresh DNS lookup,
TCP and TLS handshake, and left an idle connection open for ~90s. While
draining a backlog this exhausts the file descriptor limit.

PostWrite now uses one of two package-level transports (TLS verification
on/off), so connections are pooled across all streams and the validator.

Closes #23996
@devanbenz
devanbenz force-pushed the db/23996/open-repl-clients branch from 5baf57a to 0a69916 Compare November 9, 2026 20:59
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