Skip to content

Commit c47d134

Browse files
authored
x-pack/filebeat/input/http_endpoint: decouple shared server lifetime from individual inputs (#49415)
The http_endpoint input lets multiple inputs share a single HTTP listener on the same host:port. The server's context was derived from the creator input's cancellation context, causing two bugs: 1. Joiner deadlock: when only a joiner's context was cancelled, its Run goroutine blocked forever on the server context because it never monitored its own cancellation signal. 2. Creator kills everyone: when the creator was cancelled, the shared server was closed, taking down all other inputs on the same port even though they were still wanted. Replace http.ServeMux with a mutable mux that supports dynamic handler removal. Give the server an independent context tied to its own lifetime rather than any single input's. Both creator and joiner now select on their own cancellation and the server context, deregistering cleanly when stopped. The server shuts down only when the last input deregisters or the listener returns an error. Each handler receives a per-input context derived from that input's cancellation, so in-flight ACK waits abort before the pipeline client is closed during deregistration.
1 parent 641c324 commit c47d134

3 files changed

Lines changed: 796 additions & 87 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
kind: bug-fix
2+
summary: Fix http_endpoint input shared server lifecycle causing joiner deadlock and creator killing unrelated inputs.
3+
description: |
4+
Decouple the shared HTTP server lifetime from any single input. Previously,
5+
the server context was derived from the creator input, so cancelling a joiner
6+
blocked forever (deadlock) and cancelling the creator shut down all inputs on
7+
the same port. The server now lives until the last input deregisters.
8+
component: filebeat

0 commit comments

Comments
 (0)