Fix xdebug transform calling WRITE_READY when no data consumed#12760
Merged
bryancall merged 2 commits intoapache:masterfrom Jan 20, 2026
Merged
Fix xdebug transform calling WRITE_READY when no data consumed#12760bryancall merged 2 commits intoapache:masterfrom
bryancall merged 2 commits intoapache:masterfrom
Conversation
The xdebug probe-full-json transform was calling TSContCall(WRITE_READY) even when no data was available to consume (towrite == 0). This caused unnecessary callbacks to the transform, and under certain conditions could lead to a tight loop that would starve other transactions on the same ET_NET thread. The fix adds a check to only call TSVIOReenable and TSContCall when towrite > 0, meaning we actually consumed data. If no data was available, we simply return and wait for the upstream to call us again when more data arrives. Added a new autest (x_probe_full_json_slow_origin) that uses a slow origin server with chunked encoding to verify the transform handles delayed body data correctly.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in the xdebug plugin's probe-full-json transform where it would create a tight loop when the origin server was slow to send body data. The transform was incorrectly calling TSContCall(WRITE_READY) even when no data was consumed (towrite == 0), causing high CPU usage and potential starvation of other transactions.
Key Changes:
- Added a conditional check to only reenable and notify upstream when data has been consumed (
towrite > 0) - Added comprehensive test coverage with a slow origin server simulation to verify the fix
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| plugins/xdebug/xdebug_transforms.cc | Added conditional check to prevent unnecessary callbacks when no data is consumed |
| tests/gold_tests/pluginTest/xdebug/x_probe_full_json_slow_origin/x_probe_full_json_slow_origin.test.py | New test to verify the transform handles delayed body data correctly |
| tests/gold_tests/pluginTest/xdebug/x_probe_full_json_slow_origin/slow-body-server.sh | Custom slow server implementation to simulate delayed chunked response |
| tests/gold_tests/pluginTest/xdebug/x_probe_full_json_slow_origin/verify_no_loop.sh | Log analysis script to detect infinite loop behavior |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tests/gold_tests/pluginTest/xdebug/x_probe_full_json_slow_origin/verify_no_loop.sh
Show resolved
Hide resolved
jasmine-nahrain
previously approved these changes
Dec 17, 2025
bneradt
requested changes
Dec 19, 2025
- Update comment to explain 'why' (prevents tight loop that starves other transactions) instead of 'what' the code does - Change verify_no_loop.sh to fail the test when consumed_count != 2 instead of just warning
jasmine-nahrain
approved these changes
Jan 13, 2026
bneradt
approved these changes
Jan 20, 2026
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.
The xdebug probe-full-json transform was calling
TSContCall(WRITE_READY)even when no data was available to consume (towrite == 0). This caused unnecessary callbacks to the transform, and under certain conditions could lead to a tight loop that would starve other transactions on the same ET_NET thread.The Bug
When using
X-Debug: probe-full-json=nobody(or other probe-full-json variants), if the origin server was slow to send body data, the transform would:WRITE_READYeventtowrite == 0)TSVIOReenableandTSContCall(WRITE_READY)back to upstreamThis creates a tight loop that can cause:
The Fix
Add a check to only call
TSVIOReenableandTSContCallwhentowrite > 0, meaning we actually consumed data. If no data was available, we simply return and wait for the upstream to call us again when more data arrives.Testing
Added a new autest (
x_probe_full_json_slow_origin) that uses a slow origin server with chunked encoding to verify the transform handles delayed body data correctly.