Skip to content

Commit 3567505

Browse files
rousskovsquid-anubis
authored andcommitted
Remove doomed attempts to reforward pinned requests (#2449)
AsyncJob.cc(100) mustStop: Ftp::Relay will stop, reason: exception ... FATAL: check failed: !request->pinnedConnection() exception location: FwdState.cc(1119) connectStart Since February 2019 commit 3dde9e5, retries of "pinned" requests[^1] using a new Squid-to-server connections are meant for FTP and connection-based authentication traffic only. Back then, we agreed that such re-pinning is wrong[^2], and different mechanisms should be used to handle forwarding errors in those cases, but we preserved the corresponding functionality in fear of breaking "working" cases[^3]. On that preserved code path, `request->pinnedConnection()` is true at pinnedCanRetry() check time. Since September 2019 commit daf8070, connectStart() throws if `request->pinnedConnection()` is true, effectively breaking retries for nearly all preserved cases mentioned above! The only pinned retries that could hypothetically continue working after that commit are those where ConnStateData job had been destroyed between pinnedCanRetry() and connectStart(), and those rare cases are not interesting since ConnStateData destruction ought to abort request forwarding anyway. Both 2019 commits are present in v5.0.1 and beyond. We are not aware of any associated problems. Thus, our fears were excessive, and we can remove code that preserves problematic functionality. If we discover a need to retry pinned FTP or connection-authenticated requests via a new connection, we will add mechanisms to support that functionality. Removing this code also helps avoid FATAL errors observed during recent FTP work. CONNECT tunnels --------------- Existing tunnel.cc code ignores `request->flags.pinned` when deciding whether to retry a failed tunneling attempt. This change does not affect the corresponding "check pinned connections" TODO in that tunneling code. FWIW, that TODO is limited to tunnelStart(); switchToTunnel() cases already do not retry due to a "committed to server" retry ban on their code path. It is likely that pinned retries should be disabled in tunneled cases as well, but that adjustment deserves a dedicated analysis/change. [^1]: Here, a "pinned" request is, roughly speaking, a request sent by Squid over a Squid-to-server connection that was kept/provided by a client-to-Squid connection manager (ConnStateData). See usePinned(). [^2]: "automatically re-opening a PINNED connection from the middleware is invalid in todays networks" at #351 (comment) [^3]: "keep re-pinning as is" at #351 (comment)
1 parent a30c278 commit 3567505

3 files changed

Lines changed: 3 additions & 29 deletions

File tree

src/FwdState.cc

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ FwdState::checkRetry()
708708
if (exhaustedTries())
709709
return false;
710710

711-
if (request->flags.pinned && !pinnedCanRetry())
711+
if (request->flags.pinned)
712712
return false;
713713

714714
if (!EnoughTimeToReForward(start_t))
@@ -1323,7 +1323,7 @@ FwdState::reforward()
13231323

13241324
debugs(17, 3, e->url() << "?" );
13251325

1326-
if (request->flags.pinned && !pinnedCanRetry()) {
1326+
if (request->flags.pinned) {
13271327
debugs(17, 3, "pinned connection; cannot retry");
13281328
return 0;
13291329
}
@@ -1418,28 +1418,6 @@ FwdState::exhaustedTries() const
14181418
return n_tries >= Config.forward_max_tries;
14191419
}
14201420

1421-
bool
1422-
FwdState::pinnedCanRetry() const
1423-
{
1424-
assert(request->flags.pinned);
1425-
1426-
// pconn race on pinned connection: Currently we do not have any mechanism
1427-
// to retry current pinned connection path.
1428-
if (pconnRace == raceHappened)
1429-
return false;
1430-
1431-
// If a bumped connection was pinned, then the TLS client was given our peer
1432-
// details. Do not retry because we do not ensure that those details stay
1433-
// constant. Step1-bumped connections do not get our TLS peer details, are
1434-
// never pinned, and, hence, never reach this method.
1435-
if (request->flags.sslBumped)
1436-
return false;
1437-
1438-
// The other pinned cases are FTP proxying and connection-based HTTP
1439-
// authentication. TODO: Do these cases have restrictions?
1440-
return true;
1441-
}
1442-
14431421
time_t
14441422
FwdState::connectingTimeout(const Comm::ConnectionPointer &conn) const
14451423
{

src/FwdState.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,6 @@ class FwdState: public RefCountable, public PeerSelectionInitiator
161161

162162
void usePinned();
163163

164-
/// whether a pinned to-peer connection can be replaced with another one
165-
/// (in order to retry or reforward a failed request)
166-
bool pinnedCanRetry() const;
167-
168164
template <typename StepStart>
169165
void advanceDestination(const char *stepDescription, const Comm::ConnectionPointer &conn, const StepStart &startStep);
170166

src/tunnel.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ TunnelStateData::checkRetry()
517517
if (request->hier.peer_reply_status != Http::scNone && !Http::IsReforwardableStatus(request->hier.peer_reply_status))
518518
return "received HTTP status code is not reforwardable";
519519

520-
// TODO: check pinned connections; see FwdState::pinnedCanRetry()
520+
// TODO: check pinned connections; see request->flags.pinned in FwdState::checkRetry()
521521
return nullptr;
522522
}
523523

0 commit comments

Comments
 (0)