===== sql/ha_ndbcluster_binlog.cc 1.95 vs edited ===== --- 1.95/sql/ha_ndbcluster_binlog.cc 2006-12-31 07:04:56 +07:00 +++ edited/sql/ha_ndbcluster_binlog.cc 2007-02-02 13:39:16 +07:00 @@ -1271,6 +1271,16 @@ int no_storage_nodes= g_ndb_cluster_connection->no_db_nodes(); bitmap_init(&schema_subscribers, bitbuf, sizeof(bitbuf)*8, FALSE); bitmap_set_all(&schema_subscribers); + + /* begin protect ndb_schema_share */ + pthread_mutex_lock(&injector_mutex); + if (ndb_schema_share == 0) + { + pthread_mutex_unlock(&injector_mutex); + if (ndb_schema_object) + ndb_free_schema_object(&ndb_schema_object, FALSE); + DBUG_RETURN(0); + } (void) pthread_mutex_lock(&ndb_schema_share->mutex); for (i= 0; i < no_storage_nodes; i++) { @@ -1283,6 +1293,9 @@ } } (void) pthread_mutex_unlock(&ndb_schema_share->mutex); + pthread_mutex_unlock(&injector_mutex); + /* end protect ndb_schema_share */ + if (updated) { bitmap_clear_bit(&schema_subscribers, node_id); @@ -1478,6 +1491,14 @@ &abstime); if (thd->killed) break; + + /* begin protect ndb_schema_share */ + pthread_mutex_lock(&injector_mutex); + if (ndb_schema_share == 0) + { + pthread_mutex_unlock(&injector_mutex); + break; + } (void) pthread_mutex_lock(&ndb_schema_share->mutex); for (i= 0; i < no_storage_nodes; i++) { @@ -1487,6 +1508,8 @@ bitmap_intersect(&schema_subscribers, tmp); } (void) pthread_mutex_unlock(&ndb_schema_share->mutex); + pthread_mutex_unlock(&injector_mutex); + /* end protect ndb_schema_share */ /* remove any unsubscribed from ndb_schema_object->slock */ bitmap_intersect(&ndb_schema_object->slock_bitmap, &schema_subscribers); @@ -1910,8 +1933,14 @@ ndb_binlog_tables_inited && ndb_binlog_running) sql_print_information("NDB Binlog: ndb tables initially " "read only on reconnect."); + + /* begin protect ndb_schema_share */ + pthread_mutex_lock(&injector_mutex); free_share(&ndb_schema_share); ndb_schema_share= 0; + pthread_mutex_unlock(&injector_mutex); + /* end protect ndb_schema_share */ + close_cached_tables((THD*) 0, 0, (TABLE_LIST*) 0, FALSE); // fall through case NDBEVENT::TE_ALTER: @@ -3966,9 +3995,13 @@ } if (ndb_schema_share) { + /* begin protect ndb_schema_share */ + pthread_mutex_lock(&injector_mutex); free_share(&ndb_schema_share); ndb_schema_share= 0; + pthread_mutex_unlock(&injector_mutex); + /* end protect ndb_schema_share */ } /* remove all event operations */