Bug #77969 ndb_mgmd silently exists on certain daemon errors.
Submitted: 6 Aug 2015 22:17 Modified: 19 Aug 2015 17:30
Reporter: Matthew Montgomery Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S3 (Non-critical)
Version:7.4.6 OS:Any
Assigned to: CPU Architecture:Any

[6 Aug 2015 22:17] Matthew Montgomery
Description:
ndb_mgmd should not silently exit on the shell when it encounters an error that prevents it from starting

How to repeat:
memontgo | /data/mysql/sandbox/7.4.4 | 17:10:47 $ ps -auwx | grep ndb_mgmd
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
memontgo 11528  4.2  0.5 905196 22000 ?        Ssl  15:59   3:04 ndb_mgmd -f config.ini --initial
memontgo 13486  0.0  0.0 103252   852 pts/3    S+   17:10   0:00 grep ndb_mgmd
memontgo | /data/mysql/sandbox/7.4.4 | 17:10:55 $ ./bin/ndb_mgmd --print-defaults --reload
MySQL Cluster Management Server mysql-5.6.23 ndb-7.4.4
./bin/ndb_mgmd would have been started with the following arguments:
--config-file=/data/mysql/sandbox/7.4.4/config.ini --config-dir=/data/mysql/sandbox/7.4.3/mysql-cluster --connect-string=localhost --reload 
memontgo | /data/mysql/sandbox/7.4.4 | 17:11:12 $ ./bin/ndb_mgmd --reload
MySQL Cluster Management Server mysql-5.6.23 ndb-7.4.4
memontgo | /data/mysql/sandbox/7.4.4 | 17:11:20 $ tail -3 ./mysql-cluster/ndb_50_cluster.log
2015-08-06 17:11:20 [MgmtSrvr] INFO     -- Loaded config from '/data/mysql/sandbox/7.4.3/mysql-cluster/ndb_50_config.bin.1'
2015-08-06 17:11:20 [MgmtSrvr] INFO     -- Loaded configuration from '/data/mysql/sandbox/7.4.4/config.ini', will try to set it once started
2015-08-06 17:11:20 [MgmtSrvr] ERROR    -- Couldn't start as daemon, error: 'Failed to lock pidfile '/data/mysql/sandbox/7.4.4/mysql-cluster/ndb_50.pid', already locked by pid=11528, errno: 11'

Suggested fix:
Include printouts to stderr when terminating the daemon on error.

--- main.cpp	2015-04-01 12:15:56.000000000 -0500
+++ main.cpp-mmo	2015-08-06 17:00:50.575036061 -0500
@@ -271,6 +271,7 @@
     mgm= new MgmtSrvr(opts);
     if (mgm == NULL) {
       g_eventLogger->critical("Out of memory, couldn't create MgmtSrvr");
+      fprintf(stderr, "CRITICAL: Out of memory, couldn't create MgmtSrvr\n");
       mgmd_exit(1);
     }
 
@@ -292,6 +293,7 @@
       NodeId localNodeId= mgm->getOwnNodeId();
       if (localNodeId == 0) {
         g_eventLogger->error("Couldn't get own node id");
+	fprintf(stderr, "Couldn't get own node id\n");
         delete mgm;
         mgmd_exit(1);
       }
@@ -302,6 +304,8 @@
       {
         g_eventLogger->error("Couldn't start as daemon, error: '%s'",
                              ndb_daemon_error);
+        fprintf(stderr, "Couldn't start as daemon, error: '%s' \n", 
+                             ndb_daemon_error);
         mgmd_exit(1);
       }
     }

memontgo | /data/mysql/source/internal_trees/mysql-cluster-gpl-7.4.6/storage/ndb/src/mgmsrv | 17:14:00 $ ./ndb_mgmd --reload
MySQL Cluster Management Server mysql-5.6.24 ndb-7.4.6
Couldn't start as daemon, error: 'Failed to lock pidfile '/data/mysql/sandbox/7.4.4/mysql-cluster/ndb_50.pid', already locked by pid=11528, errno: 11'
[19 Aug 2015 17:30] Jon Stephens
Documented fix in the NDB 7.4.8 changelog as follows:

    In some cases, the management server daemon failed on startup
    without reporting the reason. Now when ndb_mgmd fails to start
    due to an error, the error message is printed to stderr.

Closed.