Skip to content

Fix RangeTransform on stale-revalidate#13158

Open
masaori335 wants to merge 2 commits into
apache:masterfrom
masaori335:asf-master-range-transform
Open

Fix RangeTransform on stale-revalidate#13158
masaori335 wants to merge 2 commits into
apache:masterfrom
masaori335:asf-master-range-transform

Conversation

@masaori335
Copy link
Copy Markdown
Contributor

@masaori335 masaori335 commented May 13, 2026

Fix RangeTransform on the stale-revalidate path when the fresh origin body is differs from the stale object size.

For example, in the added AuTest, original object size was 64097 and updated size was 40000, the second (revalidated) response from ATS was below without this patch:

HTTP/1.1 206 Partial Content
Content-Range: bytes 0-64096/40000
Content-Length: 64097

while the actual response body size was 40000 bytes.

To fix the issue,

  1. Update m_write_vio.ndone in RangeTransform::transform_to_range().
  2. Re-parse the Range against the fresh Content-Length from origin server.

@masaori335 masaori335 added this to the 11.0.0 milestone May 13, 2026
@masaori335 masaori335 self-assigned this May 13, 2026
@masaori335 masaori335 added the Bug label May 13, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes incorrect Range response headers/body accounting when serving Range requests through the stale-revalidate (cache REPLACE) path and the origin’s fresh Content-Length differs from the stale cached object size.

Changes:

  • Recompute range parsing/output length against the fresh origin Content-Length during stale revalidate (REPLACE + 200 OK) before installing the Range transform.
  • Fix RangeTransform input progress tracking by updating m_write_vio.ndone as bytes are skipped/sent.
  • Add an AuTest replay covering “shrunk” and “grown” origin bodies across stale revalidations.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
tests/gold_tests/headers/replays/range_transform.replay.yaml New replay covering stale-revalidate RangeTransform correctness when origin size shrinks/grows.
tests/gold_tests/headers/range_transform.test.py New test wrapper to run the replay.
src/proxy/Transform.cc RangeTransform now increments m_write_vio.ndone when consuming input.
src/proxy/http/HttpSM.cc Re-parse Range headers against fresh origin Content-Length on stale-revalidate REPLACE path.

Comment thread src/proxy/http/HttpSM.cc
Comment on lines +5116 to +5118
// Re-parse yielded e.g. RANGE_NOT_SATISFIABLE (entire range
// past fresh body); let downstream handling take over without
// installing the transform.
Comment thread src/proxy/http/HttpSM.cc
Comment on lines +5096 to +5100
// differs, re-parse the Range against the fresh value so the outgoing Content-Length/Content-Range match the body
// actually being sent. Without this, Content-Length/Content-Range advertise the stale cached size.
const int64_t fresh_cl = t_state.hdr_info.server_response.get_content_length();
const int64_t cached_cl = t_state.cache_info.object_read ? t_state.cache_info.object_read->object_size_get() : -1;
if (fresh_cl > 0 && fresh_cl != cached_cl) {
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants