Bug #51273 ndb_mgmd 'get version' is not threadsafe
Submitted: 18 Feb 2010 7:51 Modified: 23 Feb 2010 11:55
Reporter: Magnus Blåudd Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S2 (Serious)
Version:6.3.32 OS:Any
Assigned to: Magnus Blåudd CPU Architecture:Any

[18 Feb 2010 7:51] Magnus Blåudd
Description:
ndb_mgmd exposes a "get version" command which returns the compiled in version number and strings for ndb_mgmd.

Unfortunately the value for "string:" attribute is generated by calling 'ndbGetOwnVersionString' which is not thread safe since it's using a _static_ stack variable where it regenerates the version string for each call to the function. This causes the value of "string:" to contain garbage characters()or at least \0 in the wrong places).

How to repeat:
The "get version" command is used by 'ndb_mgm_get_version' and when running that simultaneously from a couple of threads it will trigger a parsing error in the mgmapi that looks like:

Error in mgm protocol parser. cmd: >get version< status: 5 curr: ysql-5.1.41 ndb-7.0.13
ndb_mgm_get_version failed,error: Illegal reply from server

Suggested fix:
Don't use 'ndbGetOwnVersionString' from the "get version" command.
[18 Feb 2010 13:10] 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/100743
[18 Feb 2010 13:54] 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/100755
[18 Feb 2010 15:15] Bugs System
Pushed into 5.1.41-ndb-7.0.13 (revid:magnus.blaudd@sun.com-20100218151033-iua2m7c6saazuogz) (version source revid:magnus.blaudd@sun.com-20100218151033-iua2m7c6saazuogz) (merge vers: 5.1.41-ndb-7.0.13) (pib:16)
[18 Feb 2010 16:36] Magnus Blåudd
Pushed to 6.3, 7.0 and 7.1
[19 Feb 2010 9:12] Jon Stephens
Documented in the NDB-6.3.32, 7.0.13, and 7.1.2 changelogs, as follows:

      The MGM API function ndb_mgm_get_version() regenerated the version 
      string to be reported each time the function was called. This caused 
      the version string to contain random characters, including misplaced 
      \0 characters.

Closed.
[19 Feb 2010 9:51] Magnus Blåudd
It was actually not in 'ndb_mgm_get_version' but in ndb_mgmd.

Could cause startup problems when starting many ndbd's at the same time.
[19 Feb 2010 11:02] 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/100844

3095 Martin Skold	2010-02-19 [merge]
      Merge
      modified:
        storage/ndb/include/util/Parser.hpp
        storage/ndb/src/kernel/blocks/dbacc/Dbacc.hpp
        storage/ndb/src/kernel/blocks/dbacc/DbaccInit.cpp
        storage/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp
        storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp
        storage/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp
        storage/ndb/src/kernel/vm/ndbd_malloc_impl.cpp
        storage/ndb/src/mgmsrv/MgmtSrvr.cpp
        storage/ndb/src/mgmsrv/MgmtSrvr.hpp
        storage/ndb/src/mgmsrv/Services.cpp
        storage/ndb/test/include/NdbRestarter.hpp
        storage/ndb/test/ndbapi/testMgm.cpp
        storage/ndb/test/ndbapi/testUpgrade.cpp
        storage/ndb/test/run-test/command.cpp
        storage/ndb/test/run-test/db.cpp
        storage/ndb/test/run-test/upgrade-tests.txt
        storage/ndb/test/src/CpcClient.cpp
        storage/ndb/test/src/NdbRestarter.cpp
[23 Feb 2010 11:55] Jon Stephens
Revised changelog entry reads:

        An issue internal to ndb_mgm could cause problems when trying to 
        start a large number of data nodes at the same time.

Closed.