Bug #31853 Wrong error message on failed cluster create table after mysqld (re)start
Submitted: 25 Oct 2007 14:47 Modified: 13 Feb 2012 12:01
Reporter: Hartmut Holzgraefe Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S3 (Non-critical)
Version:mysql-5.1 OS:Linux
Assigned to: Martin Skold CPU Architecture:Any
Tags: 5.1.22, usability, wrong error

[25 Oct 2007 14:47] Hartmut Holzgraefe
Description:
When mysqld is cluster enabled and started with --with-ndbcluster 
but couldn't connect to a management server yet since it started
(e.g. due to the management node(s) not running or a wrong connect 
string) an attempt to create a table produces:

  mysql> create table t1 (i int primary key) engine=ndb;
  ERROR 1495 (HY000): For the partitioned engine it is necessary to define all partitions

instead of the expected

  mysql> create table t1 (i int primary key) engine=ndb;
  ERROR 1005 (HY000): Can't create table 'test.t1' (errno: 157)

As soon as the mysqld successfully made contact to the management
server it will produce the expected error if the cluster isn't up
and running, and even when the management node vanishes again
mysqld will still produce the right error message unless it is
restarted again with the management node still down.

How to repeat:
Create a cluster configuration but start a mysqld node only.
Try to create a cluster table using this mysqld. => wrong error

Then start the ndb_mgmd, too, but not the ndbd processes.
Now the right error is shown.

Shut down the ndb_mgmd again, mysqld still shows the expected
error message on table creation attempts.

Restart the mysqld with the ndb_mgmd still down and the 
erratic behavior will show again.

Suggested fix:
Make sure mysqld returns the right error codes and message right from the start.
[12 Mar 2008 8:29] 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/43807

ChangeSet@1.2660, 2008-03-12 16:27:31+08:00, gni@dev3-221.dev.cn.tlan +1 -0
  BUG#31853 Wrong error message on failed cluster create table after after mysqld (re)start
[13 Mar 2008 6:11] 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/43895

ChangeSet@1.2660, 2008-03-13 14:10:09+08:00, gni@dev3-221.dev.cn.tlan +3 -0
  BUG#31853 Wrong error message on failed cluster create table after after mysqld (re)start
[13 Mar 2008 6:14] Guangbao Ni
Now when the mysqld never connects to ndb cluster, it will give the following error messages:
mysql> create table t2(i_ngb int primary key)engine=ndb;
ERROR 157 (HY000): Could not connect to storage engine
[13 Mar 2008 7:35] Guangbao Ni
1.
if (my_func() < 0)
  goto err;

my_var= my_func();

Why!

when the return result is less than 0, I don't want to change the my_var value.
here my_var is not a local variable.
So i don't write like :
if ((my_var= my_func()) < 0)
  goto err;

2.Yes, there can be a different result returned by the function in the 2 cases...
 when the mysqld has connected to the ndb cluster before, even though it disconnects now, the number of nodes still has value.
If want to get the same result in the 2 cases, here a connect try should do here.
[14 Mar 2008 2:40] 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/43971

ChangeSet@1.2660, 2008-03-14 10:39:06+08:00, gni@dev3-221.dev.cn.tlan +3 -0
  BUG#31853 Wrong error message on failed cluster create table after after mysqld (re)start
[20 Mar 2008 10:58] 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/44279

ChangeSet@1.2660, 2008-03-20 18:55:03+08:00, gni@dev3-221.dev.cn.tlan +3 -0
  BUG#31853 Wrong error message on failed cluster create table after after mysqld (re)start
[6 Aug 2008 12:34] Tomas Ulin
+  if (unlikely(g_ndb_cluster_connection->get_no_ready() <= 0))
+  {
+    my_error(HA_ERR_NO_CONNECTION, MYF(0));
+    return -1;
+  }
   uint no_nodes= g_ndb_cluster_connection->no_db_nodes();

Why not just check if no_nodes > 0?  why do you need to call get_no_ready?

and later in the patch:

1. please move the tmp variables inside the brackets
2. and indentation of the goto lines is wrong
[12 Aug 2008 10:47] 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/51405

2648 Guangbao Ni	2008-08-12
       BUG#31853 Wrong error message on failed cluster create table after after mysqld
      (re)start
[12 Feb 2009 11:16] 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/66025

2648 Guangbao Ni	2009-02-12
      BUG#31853 Wrong error message on failed cluster create table after after mysqld
            (re)start
[26 Apr 2010 9:12] 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/106481

3181 Martin Skold	2010-04-26
      BUG#31853 Wrong error message on failed cluster create table after after mysqld
                  (re)start
      if not connected to ndb cluster, will return HA_ERR_NO_CONNECTION error to user
      modified:
        sql/ha_ndbcluster.cc
[26 Apr 2010 9:15] 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/106482

3182 Martin Skold	2010-04-26
      BUG#31853 Wrong error message on failed cluster create table after after mysqld
                  (re)start
      if the return value of the member function get_default_no_partition() is less than 0,
          it means error happens.
      modified:
        sql/partition_info.cc
[26 Apr 2010 9:16] 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/106483

3183 Martin Skold	2010-04-26
      BUG#31853 Wrong error message on failed cluster create table after after mysqld
                  (re)start
      if the return value of the member function get_default_no_partition() is less than 0,
          it means error happens
      modified:
        sql/sql_table.cc
[26 Apr 2010 10:39] 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/106497

3506 Martin Skold	2010-04-26 [merge]
      Merge
      added:
        mysql-test/suite/ndb/r/ndb_disconnect_ddl.result
        mysql-test/suite/ndb/t/ndb_disconnect_ddl.test
      modified:
        sql/ha_ndbcluster.cc
        sql/partition_info.cc
        sql/sql_table.cc
[27 Apr 2010 10: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/106611

3184 Martin Skold	2010-04-27
      BUG#31853 Wrong error message on failed cluster create table after after mysqld (re)start: Simplified test case
      modified:
        mysql-test/suite/ndb/r/ndb_disconnect_ddl.result
        mysql-test/suite/ndb/t/ndb_disconnect_ddl.test
[27 Apr 2010 10:36] 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/106614

3507 Martin Skold	2010-04-27 [merge]
      Merge
      modified:
        mysql-test/suite/ndb/r/ndb_disconnect_ddl.result
        mysql-test/suite/ndb/t/ndb_disconnect_ddl.test
[27 Apr 2010 10:40] 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/106618

3571 Martin Skold	2010-04-27 [merge]
      Merge
      added:
        mysql-test/suite/ndb/r/ndb_disconnect_ddl.result
        mysql-test/suite/ndb/t/ndb_disconnect_ddl.test
      modified:
        sql/ha_ndbcluster.cc
        sql/partition_info.cc
        sql/sql_table.cc
[27 Apr 2010 11:38] 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/106630

3572 Martin Skold	2010-04-27 [merge]
      Merge
      modified:
        storage/ndb/src/ndbjtie/utils/mystdint.h
        win/configure.js
[27 Apr 2010 11:39] Bugs System
Pushed into 5.1.44-ndb-7.0.15 (revid:martin.skold@mysql.com-20100427103604-v355c7d8nx6vo0l5) (version source revid:martin.skold@mysql.com-20100427103604-v355c7d8nx6vo0l5) (merge vers: 5.1.44-ndb-7.0.15) (pib:16)
[27 Apr 2010 11:40] Bugs System
Pushed into 5.1.44-ndb-6.3.34 (revid:martin.skold@mysql.com-20100427100149-k6ybpamg5mprzxm1) (version source revid:martin.skold@mysql.com-20100427100149-k6ybpamg5mprzxm1) (merge vers: 5.1.44-ndb-6.3.34) (pib:16)
[28 Apr 2010 10:32] 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/106781

3186 Jonas Oreland	2010-04-28
      ndb - disable ndb_disconnect_ddl(bug#31853) - as testcase is flaky
[13 Feb 2012 12:01] Jon Stephens
Thank you for your bug report. This issue has already been fixed in the latest released version of that product, which you can download at

  http://www.mysql.com/downloads/
[13 Feb 2012 12:02] Jon Stephens
Fioxed in NDB 6.3+, documented in the NDB 6.3.34 and 7.0.15 changelogs as follows:

      When attempting to create an NDB table on an SQL node that had
      not yet connected to a MySQL Cluster management server since the
      SQL node's last restart, the CREATE TABLE statement failed with
      the unexpected Error 1495 (For the partitioned engine it is
      necessary to define all partitions).

Closed.
[13 Feb 2012 12:03] Jon Stephens
Thank you for your bug report. This issue has already been fixed in the latest released version of that product, which you can download at

  http://www.mysql.com/downloads/
[13 Feb 2012 12:04] Jon Stephens
Fioxed in NDB 6.3+, documented in the NDB 6.3.34 and 7.0.15 changelogs as follows:

      When attempting to create an NDB table on an SQL node that had
      not yet connected to a MySQL Cluster management server since the
      SQL node's last restart, the CREATE TABLE statement failed with
      the unexpected Error 1495 (For the partitioned engine it is
      necessary to define all partitions).

Closed.
[13 Feb 2012 12:05] Jon Stephens
Thank you for your bug report. This issue has already been fixed in the latest released version of that product, which you can download at

  http://www.mysql.com/downloads/
[13 Feb 2012 12:06] Jon Stephens
Fioxed in NDB 6.3+, documented in the NDB 6.3.34 and 7.0.15 changelogs as follows:

      When attempting to create an NDB table on an SQL node that had
      not yet connected to a MySQL Cluster management server since the
      SQL node's last restart, the CREATE TABLE statement failed with
      the unexpected Error 1495 (For the partitioned engine it is
      necessary to define all partitions).

Closed.