Re: Avoid duplicate peers for no-direct and maybe-direct forwarding

From: Alex Rousskov <rousskov_at_measurement-factory.com>
Date: Wed, 09 May 2012 10:14:15 -0600

On 04/28/2012 10:50 PM, Alex Rousskov wrote:
> Hello,
>
> While trying to configure Squid to resend the request to the second
> cache_peer if the first one fails, I noticed that the first peer is
> tried twice:
>
> # this peer will be tried twice in a row:
> cache_peer 172.16.101.151 parent 80 0 originserver no-query
> # then this peer will be tried
> cache_peer 172.16.103.151 parent 80 0 originserver no-query
> # this is required to allow retries
> retry_on_error on
>
> I believe the first peer is accessed twice because it is added twice to
> the list of possible peers. Here is the peerSelectFoo() code that adds
> the same peer twice because peerGetAllParents() is called after
> peerGetSomeParent():
>
>> case DIRECT_NO:
>> peerGetSomeParent(ps);
>> peerGetAllParents(ps);
>> break;
>>
>> default:
> ...
>> if (request->flags.hierarchical || !Config.onoff.nonhierarchical_direct) {
>> peerGetSomeParent(ps);
>> peerGetAllParents(ps);
>> }
>
>
> I hit the maybe-direct case in my tests, but the no-direct case seems to
> have the same flaw. The peer failure I am simulating is a 403 Forbidden
> response, but it probably does not matter.
>
> Assuming it is wrong to add (and then use) the same parent twice for the
> same request (because it screws up retries and such), we have a few options:
>
> 1. Change peerGetAllParents() so that only new parents are added. This
> will fix my use case, but there could be other cases where we add
> duplicate peers -- I see other conditional peerGet*() calls before and
> after the ones quoted above. It may be difficult to avoid duplicates
> under all conditions.
>
> 2. Change lower-level peerAddFwdServer() so that only new servers are
> added even if the higher level code tries to add duplicates; the "same
> server" comparison can be done using server address (including port) and
> disregarding the hierarchy code. This will fix my use case, but I am not
> 100% sure whether skipping some servers would break some configurations
> because those servers have "more important" hierarchy code, even though
> they are added later/last.
>
> Should I do #2? Is there a better option?

FWIW, the "duplicate peer addresses" problem does not exist in Squid 2.7
which indirectly supports my assumption that this is a bug rather than a
feature.

Cheers,

Alex.
Received on Wed May 09 2012 - 16:14:24 MDT

This archive was generated by hypermail 2.2.0 : Thu May 10 2012 - 12:00:05 MDT