Need info about FreeBSD and interrupted system calls for MySQL code

Joerg Bruehe joerg at mysql.com
Fri Apr 30 21:22:27 UTC 2010


Dan,


thanks for your reply:

Dan Nelson wrote:
> In the last episode (Apr 29), Joerg Bruehe said:
>> For some long, unknown time, the MySQL code contains a variable
>> "net_retry_count" which is by default set to 10 (ten) for all platforms,
>> but to 1000000 (1 million) for FreeBSD (during configure phase).
>>
>> The source code comment about this variable reads
>>        If a read on a communication port is interrupted, retry this many
>>        times before giving up.
>>
>> [[...]]
> 
> I'm pretty sure this is a holdover from when FreeBSD only had a user
> pthreads package (libc_r).  libc calls that would normally block got
> converted into non-blocking versions and a select() loop would execute
> threads as the events they were waiting on occurred.  Incoming signals would
> cause all threads waiting on read() to return EINTR.  If you have other
> threads doing work and sending/receiving signals, this can add up to a lot
> of extra EINTR's.

Interesting information - thanks. I never heard that before, but it
explains a lot.

> 
> FreeBSD 5.0 (released in 2003) was the first version to have kernel-based
> pthread support, so the original reason for raising net_retry_count has long
> since disappeared.

It is quite possible that nobody checked this:
"If it ain't broken ..."

> 
> A related question might be, though:  Should that variable even exist? 
> EINTR isn't technically a failure, and most programs that read from sockets
> simply wrap their read()s in a loop that retries when EINTR is received. 
> Only mysql actually counts the number of times through the loop.

I know and agree that EINTR is no failure if a system call takes long,
like read() or write() from/to a socket (or other slow device) on
sufficiently large data.

But my current action is not to change the code, rather it is a cleanup
in the build system (you may have heard we are changing from the
autotools to cmake), so currently I won't change that loop dealing with
possible system call interruptions (by not counting).

So you are saying it might all be obsolete, and current versions of
FreeBSD don't need this special setting.
This sounds like I should do a build without it and then run tests. Thanks!


Regards,
Jörg

-- 
Joerg Bruehe,  MySQL Build Team,  Joerg.Bruehe at Sun.COM
Sun Microsystems GmbH,   Komturstrasse 18a,   D-12099 Berlin
Geschaeftsfuehrer: Juergen Kunz
Amtsgericht Muenchen: HRB161028





More information about the freebsd-questions mailing list