Bug #69611 Wasted work in method CPCD::findUniqueId()
Submitted: 28 Jun 2013 14:00 Modified: 16 Sep 2013 14:25
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 14:00] 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 "CPCD::findUniqueId()" in CPCD.cpp, the loop on line 63 should
break immediately after "ok" is set to "false". All the iterations after
"ok" is set to "false" do not perform any useful work, at best they just
set "ok" again to "false".

How to repeat:
Once CPCD::findUniqueId() is executed.

Suggested fix:
Break loop after "ok" is set to "false".

=== modified file 'storage/ndb/src/cw/cpcd/CPCD.cpp'
--- storage/ndb/src/cw/cpcd/CPCD.cpp	2013-02-26 06:21:48 +0000
+++ storage/ndb/src/cw/cpcd/CPCD.cpp	2013-06-28 14:00:10 +0000
@@ -61,8 +61,10 @@
       ok = false;
 
     for(unsigned i = 0; i<m_processes.size(); i++) {
-      if(m_processes[i]->m_id == id)
+      if(m_processes[i]->m_id == id) {
 	ok = false;
+	break;
+      }
     }
   }
   m_processes.unlock();
[28 Jun 2013 14:01] 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), 421 bytes.

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

Thank you for the report and contribution.

Thanks,
Umesh
[16 Sep 2013 14:25] Jon Stephens
Fixed in 7.0.40, 7.1.29, 7.2.14, 7.3.3.

See BUG#69610 for documentation info.

Closed.