Multiple Origin Requests Due to Cache Write Lock Failure
Description: When multiple concurrent requests are made for the same expired cached resource, and the origin content hasn't been modified:
- Current behavior:
- The handle_cache_write_lock function removes the IMS (If-Modified-Since) header
- This results in multiple origin requests for the same resource
- These requests are logged with TCP_REFRESH_MISS status
Question: For this specific scenario where concurrent requests are made for an expired cached resource and the origin content hasn't been modified, can we preserve the IMS headers in handle_cache_write_lock? This would potentially reduce unnecessary origin requests.
Version: Apache Traffic Server 9.2.3
One option you can try is setting the write lock failure option to setting 5, https://docs.trafficserver.apache.org/en/9.2.x/admin-guide/files/records.config.en.html#proxy-config-http-cache-open-write-fail-action
It is still considered experimental because in previous versions of ATS we could see eventual crashes with it enabled on specific content but it may be worth trying (I have some test production machines running with this enabled for the past 3 months and have yet to see these crashes again). This enables ATS to jump backwards in the state machine so when the write lock fails it can go back to the read state and wait in line.
This wont directly address the IMS question but it would bring down the multiple origin requests as long as you have read while writer enabled.
We discussed this a bit during our bug scrub call and it looks like while it removes the IMS header it does re-insert it based on the request, so an IMS header should end up existing in the cached copy, but it would still make the upstream request in your case.
Hi @ezelkow1 Thank you for the suggestion to set proxy.config.http.cache.open_write_fail_action to 5, but I'm still experiencing the issue with multiple origin requests (TCP_REFRESH_MISS) for the same expired cached resource. Any additional guidance would be appreciated.
@gy1082 I'm facing an issue where for concurrent requests to ATS, some of them dont have the If-Not-Match header even when the when_to_revalidate = 2. This option is supposed to add INM header if origin header response contains ETags right?