Bug #37334 Very rare race-condition can lead to stale-connection
Submitted: 11 Jun 2008 9:22 Modified: 2 Jul 2008 15:52
Reporter: Jonas Oreland Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S3 (Non-critical)
Version:* OS:Any
Assigned to: Jonas Oreland CPU Architecture:Any

[11 Jun 2008 9:22] Jonas Oreland
Description:
1) do_connect
state := CONNECTING

2) start client_thread reads connectState
and starts connecting

3) do_disconnect
state := DISCONNECTING

4) update connections
state == DISCONNECTING && isConnected() == false ->
  report_disconnect -> state := DISCONNECTED

5) start_client_thread manage to connect

---

End result:
state = DISCONNECTED
transporter is connected

How to repeat:
no repeatable testcase :-(

Suggested fix:
+      case DISCONNECTED:
+      {
+        if (t->isConnected())
+        {
+          g_eventLogger.warning("Found connection to %u in state DISCONNECTED "
+                                " while being connected, disconnecting!",
+                                t->getRemoteNodeId());
+          t->doDisconnect();
+        }
+        break;
+      }
[11 Jun 2008 9:28] 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/commits/47722

2621 jonas@mysql.com	2008-06-11
      ndb - bug#37334
        Fix race condition with sequence do_connect,do_disconnect
        on transporter
[2 Jul 2008 6:58] Jonas Oreland
pushed to 6.3.16 and 6.2.16
[2 Jul 2008 15:52] Jon Stephens
Documented in the NDB 6.2.16 and 6.3.16 changelogs as follows:

        In rare circumstances, a connection followed by a disconnection could give 
        rise to a "stale" connection where the connection still existed but was 
        not seen by the transporter.
[12 Dec 2008 23:27] Bugs System
Pushed into 6.0.6-alpha  (revid:jonas@mysql.com-20080611092840-7840su31p7ks71u9) (version source revid:jonas@mysql.com-20080812185642-1nevjb94zj621dqx) (pib:5)