Commit 23b2d1d2 authored by unknown's avatar unknown

Merge bk-internal:/home/bk/mysql-5.1

into  neptunus.(none):/home/msvensson/mysql/mysql-5.1


sql/ha_ndbcluster.cc:
  Auto merged
storage/ndb/src/ndbapi/TransporterFacade.cpp:
  Auto merged
parents bfee156a 64a70ab7
...@@ -6214,9 +6214,7 @@ static void ndbcluster_drop_database(handlerton *hton, char *path) ...@@ -6214,9 +6214,7 @@ static void ndbcluster_drop_database(handlerton *hton, char *path)
#endif #endif
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
/*
find all tables in ndb and discover those needed
*/
int ndb_create_table_from_engine(THD *thd, const char *db, int ndb_create_table_from_engine(THD *thd, const char *db,
const char *table_name) const char *table_name)
{ {
...@@ -6229,6 +6227,9 @@ int ndb_create_table_from_engine(THD *thd, const char *db, ...@@ -6229,6 +6227,9 @@ int ndb_create_table_from_engine(THD *thd, const char *db,
return res; return res;
} }
/*
find all tables in ndb and discover those needed
*/
int ndbcluster_find_all_files(THD *thd) int ndbcluster_find_all_files(THD *thd)
{ {
DBUG_ENTER("ndbcluster_find_all_files"); DBUG_ENTER("ndbcluster_find_all_files");
...@@ -7290,31 +7291,51 @@ static byte *ndbcluster_get_key(NDB_SHARE *share,uint *length, ...@@ -7290,31 +7291,51 @@ static byte *ndbcluster_get_key(NDB_SHARE *share,uint *length,
return (byte*) share->key; return (byte*) share->key;
} }
#ifndef DBUG_OFF #ifndef DBUG_OFF
static void dbug_print_open_tables()
static void print_share(const char* where, NDB_SHARE* share)
{ {
DBUG_ENTER("dbug_print_open_tables"); fprintf(DBUG_FILE,
for (uint i= 0; i < ndbcluster_open_tables.records; i++) "%s %s.%s: use_count: %u, commit_count: %llu\n",
{ where, share->db, share->table_name, share->use_count,
NDB_SHARE *share= (NDB_SHARE*) hash_element(&ndbcluster_open_tables, i); share->commit_count);
DBUG_PRINT("loop", fprintf(DBUG_FILE,
("[%d] 0x%lx key: %s key_length: %d", " - key: %s, key_length: %d\n",
i, (long) share, share->key, share->key_length)); share->key, share->key_length);
DBUG_PRINT("loop",
("db.tablename: %s.%s use_count: %d commit_count: %lu",
share->db, share->table_name,
share->use_count, (ulong) share->commit_count));
#ifdef HAVE_NDB_BINLOG #ifdef HAVE_NDB_BINLOG
if (share->table) if (share->table)
DBUG_PRINT("loop", fprintf(DBUG_FILE,
("table->s->db.table_name: %s.%s", " - share->table: %p %s.%s\n",
share->table->s->db.str, share->table->s->table_name.str)); share->table, share->table->s->db.str,
share->table->s->table_name.str);
#endif #endif
}
DBUG_VOID_RETURN;
} }
#else
#define dbug_print_open_tables()
static void print_ndbcluster_open_tables()
{
DBUG_LOCK_FILE;
fprintf(DBUG_FILE, ">ndbcluster_open_tables\n");
for (uint i= 0; i < ndbcluster_open_tables.records; i++)
print_share("",
(NDB_SHARE*)hash_element(&ndbcluster_open_tables, i));
fprintf(DBUG_FILE, "<ndbcluster_open_tables\n");
DBUG_UNLOCK_FILE;
}
#define dbug_print_open_tables() \
DBUG_EXECUTE("info", \
print_ndbcluster_open_tables(););
#define dbug_print_share(t, s) \
DBUG_LOCK_FILE; \
DBUG_EXECUTE("info", \
print_share((t), (s));); \
DBUG_UNLOCK_FILE;
#endif #endif
#ifdef HAVE_NDB_BINLOG #ifdef HAVE_NDB_BINLOG
...@@ -7459,19 +7480,9 @@ static int rename_share(NDB_SHARE *share, const char *new_key) ...@@ -7459,19 +7480,9 @@ static int rename_share(NDB_SHARE *share, const char *new_key)
share->table_name= share->db + strlen(share->db) + 1; share->table_name= share->db + strlen(share->db) + 1;
ha_ndbcluster::set_tabname(new_key, share->table_name); ha_ndbcluster::set_tabname(new_key, share->table_name);
DBUG_PRINT("info", dbug_print_share("rename_share:", share);
("share: 0x%lx key: %s key_length: %d",
(long) share, share->key, share->key_length));
DBUG_PRINT("info",
("db.tablename: %s.%s use_count: %d commit_count: %lu",
share->db, share->table_name,
share->use_count, (ulong) share->commit_count));
if (share->table) if (share->table)
{ {
DBUG_PRINT("rename_share",
("table->s->db.table_name: %s.%s",
share->table->s->db.str, share->table->s->table_name.str));
if (share->op == 0) if (share->op == 0)
{ {
share->table->s->db.str= share->db; share->table->s->db.str= share->db;
...@@ -7499,14 +7510,7 @@ NDB_SHARE *ndbcluster_get_share(NDB_SHARE *share) ...@@ -7499,14 +7510,7 @@ NDB_SHARE *ndbcluster_get_share(NDB_SHARE *share)
share->use_count++; share->use_count++;
dbug_print_open_tables(); dbug_print_open_tables();
dbug_print_share("ndbcluster_get_share:", share);
DBUG_PRINT("info",
("share: 0x%lx key: %s key_length: %d",
(long) share, share->key, share->key_length));
DBUG_PRINT("info",
("db.tablename: %s.%s use_count: %d commit_count: %lu",
share->db, share->table_name,
share->use_count, (ulong) share->commit_count));
pthread_mutex_unlock(&ndbcluster_mutex); pthread_mutex_unlock(&ndbcluster_mutex);
return share; return share;
} }
...@@ -7597,14 +7601,7 @@ NDB_SHARE *ndbcluster_get_share(const char *key, TABLE *table, ...@@ -7597,14 +7601,7 @@ NDB_SHARE *ndbcluster_get_share(const char *key, TABLE *table,
share->use_count++; share->use_count++;
dbug_print_open_tables(); dbug_print_open_tables();
dbug_print_share("ndbcluster_get_share:", share);
DBUG_PRINT("info",
("0x%lx key: %s key_length: %d key: %s",
(long) share, share->key, share->key_length, key));
DBUG_PRINT("info",
("db.tablename: %s.%s use_count: %d commit_count: %lu",
share->db, share->table_name,
share->use_count, (ulong) share->commit_count));
if (!have_lock) if (!have_lock)
pthread_mutex_unlock(&ndbcluster_mutex); pthread_mutex_unlock(&ndbcluster_mutex);
DBUG_RETURN(share); DBUG_RETURN(share);
...@@ -7614,12 +7611,7 @@ NDB_SHARE *ndbcluster_get_share(const char *key, TABLE *table, ...@@ -7614,12 +7611,7 @@ NDB_SHARE *ndbcluster_get_share(const char *key, TABLE *table,
void ndbcluster_real_free_share(NDB_SHARE **share) void ndbcluster_real_free_share(NDB_SHARE **share)
{ {
DBUG_ENTER("ndbcluster_real_free_share"); DBUG_ENTER("ndbcluster_real_free_share");
DBUG_PRINT("enter", dbug_print_share("ndbcluster_real_free_share:", *share);
("share: 0x%lx key: %s key_length: %d "
"db.tablename: %s.%s use_count: %d commit_count: %lu",
(long) (*share), (*share)->key, (*share)->key_length,
(*share)->db, (*share)->table_name,
(*share)->use_count, (ulong) (*share)->commit_count));
hash_delete(&ndbcluster_open_tables, (byte*) *share); hash_delete(&ndbcluster_open_tables, (byte*) *share);
thr_lock_delete(&(*share)->lock); thr_lock_delete(&(*share)->lock);
...@@ -7648,12 +7640,7 @@ void ndbcluster_real_free_share(NDB_SHARE **share) ...@@ -7648,12 +7640,7 @@ void ndbcluster_real_free_share(NDB_SHARE **share)
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
/*
decrease refcount of share
calls real_free_share when refcount reaches 0
have_lock == TRUE, pthread_mutex_lock(&ndbcluster_mutex) already taken
*/
void ndbcluster_free_share(NDB_SHARE **share, bool have_lock) void ndbcluster_free_share(NDB_SHARE **share, bool have_lock)
{ {
if (!have_lock) if (!have_lock)
...@@ -7667,13 +7654,7 @@ void ndbcluster_free_share(NDB_SHARE **share, bool have_lock) ...@@ -7667,13 +7654,7 @@ void ndbcluster_free_share(NDB_SHARE **share, bool have_lock)
else else
{ {
dbug_print_open_tables(); dbug_print_open_tables();
DBUG_PRINT("info", dbug_print_share("ndbcluster_free_share:", *share);
("share: 0x%lx key: %s key_length: %d",
(long) *share, (*share)->key, (*share)->key_length));
DBUG_PRINT("info",
("db.tablename: %s.%s use_count: %d commit_count: %lu",
(*share)->db, (*share)->table_name,
(*share)->use_count, (ulong) (*share)->commit_count));
} }
if (!have_lock) if (!have_lock)
pthread_mutex_unlock(&ndbcluster_mutex); pthread_mutex_unlock(&ndbcluster_mutex);
...@@ -8330,9 +8311,9 @@ ha_ndbcluster::update_table_comment( ...@@ -8330,9 +8311,9 @@ ha_ndbcluster::update_table_comment(
pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused))) pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
{ {
THD *thd; /* needs to be first for thread_stack */ THD *thd; /* needs to be first for thread_stack */
Ndb* ndb;
struct timespec abstime; struct timespec abstime;
List<NDB_SHARE> util_open_tables; List<NDB_SHARE> util_open_tables;
Thd_ndb *thd_ndb;
my_thread_init(); my_thread_init();
DBUG_ENTER("ndb_util_thread"); DBUG_ENTER("ndb_util_thread");
...@@ -8340,17 +8321,15 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused))) ...@@ -8340,17 +8321,15 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
thd= new THD; /* note that contructor of THD uses DBUG_ */ thd= new THD; /* note that contructor of THD uses DBUG_ */
THD_CHECK_SENTRY(thd); THD_CHECK_SENTRY(thd);
ndb= new Ndb(g_ndb_cluster_connection, "");
pthread_detach_this_thread(); pthread_detach_this_thread();
ndb_util_thread= pthread_self(); ndb_util_thread= pthread_self();
thd->thread_stack= (char*)&thd; /* remember where our stack is */ thd->thread_stack= (char*)&thd; /* remember where our stack is */
if (thd->store_globals() || (ndb->init() != 0)) if (thd->store_globals())
{ {
thd->cleanup(); thd->cleanup();
delete thd; delete thd;
delete ndb;
DBUG_RETURN(NULL); DBUG_RETURN(NULL);
} }
thd->init_for_queries(); thd->init_for_queries();
...@@ -8392,16 +8371,14 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused))) ...@@ -8392,16 +8371,14 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
} }
pthread_mutex_unlock(&LOCK_ndb_util_thread); pthread_mutex_unlock(&LOCK_ndb_util_thread);
/* Get thd_ndb for this thread */
if (!(thd_ndb= ha_ndbcluster::seize_thd_ndb()))
{ {
Thd_ndb *thd_ndb; sql_print_error("Could not allocate Thd_ndb object");
if (!(thd_ndb= ha_ndbcluster::seize_thd_ndb())) goto ndb_util_thread_end;
{
sql_print_error("Could not allocate Thd_ndb object");
goto ndb_util_thread_end;
}
set_thd_ndb(thd, thd_ndb);
thd_ndb->options|= TNO_NO_LOG_SCHEMA_OP;
} }
set_thd_ndb(thd, thd_ndb);
thd_ndb->options|= TNO_NO_LOG_SCHEMA_OP;
#ifdef HAVE_NDB_BINLOG #ifdef HAVE_NDB_BINLOG
if (ndb_extra_logging && ndb_binlog_running) if (ndb_extra_logging && ndb_binlog_running)
...@@ -8485,22 +8462,22 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused))) ...@@ -8485,22 +8462,22 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
} }
#endif /* HAVE_NDB_BINLOG */ #endif /* HAVE_NDB_BINLOG */
DBUG_PRINT("ndb_util_thread", DBUG_PRINT("ndb_util_thread",
("Fetching commit count for: %s", ("Fetching commit count for: %s", share->key));
share->key));
/* Contact NDB to get commit count for table */
ndb->setDatabaseName(share->db);
struct Ndb_statistics stat; struct Ndb_statistics stat;
uint lock; uint lock;
pthread_mutex_lock(&share->mutex); pthread_mutex_lock(&share->mutex);
lock= share->commit_count_lock; lock= share->commit_count_lock;
pthread_mutex_unlock(&share->mutex); pthread_mutex_unlock(&share->mutex);
{ {
/* Contact NDB to get commit count for table */
Ndb* ndb= thd_ndb->ndb;
ndb->setDatabaseName(share->db);
Ndb_table_guard ndbtab_g(ndb->getDictionary(), share->table_name); Ndb_table_guard ndbtab_g(ndb->getDictionary(), share->table_name);
if (ndbtab_g.get_table() && if (ndbtab_g.get_table() &&
ndb_get_table_statistics(NULL, false, ndb, ndbtab_g.get_table(), &stat) == 0) ndb_get_table_statistics(NULL, false, ndb,
ndbtab_g.get_table(), &stat) == 0)
{ {
char buff[22], buff2[22]; char buff[22], buff2[22];
DBUG_PRINT("info", DBUG_PRINT("info",
...@@ -8556,7 +8533,6 @@ ndb_util_thread_end: ...@@ -8556,7 +8533,6 @@ ndb_util_thread_end:
net_end(&thd->net); net_end(&thd->net);
thd->cleanup(); thd->cleanup();
delete thd; delete thd;
delete ndb;
DBUG_PRINT("exit", ("ndb_util_thread")); DBUG_PRINT("exit", ("ndb_util_thread"));
my_thread_end(); my_thread_end();
pthread_exit(0); pthread_exit(0);
......
...@@ -762,7 +762,7 @@ TransporterFacade::init(Uint32 nodeId, const ndb_mgm_configuration* props) ...@@ -762,7 +762,7 @@ TransporterFacade::init(Uint32 nodeId, const ndb_mgm_configuration* props)
void void
TransporterFacade::for_each(NdbApiSignal* aSignal, LinearSectionPtr ptr[3]) TransporterFacade::for_each(NdbApiSignal* aSignal, LinearSectionPtr ptr[3])
{ {
DBUG_ENTER("TransporterFacade::connected"); DBUG_ENTER("TransporterFacade::for_each");
Uint32 sz = m_threads.m_statusNext.size(); Uint32 sz = m_threads.m_statusNext.size();
TransporterFacade::ThreadData::Object_Execute oe; TransporterFacade::ThreadData::Object_Execute oe;
for (Uint32 i = 0; i < sz ; i ++) for (Uint32 i = 0; i < sz ; i ++)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment