]> git.ipfire.org Git - thirdparty/squid.git/commit
Bug 4223: fixed retries of failed re-forwardable transactions (#211)
authorEduard Bagdasaryan <eduard.bagdasaryan@measurement-factory.com>
Mon, 11 Jun 2018 10:44:37 +0000 (10:44 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Mon, 11 Jun 2018 10:46:34 +0000 (10:46 +0000)
commit70eb3fde5e3bbfbab7ce310393b32ce785ab2881
tree4c8d04ab5fde808167626a1dc28118f7c63831b8
parentb5391492eb4be8d2603e8ff6c01fc43a16c25281
Bug 4223: fixed retries of failed re-forwardable transactions (#211)

This change fixes Store to delay writing (and, therefore, sharing) of
re-triable errors (e.g., 504 Gateway Timeout responses) to clients:
once we start sharing the response with a client, we cannot re-try the
transaction. Since ENTRY_FWD_HDR_WAIT flag purpose is to delay response
sharing with Store clients, this patch fixes and clarifies its usage:

1. Removes unconditional clearing from startWriting().
2. Adds a conditional clearing to StoreEntry::write().
3. Sets it only for may-be-rejected responses.

(2) adds ENTRY_FWD_HDR_WAIT clearing to detect responses that filled the
entire read buffer and must be shared now with the clients because
they can no longer be retried with the current re-forwarding mechanisms
(which rely on completing the bad response transaction first) and will
get stuck. Such large re-triable error responses (>16KB with default
read_ahead_gap) should be uncommon. They were getting stuck prior to
master r12501.1.48. That revision started clearing ENTRY_FWD_HDR_WAIT in
StoreEntry startWriting() unconditionally, allowing all errors to be
sent to Store clients without a delay, and effectively disabling
retries.

Mgr::Forwarder was always setting ENTRY_FWD_HDR_WAIT, probably mimicking
similarly aggressive FwdState behavior that we are now removing. Since
the forwarder never rewrites the entry content, it should not need to
set that flag. The forwarder and associated Server classes must not
communicate with the mgr client during the client-Squid connection
descriptor handoff to Coordinator, but ENTRY_FWD_HDR_WAIT is not the
right mechanism to block such Squid-client communication. The flag
does not work well for this purpose because those Server classes may
(and do?) substitute the "blocked" StoreEntry with another one to
write an error message to the client.

Also moved ENTRY_FWD_HDR_WAIT clearance from many StoreEntry::complete()
callers to that method itself. StoreEntry::complete() is meant to be the
last call when forming the entry. Any post-complete entry modifications
such as retries are prohibited.
12 files changed:
src/FwdState.cc
src/MemStore.cc
src/client_side_request.cc
src/clients/FtpGateway.cc
src/clients/FtpRelay.cc
src/enums.h
src/gopher.cc
src/http.cc
src/ipc/Forwarder.cc
src/mgr/Forwarder.cc
src/store.cc
src/store_client.cc