wrong $bytes_sent on nginx-1.8.0 if aio threads is enabled

Valentin V. Bartenev vbart at nginx.com
Fri May 15 20:37:29 UTC 2015


On Friday 15 May 2015 17:45:44 George . wrote:
> Hi,
> 
> I found following bug in  nginx-1.8.0:
> 
> if   aio is configured with threads support - sometime (one in  thousands
> requests)  $bytes_sent contains only length of the header. I'm attaching my
> nginx.conf, build params and simple python script I'm using the reproduce
> this issue.
> 
> Here is the output of test script when the problem appears:
> .
> .
> .
> received: 101700000 from access_log : 101700000 on 26 iteration
> 127.0.0.1 - - [15/May/2015 17:27:45] "GET /test HTTP/1.0" 200 -
> 127.0.0.1 - - [15/May/2015 17:27:47] "GET /test HTTP/1.0" 200 -
> received: 101700000 from access_log : 101700000 on 27 iteration
> 127.0.0.1 - - [15/May/2015 17:27:58] "GET /test HTTP/1.0" 200 -
> 127.0.0.1 - - [15/May/2015 17:28:00] "GET /test HTTP/1.0" 200 -
> received: 101700000 from access_log : 101690000 on 28 iteration
> test failed!!
> 
> also in access_log file"
> 
> .
> .
> .
> 10170 GET /test HTTP/1.1
> 10170 GET /test HTTP/1.1
> 10170 GET /test HTTP/1.1
> 170 GET /test HTTP/1.1
> 10170 GET /test HTTP/1.1
> 10170 GET /test HTTP/1.1
> .
> .
> 

Thank you for the report.

It caused by a race condition between sendfile() task completion
and connection close notifications.  If the latter comes first,
nginx logs that client prematurely closed connection.

Unfortunately, it's not easy to fix.  I'll look at it later.

  wbr, Valentin V. Bartenev



More information about the nginx-devel mailing list