Fix bg fill teardown crash in update_size_and_time_stats#13114
Open
bneradt wants to merge 1 commit intoapache:masterfrom
Open
Fix bg fill teardown crash in update_size_and_time_stats#13114bneradt wants to merge 1 commit intoapache:masterfrom
bneradt wants to merge 1 commit intoapache:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a production crash in the HTTP transaction teardown path by ensuring background-fill accounting is left in a terminal state (and no longer triggers an ink_assert(0)) when the state machine is destroyed mid-fill.
Changes:
- Treat
BackgroundFill_t::STARTEDas anABORTED-equivalent inHttpTransact::update_size_and_time_stats()to avoid asserting and to record aborted bytes instead. - Normalize
HttpSM::background_fillfromSTARTEDtoABORTEDduringHttpSM::update_stats()teardown, and decrementproxy.process.http.background_fill_current_countthere to prevent gauge leakage on early teardown.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/proxy/http/HttpTransact.cc |
Makes stats update resilient to STARTED by folding it into the aborted accounting path instead of asserting. |
src/proxy/http/HttpSM.cc |
Normalizes leftover STARTED background-fill state during teardown and decrements the active-fill gauge to keep metrics balanced. |
Production crash logs show ink_assert(0) firing in HttpTransact::update_size_and_time_stats from HttpSM::update_stats via HttpSM::kill_this, triggered by an Http2Stream event re-entering the state machine while background_fill was still in the STARTED state. The background_fill state is normally driven to a terminal value (COMPLETED or ABORTED) by tunnel_handler_server, but when the SM is torn down before that handler runs the state stays STARTED and the unreachable default branch in update_size_and_time_stats asserts. The same path also leaks proxy.process.http.background_fill_current_count because tunnel_handler_server is the only site that decrements the gauge after tunnel_handler_ua incremented it. This normalizes STARTED to ABORTED inside HttpSM::kill_this, before the enable_http_stats gate that guards update_stats, and decrements the gauge there. Doing the normalization in kill_this rather than in update_stats keeps the gauge accounting balanced regardless of whether http stats are enabled, and ensures the downstream stats helper sees a terminal state. As a defensive backstop this also folds the STARTED case into the ABORTED branch of update_size_and_time_stats so a future caller that reaches this point mid-fill records the bytes against background_fill_bytes_aborted instead of crashing the server.
e700ff2 to
82a1557
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes a crash seen on docs.
Production crash logs show ink_assert(0) firing in
HttpTransact::update_size_and_time_stats from HttpSM::update_stats via
HttpSM::kill_this, triggered by an Http2Stream event re-entering the
state machine while background_fill was still in the STARTED state.
The background_fill state is normally driven to a terminal value
(COMPLETED or ABORTED) by tunnel_handler_server, but when the SM is
torn down before that handler runs the state stays STARTED and the
unreachable default branch in update_size_and_time_stats asserts. The
same path also leaks proxy.process.http.background_fill_current_count
because tunnel_handler_server is the only site that decrements the
gauge after tunnel_handler_ua incremented it.
This normalizes STARTED to ABORTED inside HttpSM::kill_this, before
the enable_http_stats gate that guards update_stats, and decrements
the gauge there. Doing the normalization in kill_this rather than in
update_stats keeps the gauge accounting balanced regardless of whether
http stats are enabled, and ensures the downstream stats helper sees a
terminal state. As a defensive backstop this also folds the STARTED
case into the ABORTED branch of update_size_and_time_stats so a future
caller that reaches this point mid-fill records the bytes against
background_fill_bytes_aborted instead of crashing the server.