#At file:///home/tomas/mysql_src/mysql-5.1-telco-6.3/
2799 Tomas Ulin 2009-01-12
Bug #33626 MySQL clients does not reconnect to Cluster after it was restarted
modified:
mysql-test/suite/ndb/t/disabled.def
sql/ha_ndbcluster.cc
sql/ha_ndbcluster_binlog.cc
sql/ha_ndbcluster_connection.cc
storage/ndb/src/ndbapi/ClusterMgr.cpp
=== modified file 'mysql-test/suite/ndb/t/disabled.def'
--- a/mysql-test/suite/ndb/t/disabled.def 2008-12-10 15:35:47 +0000
+++ b/mysql-test/suite/ndb/t/disabled.def 2009-01-12 13:11:43 +0000
@@ -11,5 +11,4 @@
##############################################################################
ndb_partition_error2 : HF is not sure if the test can work as internded on all the platforms
-ndb_reconnect : jonas 2008-11-20, breaks, please enable when fixed
# the below testcase have been reworked to avoid the bug, test contains comment, keep bug open
=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc 2008-12-10 15:35:47 +0000
+++ b/sql/ha_ndbcluster.cc 2009-01-12 13:11:43 +0000
@@ -11040,7 +11040,14 @@ pthread_handler_t ndb_util_thread_func(v
continue;
}
if (!ndb_binlog_tables_inited)
+ {
ndbcluster_setup_binlog_table_shares(thd);
+ if (!ndb_binlog_tables_inited)
+ {
+ set_timespec(abstime, 1);
+ continue;
+ }
+ }
if (ndb_cache_check_time == 0)
{
=== modified file 'sql/ha_ndbcluster_binlog.cc'
--- a/sql/ha_ndbcluster_binlog.cc 2009-01-12 09:01:57 +0000
+++ b/sql/ha_ndbcluster_binlog.cc 2009-01-12 13:11:43 +0000
@@ -3614,7 +3614,8 @@ ndbcluster_read_binlog_replication(THD *
Ndb_table_guard ndbtab_g(dict, ndb_replication_table);
const NDBTAB *reptab= ndbtab_g.get_table();
if (reptab == NULL &&
- dict->getNdbError().classification == NdbError::SchemaError)
+ (dict->getNdbError().classification == NdbError::SchemaError ||
+ dict->getNdbError().code == 4009))
{
DBUG_PRINT("info", ("No %s.%s table", ndb_rep_db, ndb_replication_table));
if (do_set_binlog_flags)
@@ -3781,6 +3782,8 @@ ndbcluster_read_binlog_replication(THD *
}
err:
+ DBUG_PRINT("info", ("error %d, error_str %s, ndberror.code %u",
+ error, error_str, ndberror.code));
if (error > 0)
{
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
@@ -5495,7 +5498,6 @@ restart_cluster_failure:
}
}
pthread_mutex_unlock(&LOCK_server_started);
- restart:
/*
Main NDB Injector loop
*/
@@ -6129,11 +6131,6 @@ restart_cluster_failure:
*root_ptr= old_root;
ndb_latest_handled_binlog_epoch= ndb_latest_received_binlog_epoch;
}
- if (do_ndbcluster_binlog_close_connection == BCCC_restart)
- {
- ndb_binlog_tables_inited= FALSE;
- goto restart;
- }
err:
if (do_ndbcluster_binlog_close_connection != BCCC_restart)
{
@@ -6155,6 +6152,13 @@ restart_cluster_failure:
pthread_mutex_unlock(&injector_mutex);
thd->db= 0; // as not to try to free memory
+ /*
+ This will cause the util thread to start to try to initialize again
+ via ndbcluster_setup_binlog_table_shares. But since injector_ndb is
+ set to NULL it will not succeed until injector_ndb is reinitialized.
+ */
+ ndb_binlog_tables_inited= FALSE;
+
if (ndb_apply_status_share)
{
/* ndb_share reference binlog extra free */
@@ -6163,7 +6167,6 @@ restart_cluster_failure:
ndb_apply_status_share->use_count));
free_share(&ndb_apply_status_share);
ndb_apply_status_share= 0;
- ndb_binlog_tables_inited= FALSE;
}
if (ndb_schema_share)
{
@@ -6175,7 +6178,6 @@ restart_cluster_failure:
ndb_schema_share->use_count));
free_share(&ndb_schema_share);
ndb_schema_share= 0;
- ndb_binlog_tables_inited= FALSE;
pthread_mutex_unlock(&ndb_schema_share_mutex);
/* end protect ndb_schema_share */
}
@@ -6205,7 +6207,6 @@ restart_cluster_failure:
if (do_ndbcluster_binlog_close_connection == BCCC_restart)
{
- ndb_binlog_tables_inited= FALSE;
pthread_mutex_lock(&injector_mutex);
goto restart_cluster_failure;
}
=== modified file 'sql/ha_ndbcluster_connection.cc'
--- a/sql/ha_ndbcluster_connection.cc 2008-11-26 12:55:36 +0000
+++ b/sql/ha_ndbcluster_connection.cc 2009-01-12 13:11:43 +0000
@@ -35,6 +35,15 @@ static ulong g_ndb_cluster_connection_po
static ulong g_ndb_cluster_connection_pool_pos= 0;
static pthread_mutex_t g_ndb_cluster_connection_pool_mutex;
+/*
+ Global flag in ndbapi to specify if api should wait to connect
+ until dict cache is clean.
+
+ Set to 1 below to not wait, as ndb handler makes sure that no
+ old ndb objects are used.
+*/
+extern int global_flag_skip_waiting_for_clean_cache;
+
int ndbcluster_connect(int (*connect_callback)(void))
{
#ifndef EMBEDDED_LIBRARY
@@ -44,6 +53,9 @@ int ndbcluster_connect(int (*connect_cal
#endif
int res;
DBUG_ENTER("ndbcluster_connect");
+
+ global_flag_skip_waiting_for_clean_cache= 1;
+
// Set connectstring if specified
if (opt_ndbcluster_connectstring != 0)
DBUG_PRINT("connectstring", ("%s", opt_ndbcluster_connectstring));
=== modified file 'storage/ndb/src/ndbapi/ClusterMgr.cpp'
--- a/storage/ndb/src/ndbapi/ClusterMgr.cpp 2008-12-16 20:51:49 +0000
+++ b/storage/ndb/src/ndbapi/ClusterMgr.cpp 2009-01-12 13:11:43 +0000
@@ -37,6 +37,7 @@
#include <mgmapi_config_parameters.h>
int global_flag_skip_invalidate_cache = 0;
+int global_flag_skip_waiting_for_clean_cache = 0;
//#define DEBUG_REG
// Just a C wrapper for threadMain
@@ -240,11 +241,14 @@ ClusterMgr::threadMain( ){
if (m_cluster_state == CS_waiting_for_clean_cache &&
theFacade.m_globalDictCache)
{
- theFacade.m_globalDictCache->lock();
- unsigned sz= theFacade.m_globalDictCache->get_size();
- theFacade.m_globalDictCache->unlock();
- if (sz)
- goto next;
+ if (!global_flag_skip_waiting_for_clean_cache)
+ {
+ theFacade.m_globalDictCache->lock();
+ unsigned sz= theFacade.m_globalDictCache->get_size();
+ theFacade.m_globalDictCache->unlock();
+ if (sz)
+ goto next;
+ }
m_cluster_state = CS_waiting_for_first_connect;
}
| Thread |
|---|
| • bzr commit into mysql-5.1 branch (tomas.ulin:2799) Bug#33626 | Tomas Ulin | 12 Jan |