Bug #48405 Allow explicit node id for mysqld with connection pooling
Submitted: 29 Oct 2009 12:01 Modified: 9 Dec 2009 20:05
Reporter: Sivert Sørumgård Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S3 (Non-critical)
Version:mysql-5.1-telco-6.3 OS:Any
Assigned to: Magnus Blåudd CPU Architecture:Any
Tags: 6.3, 7.0

[29 Oct 2009 12:01] Sivert Sørumgård
Description:
Starting a mysqld with node id explicitly specified (as config file variable or command line parameter) makes the mysqld get only the single corresponding connection (i.e., the [mysqld] section with the matching id in the config.ini file) if connection pooling is used (ndb-cluster-connection-pool > 1). 

For connection pooling to work, the node id cannot be specified explicitly for the mysqld. This is a problem when using the Mysql Cluster Manager since we need to know the node id to interpret the status reports from the ndb_mgmd properly. 

It would be great if we could specify an explicit node id, and the mysqld would get the corresponding connection first. Later, additional connections with arbitrary node ids could be assigned. 

It would also be great if there was a way to avoid stealing the id of another mysqld, if running more than one mysqld on a host.

Related cluster bugs: 
---------------------
#27644 ndb: connecting api node/mysqld may "steal" node_id from running mysqld

#38590 Connection string with node-id specified fails to use connection-pool feature

#41592 ndb-cluster-connection-pool should [WARNING] when all connection do not connect

Related MCM bugs: 
-----------------
#47536 Support mysqld connection pooling

How to repeat:
Start mysqld with explicit node id and connection pool > 1. Have additional mysqld entries available in the config.ini file. Start the cluster and the mysqld. Run ndb_mgm to get connection status. You will see that only one connection is used by the mysqld. 

Repeat the above without explicit node id for the mysqld. Now, additional connections will be used.
[30 Oct 2009 10:49] Hartmut Holzgraefe
Shouldn't it be possible to specify an id range for a pooling mysqld, too, to be able to avoid id overlap alltogether?
[16 Nov 2009 21:55] Magnus Blåudd
In the constructor of Ndb_cluster_connection in the case when it has been created _with_ a main_connection, set the nodeid to 0 for ConfigRetriever after its been created(who then parses the connectstring and extracts whjich nodeid to use, should any be set).

Also change the constructor not to destroy ConfigRetriver if it fails to parse the connect string, that task is performed by destructor. 

msvensson@pilot:~/mysql/7.0-bug48405$ quilt diffIndex: 7.0-bug48405/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp
===================================================================
--- 7.0-bug48405.orig/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp	2009-11-16 22:42:19.000000000 +0100
+++ 7.0-bug48405/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp	2009-11-16 22:54:09.000000000 +0100
@@ -334,8 +334,6 @@ Ndb_cluster_connection_impl(const char *
       ("Could not initialize handle to management server: %s",
        m_config_retriever->getErrorString());
     printf("%s\n", get_latest_error_msg());
-    delete m_config_retriever;
-    m_config_retriever= 0;
   }
   if (!m_main_connection)
   {
@@ -348,6 +346,11 @@ Ndb_cluster_connection_impl(const char *
     m_globalDictCache = 0;
     m_transporter_facade=
       new TransporterFacade(m_main_connection->m_impl.m_globalDictCache);
+
+    // The secondary connection can't use same nodeid, clear the nodeid
+    // in ConfigRetriver to avoid asking for the same nodeid again
+    m_config_retriever->setNodeId(0);
+
   }
[16 Nov 2009 21:57] Magnus Blåudd
With this patch it's also easy to extend it to allow one specific node id to be passed as third arg to constructor. The specific nodeid could come from a list of nodeids passed to mysqld(for example).
[17 Nov 2009 16:26] 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/90705
[17 Nov 2009 17:34] Bugs System
Pushed into 5.1.39-ndb-7.0.10 (revid:magnus.blaudd@sun.com-20091117172724-7hyrcstjwf71v3v6) (version source revid:magnus.blaudd@sun.com-20091117172724-7hyrcstjwf71v3v6) (merge vers: 5.1.39-ndb-7.0.10) (pib:13)
[17 Nov 2009 17:34] Bugs System
Pushed into 5.1.39-ndb-7.1.0 (revid:magnus.blaudd@sun.com-20091117172958-eyzf3t03srth5fgf) (version source revid:magnus.blaudd@sun.com-20091117172958-eyzf3t03srth5fgf) (merge vers: 5.1.39-ndb-7.1.0) (pib:13)
[17 Nov 2009 17:45] Magnus Blåudd
Pushed to 7.0 and 7.1
[9 Dec 2009 20:05] Jon Stephens
Documented bugfix in the NDB-7.0.10 changelog as follows:

        Starting a mysqld process with --ndb-nodeid (either as a
        command-line option or by assigning it a value in my.cnf) caused
        the mysqld to get only the corresponding connection from the
        [mysqld] section in the config.ini having the matching ID, even
        when connection pooling was enabled used (that is, when the
        mysqld process was started with --ndb-cluster-connection-pool
        greater than 1).

Closed.