Bug #58247 ndb_mgm_bindaddress produces errors on stdout; errno/errmsg incorrect
Submitted: 17 Nov 2010 8:30
Reporter: Geert Vanderkelen Email Updates:
Status: Verified Impact on me:
Category:MySQL Cluster: NDB API Severity:S3 (Non-critical)
Version:mysql-5.1-telco-7.0 OS:Any
Assigned to: CPU Architecture:Any
Tags: mgmapi

[17 Nov 2010 8:30] Geert Vanderkelen
When  ndb_mgm_set_bindaddress fails, errors are reported on STDOUT and the ndb_mgm_latest_error() function reports a weird errno.

The code in 'How to repeat' produces the following output:

Unable to bind local address '' errno: 49, while trying to connect with connect string: 'nodeid=0,bind-address=,'
1012: Error

How to repeat:
# Make sure you use address which is not available.

#include <stdlib.h>
#include <ndbapi/NdbApi.hpp>
#include <mgmapi/mgmapi.h>

int main()
  NdbMgmHandle handle = ndb_mgm_create_handle();
  ndb_mgm_set_bindaddress(handle, "");
  ndb_mgm_set_timeout(handle, 500);
  ndb_mgm_connect(handle, 0, 0, 0);
  printf("%d: %s\n", ndb_mgm_get_latest_error(handle),

Suggested fix:
ndb_mgm_connect() should act nicer since this is the one reporting it and definitely not report errors using STDOUT.
Also, the error 1012 seems way off.
[15 Dec 2010 12:22] Hartmut Holzgraefe
There are also other places in storage/ndb/src/mgmapi/mgmapi.cpp that directly print error messages. In ndb_mgm_connect() this is controlled by setting the 'verbose' parameter to !=0, but other functions like ndb_mgm_bindaddress, ndb_mgm_call, etc. print to handle->errstream unconditionally.

Regarding the 1012 error code: this is the MGMAPI code for NDB_MGM_BIND_ADDRESS
and the setError() call supposed to set the error string looks correct to me:     

      setError(handle, NDB_MGM_BIND_ADDRESS, __LINE__,
               "Unable to bind local address '%s:0' errno: %d, errno: %d, "
               "while trying to connect with connect string: '%s:%d'\n",
               bind_address, err, errno, hostname, port);
No idea why ndb_mgm_get_latest_error_msg() does not return anything useful here

For a list of MGMAPI error codes see storage/ndb/include/mgmapi/mgmapi_error.h