Bug #9721 net_write_timeout not used on Windows
Submitted: 7 Apr 2005 15:03 Modified: 12 May 2005 3:15
Reporter: Hartmut Holzgraefe Email Updates:
Status: Closed Impact on me:
Category:MySQL Server Severity:S2 (Serious)
Version:4.1.9, probably any OS:Microsoft Windows (Windows)
Assigned to: Reggie Burnett CPU Architecture:Any

[7 Apr 2005 15:03] Hartmut Holzgraefe
On Windows we can't use alarms or signals to enforce net_(read|write)_timeout settings
as the WinSock send() call is not interruptable, so we have to rely on socket options to
request proper timeouts from WinSock.

Function net_real_write() uses vio_timeout() to set the WinSock write timeout ot
net_write_timeout seconds. But vio_timeout() does only set the SO_RCVTIMEO 
option, not SO_SNDTIMEO as needed for writes.

This leads to unkillable server threads hanging in "Writing to Net" state if a client stalls
while reading results (write buffer fills up, client doesn't read fast enough or not at all
but socket still exists). 

How to repeat:
hard to repeat at will, you need a stalling client and a windows server to reproduce this

Suggested fix:

As a quick fix i added a set_sockopt call to set SO_SNDTIMEO together with SO_RCVTIMEO in vio_socket (effectively setting both to the same values), this did solve the locking problems for the customer.

A clean solution would probably require seperate vio_readtimeout() and vio_writetimeout() funcions or an aditional parameter to vio_timeout() to
specify which value(s) to set.
[6 May 2005 13:17] Reggie Burnett
Fixed in 4.1.12 & 5.0.6
[6 May 2005 13:42] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

[12 May 2005 3:15] Paul Dubois
Noted in 4.1.12, 5.0.6 changelogs.