Bug #12582 using sleep() can make the thread unkillable
Submitted: 15 Aug 2005 12:46 Modified: 18 Aug 2005 18:47
Reporter: Michael Widenius Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.0 OS:Any (all)
Assigned to: Jim Winstead CPU Architecture:Any

[15 Aug 2005 12:46] Michael Widenius
Description:
One can make a thread unkillable by executing sleep(#) with a high argument
Another problem is that my_usleep() is not guranteed to sleep the requested number of microseconds as in a threaded environment it's not uncommon that threads wake up from
select() or sleep() much earlier

How to repeat:
- Create two connections to mysql and let one do a sleep(10000) and in the other send a kill to the first connection.
- Test on all os (especially Linux with linuxthreads and freebsd) to verify that during a heavy multi-thread test that sleep() doesn't wake us to early.

Suggested fix:
Change call of my_sleep() to use pthread_cond_timedwait() and make it breakable by 'kill #mysql_connection_id'
[16 Aug 2005 18:38] 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:

  http://lists.mysql.com/internals/28345
[16 Aug 2005 19:17] Jim Winstead
i'm working on testing this on freebsd and linux with linuxthreads, but it seems that any failures under load would be a problem shared with GET_LOCK().
[16 Aug 2005 23:29] 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:

  http://lists.mysql.com/internals/28357
[18 Aug 2005 1:06] 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:

  http://lists.mysql.com/internals/28429
[18 Aug 2005 18:47] Jim Winstead
Fixed in 5.0.12. (Doesn't need documentation, since SLEEP() hasn't been in a release yet.)