Below is the list of changes that have just been committed into a local
5.1 repository of stewart. When stewart does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.1840 05/04/06 01:12:15 stewart@stripped +1 -0
hand fix merge conflict
sql/ha_ndbcluster.cc
1.192 05/04/06 01:12:09 stewart@stripped +2 -8
hand fix merge conflict
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: stewart
# Host: kennedy.(none)
# Root: /home/stewart/Documents/MySQL/5.1/ndb-wl2325/RESYNC
--- 1.191/sql/ha_ndbcluster.cc 2005-04-05 11:41:10 +10:00
+++ 1.192/sql/ha_ndbcluster.cc 2005-04-06 01:12:09 +10:00
@@ -98,7 +98,7 @@
static byte *ndbcluster_get_key(NDB_SHARE *share,uint *length,
my_bool not_used __attribute__((unused)));
-static NDB_SHARE *get_share(const char *table_name);
+static NDB_SHARE *get_share(const char *table_name, bool create_if_not_exists= 1);
static void free_share(NDB_SHARE *share);
static int packfrm(const void *data, uint len, const void **pack_data, uint *pack_len);
@@ -138,7 +138,7 @@
extern "C" pthread_handler_decl(ndb_injector_thread_func, arg);
pthread_mutex_t injector_startup_mutex;
-pthread_cond_t injector_startup_cond;
+pthread_cond_t injector_cond;
static int ndb_injector_thread_running= 0;
/**
@@ -4138,6 +4138,37 @@
ndb_rep_event_name(&event_name,m_dbname,m_tabname);
if ( ndbcluster_drop_event(ndb,0/* ToDo */,event_name.c_ptr()) < 0 )
; /* ToDo; handle error? */
+
+ char name[FN_REFLEN];
+ (void)strxnmov(name, FN_REFLEN, "./",m_dbname,"/",m_tabname,NullS);
+ NDB_SHARE *share= get_share(name,false);
+ if (share)
+ {
+ int max_timeout= 10;
+ (void) pthread_mutex_lock(&share->mutex);
+ while (share->op && max_timeout)
+ {
+ struct timespec abstime;
+ set_timespec(abstime, 1);
+ sql_print_information("NDB delete table: waiting max %u sec for drop table %s.",
+ max_timeout, name);
+ (void) pthread_cond_timedwait(&injector_cond,
+ &share->mutex,
+ &abstime);
+ max_timeout--;
+ }
+ (void) pthread_mutex_unlock(&share->mutex);
+ free_share(share);
+ if (max_timeout == 0)
+ {
+ sql_print_error("NDB delete table: timed out. Ignoring...");
+ // ToDo: handle possible mem leak if cluter goes down and share is not freed...
+ }
+ }
+ else
+ {
+ sql_print_error("NDB delete table: share does not exist for %s. Ignoring...", name);
+ }
}
#endif /* HAVE_REPLICATION */
@@ -4783,7 +4814,7 @@
if (opt_bin_log)
{
pthread_mutex_init(&injector_startup_mutex,MY_MUTEX_INIT_FAST);
- pthread_cond_init(&injector_startup_cond,NULL);
+ pthread_cond_init(&injector_cond,NULL);
// Create injector thread
@@ -4791,7 +4822,7 @@
ndb_injector_thread_func, 0))
{
DBUG_PRINT("error", ("Could not create ndb injector thread"));
- pthread_cond_destroy(&injector_startup_cond);
+ pthread_cond_destroy(&injector_cond);
pthread_mutex_destroy(&injector_startup_mutex);
goto ndbcluster_init_error;
}
@@ -4801,10 +4832,9 @@
*/
pthread_mutex_lock(&injector_startup_mutex);
while(!ndb_injector_thread_running)
- pthread_cond_wait(&injector_startup_cond,&injector_startup_mutex);
+ pthread_cond_wait(&injector_cond,&injector_startup_mutex);
pthread_mutex_unlock(&injector_startup_mutex);
- pthread_cond_destroy(&injector_startup_cond);
pthread_mutex_destroy(&injector_startup_mutex);
if(ndb_injector_thread_running<0)
@@ -4873,6 +4903,7 @@
DBUG_PRINT("info",("pthread_join(ndb_injector_thread, NULL) %d", r));
DBUG_PRINT("info",("%d %d %d", ESRCH, EINVAL, EDEADLK));
}
+ pthread_cond_destroy(&injector_cond);
ndb_injector_thread_running= 0;
}
#endif /* HAVE_REPLICATION */
@@ -5303,7 +5334,7 @@
return (byte*) share->table_name;
}
-static NDB_SHARE* get_share(const char *table_name)
+static NDB_SHARE* get_share(const char *table_name, bool create_if_not_exists)
{
NDB_SHARE *share;
pthread_mutex_lock(&ndbcluster_mutex);
@@ -5312,6 +5343,12 @@
(byte*) table_name,
length)))
{
+ if (!create_if_not_exists)
+ {
+ DBUG_PRINT("error", ("Share for %s does not exist", table_name));
+ pthread_mutex_unlock(&ndbcluster_mutex);
+ return 0;
+ }
if ((share=(NDB_SHARE *) my_malloc(sizeof(*share)+length+1,
MYF(MY_WME | MY_ZEROFILL))))
{
@@ -7341,9 +7378,14 @@
{
DBUG_ENTER("ndbcluster_drop_event_ops");
- NDB_SHARE *share= get_share(db_tab);
- pthread_mutex_lock(&share->mutex);
+ NDB_SHARE *share= get_share(db_tab,false);
+ if (share == 0)
+ {
+ DBUG_RETURN(-1);
+ }
+
+ pthread_mutex_lock(&share->mutex);
if (share->op)
{
sql_print_information("NDB Replication: Drop table %s",
@@ -7406,7 +7448,7 @@
delete thd;
ndb_injector_thread_running= -1;
pthread_mutex_unlock(&injector_startup_mutex);
- pthread_cond_signal(&injector_startup_cond);
+ pthread_cond_signal(&injector_cond);
my_thread_end();
pthread_exit(0);
DBUG_RETURN(NULL);
@@ -7423,7 +7465,7 @@
sql_print_error("NDB Replication: Getting Ndb object failed");
ndb_injector_thread_running= -1;
pthread_mutex_unlock(&injector_startup_mutex);
- pthread_cond_signal(&injector_startup_cond);
+ pthread_cond_signal(&injector_cond);
goto err;
}
@@ -7438,7 +7480,7 @@
* starting up.
*/
pthread_mutex_unlock(&injector_startup_mutex);
- pthread_cond_signal(&injector_startup_cond);
+ pthread_cond_signal(&injector_cond);
/**
* Main NDB Injector loop
@@ -7540,25 +7582,43 @@
if ( pOp->getEventType() == NdbDictionary::Event::TE_DROP )
{
- ndb->dropEventOperation(pOp);
char name[FN_REFLEN];
(void)strxnmov(name, FN_REFLEN, "./",table->getMysqlName(),NullS);
- NDB_SHARE *share= get_share(name);
- sql_print_information("NDB Replication: drop table %s. ", name);
- DBUG_PRINT("info",("TABLE DROP EVENT: %s received op: %x dahare op: %x",
- name, pOp, share->op));
- assert(share->op == pOp);
- share->op= 0;
- free_share(share);
- // extra for the previous lock
- free_share(share);
+
+ sql_print_information("NDB Replication: drop table %s.", name);
+
+ ndb->dropEventOperation(pOp);
+
+ NDB_SHARE *share= get_share(name, false);
+ DBUG_ASSERT(share != 0);
+
+ if (share)
+ {
+ (void) pthread_mutex_lock(&share->mutex);
+ DBUG_PRINT("info",("TABLE DROP EVENT: %s received op: %x dahare op: %x",
+ name, pOp, share->op));
+ assert(share->op == pOp);
+ share->op= 0;
+ // Signal ha_ndbcluster::delete_table that drop is done
+ (void) pthread_cond_signal(&injector_cond);
+ (void) pthread_mutex_unlock(&share->mutex);
+
+ free_share(share);
+ // extra for the previous lock
+ free_share(share);
+ }
+ else
+ {
+ sql_print_error("NDB Replication: share does not exist for %s. Ignoring...", name);
+ }
continue;
}
String db_tab(200);
db_tab.append("./");
db_tab.append(table->getMysqlName());
- NDB_SHARE *share= get_share(db_tab.c_ptr()); // remember to free share
+ NDB_SHARE *share= get_share(db_tab.c_ptr(),false); // remember to free share
+ DBUG_ASSERT(share != 0);
#ifndef DISABLE_INJECTOR
byte* row_buf= new byte[share->table->s->rec_buff_length];
byte* field_buf= NULL;
@@ -7614,14 +7674,11 @@
int res;
DBUG_PRINT("info",("INSERT INTO %s (%s)",table->getName(),col_names.c_ptr()));
#ifndef DISABLE_INJECTOR
- injector::transaction::table
- tbl(share->table->s->db,table->getName());
- bitvector b(i);
- b.set_all();
- res= trans.write_row(::server_id, tbl, b,row_buf);
- DBUG_PRINT("info",("WRITE_ROW: %d",res));
+ injector::transaction::table tbl(share->table);
+ bitvector cols(i,true);
+ res= trans.write_row(::server_id, tbl, cols, row_buf);
+ DBUG_PRINT("info",("WRITE_ROW: %d", res));
#endif
- }
break;
case NdbDictionary::Event::TE_DELETE:
DBUG_PRINT("info",("DELETE FROM %s",table->getName()));
| Thread |
|---|
| • bk commit into 5.1 tree (stewart:1.1840) | Stewart Smith | 5 Apr |