Mailing List Archive

#1772: first_byte_timeout is ignored when re-using a backend connection (HTTP Keep Alive)
#1772: first_byte_timeout is ignored when re-using a backend connection (HTTP Keep
Alive)
-----------------------+--------------------
Reporter: tnt | Type: defect
Status: new | Priority: normal
Milestone: | Component: build
Version: 4.1.0-TP1 | Severity: normal
Keywords: |
-----------------------+--------------------
On a given backend TCP connection, only the first request will have
first_byte_timeout properly applied, all subsequent requests will wait
indefinitely long (AFAICT).

What I traced so far is that inside vbe_dir_gethdrs, it blocks on VBT_Wait
on the second requests because state is STOLEN. And whatever event loop
should be processing the STOLEN -> USED transition will not be triggered
until a byte is received on the fd, which defeats the first_byte_timeout.

(tested on 4.1.0-tp1 only)

--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1772>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator

_______________________________________________
varnish-bugs mailing list
varnish-bugs@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-bugs
Re: #1772: first_byte_timeout is ignored when re-using a backend connection (HTTP Keep Alive) [ In reply to ]
#1772: first_byte_timeout is ignored when re-using a backend connection (HTTP Keep
Alive)
--------------------+------------------------
Reporter: tnt | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: build | Version: 4.1.0-TP1
Severity: normal | Resolution:
Keywords: |
--------------------+------------------------

Comment (by Dridi):

My comments from the IRC:

> my understanding is the following
> we should pass a timeout to VBT_Wait, to be used with the underlying
cond wait
> the cond wait being done in a loop, that means more system calls to re-
compute the deadline on each iteration
> (which means it would probably not be done this way)
> after a vbt wait, we could compute the remaining timeout and pass it to
V1F_FetchRespHdr
> I don't remember how vcl_pipe deals with timeouts, so that has to be
considered too

Then I wrote a test case:
{{{
varnishtest "honour first-byte timeout on a stolen connection"

server s1 {
rxreq
expect req.url == "/first"
txresp -hdr "Connection: keep-alive"

rxreq
expect req.url == "/stolen"
txresp

delay 1.5

rxreq
expect req.url == "/second"
txresp
} -start

varnish v1 -vcl {
backend s1 {
.host = "${s1_addr}";
.port = "${s1_port}";
.max_connections = 1;
.first_byte_timeout = 1s;
}
} -start

client c1 {
txreq -url "/first"
rxresp
expect resp.status == 200

sema r1 sync 2
sema r2 sync 2

txreq -url "/second"
rxresp
expect resp.status == 503
} -start

client c2 {
sema r1 sync 2

txreq -url "/stolen"
rxresp
expect resp.status == 200

sema r2 sync 2
} -start

client c1 -wait
}}}

And the thing that is puzzling me is that I couldn't make the test pass by
moving the '''delay''' right before the last '''txresp''' in s1.

--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1772#comment:1>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator

_______________________________________________
varnish-bugs mailing list
varnish-bugs@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-bugs
Re: #1772: first_byte_timeout is ignored when re-using a backend connection (HTTP Keep Alive) [ In reply to ]
#1772: first_byte_timeout is ignored when re-using a backend connection (HTTP Keep
Alive)
--------------------+------------------------
Reporter: tnt | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: build | Version: 4.1.0-TP1
Severity: normal | Resolution:
Keywords: |
--------------------+------------------------

Comment (by tnt):

New simplified test case :

{{{
varnishtest "honour first-byte timeout on a stolen connection"

server s1 {
rxreq
expect req.url == "/first"
txresp -hdr "Connection: keep-alive"

rxreq
expect req.url == "/second"
delay 2
txresp
} -start

varnish v1 -vcl {
backend s1 {
.host = "${s1_addr}";
.port = "${s1_port}";
.first_byte_timeout = 1s;
}
} -start

client c1 {
txreq -url "/first"
rxresp
expect resp.status == 200

txreq -url "/second"
rxresp
expect resp.status == 503
} -run
}}}

--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1772#comment:2>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator

_______________________________________________
varnish-bugs mailing list
varnish-bugs@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-bugs
Re: #1772: first_byte_timeout is ignored when re-using a backend connection (HTTP Keep Alive) [ In reply to ]
#1772: first_byte_timeout is ignored when re-using a backend connection (HTTP Keep
Alive)
----------------------+------------------------
Reporter: tnt | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: varnishd | Version: 4.1.0-TP1
Severity: normal | Resolution:
Keywords: |
----------------------+------------------------
Changes (by fgsch):

* component: build => varnishd


--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1772#comment:3>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator

_______________________________________________
varnish-bugs mailing list
varnish-bugs@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-bugs
Re: #1772: first_byte_timeout is ignored when re-using a backend connection (HTTP Keep Alive) [ In reply to ]
#1772: first_byte_timeout is ignored when re-using a backend connection (HTTP Keep
Alive)
----------------------+------------------------
Reporter: tnt | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: varnishd | Version: 4.1.0-TP1
Severity: normal | Resolution:
Keywords: |
----------------------+------------------------

Comment (by Dridi):

I didn't understand the problem initially, so your test case explains why
I was puzzled in the first place.

There's still something wrong however with VBC_Wait for it should be
accounted to a timeout, and I still think the first_byte_timeout is the
one.

--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1772#comment:4>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator

_______________________________________________
varnish-bugs mailing list
varnish-bugs@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-bugs
Re: #1772: first_byte_timeout is ignored when re-using a backend connection (HTTP Keep Alive) [ In reply to ]
#1772: first_byte_timeout is ignored when re-using a backend connection (HTTP Keep
Alive)
----------------------+------------------------
Reporter: tnt | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: varnishd | Version: 4.1.0-TP1
Severity: normal | Resolution:
Keywords: |
----------------------+------------------------

Comment (by tnt):

The way I see it there is two ways to see this :

- Either make VBC_Wait account for the timeout (and yes, first_byte would
be the one here) then report any unused timeout to the rest of the process
like you described.

- Ensure VBC_Wait never blocks for long. After all it's mostly a
lock/ownership change and the fact this only happens when bytes are
exchanged on the fd is a bit weird to me.

--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1772#comment:5>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator

_______________________________________________
varnish-bugs mailing list
varnish-bugs@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-bugs
Re: #1772: first_byte_timeout is ignored when re-using a backend connection (HTTP Keep Alive) [ In reply to ]
#1772: first_byte_timeout is ignored when re-using a backend connection (HTTP Keep
Alive)
----------------------+--------------------
Reporter: tnt | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: varnishd | Version: trunk
Severity: normal | Resolution:
Keywords: |
----------------------+--------------------
Changes (by fgsch):

* version: 4.1.0-TP1 => trunk


--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1772#comment:6>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator

_______________________________________________
varnish-bugs mailing list
varnish-bugs@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-bugs
Re: #1772: first_byte_timeout is ignored when re-using a backend connection (HTTP Keep Alive) [ In reply to ]
#1772: first_byte_timeout is ignored when re-using a backend connection (HTTP Keep
Alive)
----------------------+--------------------
Reporter: tnt | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: varnishd | Version: trunk
Severity: normal | Resolution:
Keywords: |
----------------------+--------------------

Comment (by phk):

See also #1806

--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1772#comment:7>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator

_______________________________________________
varnish-bugs mailing list
varnish-bugs@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-bugs