Skip to content

exactly-once-counter: drain and close HTTP body, back off on retryable failures#673

Open
SAY-5 wants to merge 1 commit intoThreeDotsLabs:masterfrom
SAY-5:fix/exactly-once-counter-sendCountRequest-leak-664
Open

exactly-once-counter: drain and close HTTP body, back off on retryable failures#673
SAY-5 wants to merge 1 commit intoThreeDotsLabs:masterfrom
SAY-5:fix/exactly-once-counter-sendCountRequest-leak-664

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented Apr 20, 2026

Fixes #664.

sendCountRequest hits http.Post in a tight loop and never closes the response body, pinning the underlying TCP connection to the example counter until the garbage collector eventually runs. On error or non-204 responses the loop retries immediately, so the unread bodies pile up faster than GC reclaims them and the example run stalls on FD / connection pressure as soon as the server momentarily returns 4xx/5xx.

This drains and closes the body on every iteration, and sleeps 100ms before retrying both the transport-error path and the non-204 path so we do not hammer the counter handler in a spin loop when the backend is briefly unhealthy. Behaviour on the happy path (204) is unchanged.

…e failures

sendCountRequest hits http.Post in a tight loop and never closes
the response body, pinning the underlying TCP connection to the
example counter until the garbage collector eventually runs. On
error or non-204 responses the loop retries immediately, so the
unread bodies pile up faster than GC reclaims them and the example
run stalls on FD / connection pressure as soon as the server
momentarily returns 4xx/5xx (ThreeDotsLabs#664).

Drain and close the body on every iteration, and sleep 100ms before
retrying both the transport-error path and the non-204 path so we
do not hammer the counter handler in a spin loop when the backend
is briefly unhealthy. Behaviour on the happy path (204) is
unchanged.

Fixes ThreeDotsLabs#664
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.

run.go: HTTP response body leak and potential goroutine deadlock

1 participant