WorkLog Frontpage Log in / Register
High-Level Description | Task Dependencies | High-Level Specification | Low-Level Design | File Attachments | User Comments | Time Estimates | Funding and Votes | Progress Reports

 add is_connection_alive for server-side checks to find disconnected clients
Title
Task ID196
Queue
Version N/A
Status
PriorityN/A
Copies toSergei

Created byMdcallag08 Apr 2011Done
Supervisor N/A  
Lead Architect    
Architecture Review  
Implementor  
Code Review  
QA  
Documentation  
 High-Level Description
There are a few places in the server where the thread for a user connection will 
wait. With upcoming features in the FB patch there will be more places. I don't 
want a thread to continue waiting after the client has disconnected. Is it 
possible to check whether the client has disconnected without reading/writing 
more than 0 bytes from the socket? Assuming the check is is_connection_alive(), 
it can return TRUE when the client has disconnected (but not all of the time). 
But it must not return FALSE when the client has not disconnected.

The check does not have to be cheap. It can require a system call as it won't be 
made frequently. For example, assume that a row lock wait is implemented as a 
sequent of timed pthread condition variable waits (1 second each). At the end of 
each 1 second timeout there can be a check for whether the connection was killed 
and a check for whether the client has disconnected.

Disconnected clients on the server-side can be a serious problem for high 
throughput servers. The worst case is when the client starts a long-running and 
blocking query (external sort) that won't return a row for a long time and thus 
won't detect the disconnected client for a long time.

I have used tool in the past that join output from netstat with SHOW PROCESSLIST 
to find sockets for disconnected clients. This works but is very expensive.

MySQL 5.5 has vio_is_connected which and Interruptible_wait which is used for 
"select get_lock(...)" and "select sleep(...)". I think that can be used in more 
places.

I think the scope of this WL is to determine where else in the server the 
is_connected check can be made. I think it is needed for blocking query plans. If 
a query does a 2 hour external sort and the client disconnects after the first 
hour, MySQL will not notice. The other place is a query that runs for a long time 
before returning data (full table scan with high selectivity is an example). In 
this case the query plan isn't blocking but still can run a long time before 
noticing the client has disconnected.

I have lots of experience with mysqld servers overloaded by disconnected clients 
and my teams have built tools to detect this and kill them (at multiple 
companies). I prefer that we solve this in mysql.
 Task Dependencies
Others waiting for Task 196Task 196 is waiting forGraph
 
 High-Level Specification
 Low-Level Design
 File Attachments
 NameTypeSizeByDate
 User Comments
 Time Estimates
NameHours WorkedLast Updated
Total0 
 Hrs WorkedProgressCurrentOriginal
Total000
 
 Funding and Votes
Votes: 1: 100%
 Change vote: Useless    Nice to have    Important    Very important    

Funding: 0 offers, total 0 Euro
 Progress Reports
(Mdcallag - Sat, 09 Apr 2011, 14:27
    
High Level Description modified.
--- /tmp/wklog.196.old.20593	2011-04-09 14:27:03.000000000 +0000
+++ /tmp/wklog.196.new.20593	2011-04-09 14:27:03.000000000 +0000
@@ -24,3 +24,15 @@
 "select get_lock(...)" and "select sleep(...)". I think that can be used in more 
 places.
 
+I think the scope of this WL is to determine where else in the server the 
+is_connected check can be made. I think it is needed for blocking query plans. If 
+a query does a 2 hour external sort and the client disconnects after the first 
+hour, MySQL will not notice. The other place is a query that runs for a long time 
+before returning data (full table scan with high selectivity is an example). In 
+this case the query plan isn't blocking but still can run a long time before 
+noticing the client has disconnected.
+
+I have lots of experience with mysqld servers overloaded by disconnected clients 
+and my teams have built tools to detect this and kill them (at multiple 
+companies). I prefer that we solve this in mysql.
+

(Sergei - Fri, 08 Apr 2011, 16:39
    
Observers changed: Sergei

(Mdcallag - Fri, 08 Apr 2011, 15:23
    
High Level Description modified.
--- /tmp/wklog.196.old.17122	2011-04-08 15:23:10.000000000 +0000
+++ /tmp/wklog.196.new.17122	2011-04-08 15:23:10.000000000 +0000
@@ -20,3 +20,7 @@
 I have used tool in the past that join output from netstat with SHOW PROCESSLIST 
 to find sockets for disconnected clients. This works but is very expensive.
 
+MySQL 5.5 has vio_is_connected which and Interruptible_wait which is used for 
+"select get_lock(...)" and "select sleep(...)". I think that can be used in more 
+places.
+


Report Generator:
 
Saved Reports:

WorkLog v4.0.0
  © 2010  Sergei Golubchik and Monty Program AB
  © 2004  Andrew Sweger <yDNA@perlocity.org> and Addnorya
  © 2003  Matt Wagner <matt@mysql.com> and MySQL AB