Bug #69171 Wasted work in method is_ndb_node()
Submitted: 8 May 2013 3:24 Modified: 10 Jun 2013 13:53
Reporter: Po-Chun Chang (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S5 (Performance)
Version:5.6, 5.7 OS:Any
Assigned to: Magnus Blåudd CPU Architecture:Any
Tags: patch, performance

[8 May 2013 3:24] 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 one-line patch (patch.diff) that fixes it.  This problem is similar to the already verified MySQL #69117.

In method "is_ndb_node()" in CommandInterpreter.cpp, the loop on line 1091
should break immediately after "found" is set to "true".  All the iterations
after "found" is set to "true" do not perform any useful work, at best they
just set "found" again to "true".

How to repeat:
Once is_ndb_node() is executed.

Suggested fix:
=== modified file 'storage/ndb/src/mgmclient/CommandInterpreter.cpp'
--- storage/ndb/src/mgmclient/CommandInterpreter.cpp	2013-02-26 06:21:48 +0000
+++ storage/ndb/src/mgmclient/CommandInterpreter.cpp	2013-05-08 03:24:42 +0000
@@ -1091,8 +1091,10 @@
     for (int i = 0; i < m_status->no_of_nodes; i++)
     {
       if (m_status->node_states[i].node_id == nodeid &&
-          m_status->node_states[i].node_type == NDB_MGM_NODE_TYPE_NDB)
+          m_status->node_states[i].node_type == NDB_MGM_NODE_TYPE_NDB) {
         found = true;
+        break;
+      }
     }
 
     if (!found)
[8 May 2013 3:24] Po-Chun Chang
Suggested patch

Attachment: patch.diff (text/plain), 588 bytes.

[8 May 2013 6:30] MySQL Verification Team
Thank you for the bug report and contribution.
[10 Jun 2013 13:53] Magnus Blåudd
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release.

If necessary, you can access the source repository and build the latest available version, including the bug fix. More information about accessing the source trees is available at

    http://dev.mysql.com/doc/en/installing-source.html
[10 Jun 2013 14:01] Magnus Blåudd
Fixed from MySQL Cluster 7.0.39 and upwards
[17 Jun 2013 11:39] Jon Stephens
For documentation, see BUG#69393.