Elasticsearch sink loses backpressure during retries and can OOM
A note for the community
Please vote on this issue with a reaction to help prioritize it. If you are working on it or submitting a pull request, please leave a comment.
Problem
The Elasticsearch sink can admit new logical requests while earlier requests are still waiting to retry. Fixed request.concurrency limits HTTP attempts at the individual endpoints, but does not bound all outstanding retrying requests for the sink. A disk backlog can therefore be read into prepared requests faster than the downstream can complete them, eventually causing OOM.
This is reproducible with a fixed concurrency limit, not only adaptive concurrency. It does not require continued ingestion, a real Elasticsearch cluster, or an upstream Vector/gRPC source.
Version
vector 0.60.0-dev (x86_64-unknown-linux-gnu) built from upstream master commit 25a42d7a8c3e604a5af2fd8a009a7e661099eb34, with Rust 1.96.1, jemalloc, and the required source/sink components only. Also reproduced by the regression test on the unchanged runtime from 1b0e38642daaa791834ca89259c8b441b69cc644.
Minimal reproduction
A self-contained regression test is available in the test-only commit. That commit deliberately contains no runtime fix. Check out that revision and run:
cargo test --locked --release --jobs 2 --lib --no-default-features \
--features tikv-jemallocator,sources-socket,sources-internal_metrics,sources-vector,sinks-vector,sinks-elasticsearch,sinks-prometheus \
fixed_concurrency_bounds_pending_retries_across_endpoints -- --nocapture
The test builds the actual ElasticsearchConfig sink, uses two ephemeral localhost HTTP endpoints, and gives each event its own acknowledgement notifier. Response barriers keep the outage under test control. It checks fixed concurrency 1 and 2 and retains the original pending event identities through HTTP 503, HTTP 429, a transport error, and a request timeout, then recovers without rebuilding the sink.
On the unfixed runtime it fails immediately after the first retryable response:
fixed concurrency 1 admitted a new event while the original requests were still awaiting retries
On the candidate fix the same behavioral test passes, including recovery of every event and no acknowledgements before successful responses. This reproduction needs neither a large disk buffer nor an actual OOM.
Configuration
The small test uses the equivalent of:
endpoints:
- http://127.0.0.1:18080
- http://127.0.0.1:18081
api_version: v8
compression: none
acknowledgements:
enabled: true
batch:
max_events: 1
request:
concurrency: 1
timeout_secs: 5
retry_initial_backoff_secs: 1
retry_max_duration_secs: 1
retry_jitter_mode: None
No custom endpoint-health configuration is used; the current documented defaults, including the merged health-default fix, are active.
Larger replay evidence
A separate bounded local experiment used 5,500 synthetic records with seeded high-entropy 8 KiB payloads, fanned out to 24 Elasticsearch sinks: 132,000 (index, sequence) sink-events and approximately 1.1 GB on disk. Runtime limits were 2 GiB memory, no swap, two CPUs and two Vector worker threads. Every sink used request.concurrency: 1, gzip, 10 MB batches, disk buffering with when_full: block, acknowledgements enabled, and default retries.
After persisting the backlog, ingestion was stopped. Healthy and outage cases replayed the same disk snapshot within each build's experiment.
| Build / backend | Observed result |
|---|---|
| Upstream master, HTTP 200 | All sink-events delivered; no OOM |
| Upstream master, constant HTTP 503 | OOMKilled=true, exit 137, approximately 29 seconds after start |
| Candidate, constant HTTP 503 | Survived the full 180-second observation; read-ahead plateaued; no deliveries or disk acknowledgements during the outage |
| Candidate, backend recovered | All sink-events delivered without duplicates; disk buffer empty; no Vector restart |
The candidate's same-process recovery took approximately 154 seconds under the unchanged retry and endpoint-health backoff settings. This is not a recovery-latency guarantee.
A small external two-endpoint check with request.concurrency: 2 also observed 14 distinct undelivered batches under 503 on upstream master, versus 2 on the candidate. Both recovered all 120 synthetic events.
Suspected cause
distributed_service puts Retry outside the per-endpoint concurrency limiters. The Driver relies on service readiness to apply backpressure and has no separate limit on pending call futures. Endpoint permits can therefore become available while logical calls are still sleeping between retries.
The candidate holds an additional fixed-concurrency permit around the complete Elasticsearch service call, including retry waits, across endpoints. It does not change retry eligibility, retry counts, acknowledgements, or adaptive mode.
This is not a claim that disk buffering should eliminate all RAM use: prepared batches and other pipeline components still consume memory. The specific defect is the missing bound on dispatched retrying requests.
References
The merged fix(healthcheck): use documented retry defaults is present in the tested master and does not eliminate this reproduction.