Bug #69610 Wasted work in method waitClusterStatus()
Submitted: 28 Jun 2013 13:52 Modified: 16 Sep 2013 14:27
Reporter: Po-Chun Chang (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S5 (Performance)
Version:5.6, 5.7 OS:Any
Assigned to: CPU Architecture:Any
Tags: patch, performance

[28 Jun 2013 13:52] Po-Chun Chang
Description:
The problem appears in version 5.6 and in the latest revision 5216 in
version 5.7.  I have attached a simple patch that fixes it.

In method "waitClusterStatus" in waiter.cpp, the loop on line 325 should
break immediately after "waitMore" is set to "false". All the iterations
after "waitMore" is set to "false" do not perform any useful work, at best
they just set "waitMore" again to "false".

How to repeat:
Once waitClusterStatus() is executed.

Suggested fix:
Break after "waitMore" is set to "false".

=== modified file 'storage/ndb/tools/waiter.cpp'
--- storage/ndb/tools/waiter.cpp	2013-02-26 06:21:48 +0000
+++ storage/ndb/tools/waiter.cpp	2013-06-28 13:52:32 +0000
@@ -324,9 +324,10 @@
 	 */
 	for (unsigned n = 0; n < ndbNodes.size(); n++){
 	  if (ndbNodes[n].node_status != NDB_MGM_NODE_STATUS_STARTED &&
-	      ndbNodes[n].node_status != NDB_MGM_NODE_STATUS_STARTING)
+	      ndbNodes[n].node_status != NDB_MGM_NODE_STATUS_STARTING){
 	    waitMore = false;
-
+	    break;
+	  }
 	}
       }
[28 Jun 2013 13:53] Po-Chun Chang
Suggested patch

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: patch.diff (text/plain), 502 bytes.

[28 Jun 2013 15:51] MySQL Verification Team
Hello Chang,

Thank you for the report and contribution.

Thanks,
Umesh
[16 Sep 2013 14:27] Jon Stephens
Fixed together with BUG#69611, BUG#69736 in NDB 7.0+.

Documented as follows in the NDB 7.0.40, 7.1.29, 7.2.14, and 7.3.3 changelogs:

      Program execution failed to break out of a loop after meeting 
      a desired condition in a number of internal methods, 
      performing unneeded work in all cases where this occurred.
    

Closed.