Bug #31853 Wrong error message on failed cluster create table after mysqld (re)start
Submitted: 25 Oct 2007 16:47 Modified: 12 Feb 12:16
Reporter: Hartmut Holzgraefe
Status: Patch pending
Category:Server: Cluster Severity:S3 (Non-critical)
Version:mysql-5.1 OS:Linux
Assigned to: Bernhard Ocklin Target Version:
Tags: usability, wrong error, 5.1.22
Triage: Triaged: D4 (Minor)

[25 Oct 2007 16: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 9: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 7: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 7: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 8: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 3: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 11: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 14: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 12: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 12: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