From: magnus.blaudd Date: September 21 2012 1:20pm Subject: bzr push into mysql-5.5-cluster-7.2 branch (magnus.blaudd:4006 to 4008) WL#6224 List-Archive: http://lists.mysql.com/commits/144829 Message-Id: <20120921132049.2296.92062.4008@wholphin.se.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 4008 magnus.blaudd@stripped 2012-09-21 WL#6224 Adapt MySQL Cluster to 5.6 - another refactoring step, create ndb_binlog_thread.cc and move constructro + destructor ther, the other parts are still to tangled up added: sql/ndb_util_thread.cc modified: sql/ha_ndbcluster.cc storage/ndb/CMakeLists.txt 4007 magnus.blaudd@stripped 2012-09-21 WL#6224 Adapt MySQL Cluster to 5.6 - refactoring step, make the binlog thread into a Ndb_component added: sql/ndb_binlog_thread.cc sql/ndb_binlog_thread.h modified: sql/ha_ndbcluster_binlog.cc storage/ndb/CMakeLists.txt 4006 magnus.blaudd@stripped 2012-09-21 [merge] Merge === modified file 'sql/ha_ndbcluster.cc' --- a/sql/ha_ndbcluster.cc 2012-09-19 07:09:57 +0000 +++ b/sql/ha_ndbcluster.cc 2012-09-21 13:19:24 +0000 @@ -14719,22 +14719,6 @@ ha_ndbcluster::update_table_comment( /** Utility thread main loop. */ -Ndb_util_thread::Ndb_util_thread() - : running(-1) -{ - pthread_mutex_init(&LOCK, MY_MUTEX_INIT_FAST); - pthread_cond_init(&COND, NULL); - pthread_cond_init(&COND_ready, NULL); -} - -Ndb_util_thread::~Ndb_util_thread() -{ - assert(running <= 0); - pthread_mutex_destroy(&LOCK); - pthread_cond_destroy(&COND); - pthread_cond_destroy(&COND_ready); -} - void Ndb_util_thread::do_run() { === modified file 'sql/ha_ndbcluster_binlog.cc' --- a/sql/ha_ndbcluster_binlog.cc 2012-09-13 12:04:27 +0000 +++ b/sql/ha_ndbcluster_binlog.cc 2012-09-21 13:15:00 +0000 @@ -64,6 +64,7 @@ void ndb_index_stat_restart(); #include "ndb_schema_object.h" #include "ndb_schema_dist.h" #include "ndb_repl_tab.h" +#include "ndb_binlog_thread.h" /* Timeout for syncing schema events between @@ -162,11 +163,12 @@ static int ndbcluster_binlog_inited= 0; */ static int ndbcluster_binlog_terminating= 0; +static Ndb_binlog_thread ndb_binlog_thread; + /* Mutex and condition used for interacting between client sql thread and injector thread */ -static pthread_t ndb_binlog_thread; static pthread_mutex_t injector_mutex; static pthread_cond_t injector_cond; @@ -802,6 +804,8 @@ int ndbcluster_binlog_end(THD *thd) pthread_mutex_destroy(&injector_mutex); pthread_cond_destroy(&injector_cond); pthread_mutex_destroy(&ndb_schema_share_mutex); + + ndb_binlog_thread.deinit(); } DBUG_RETURN(0); @@ -3910,8 +3914,6 @@ add_ndb_binlog_index_err: Functions for start, stop, wait for ndbcluster binlog thread *********************************************************************/ -pthread_handler_t ndb_binlog_thread_func(void *arg); - int ndbcluster_binlog_start() { DBUG_ENTER("ndbcluster_binlog_start"); @@ -3950,9 +3952,10 @@ int ndbcluster_binlog_start() pthread_cond_init(&injector_cond, NULL); pthread_mutex_init(&ndb_schema_share_mutex, MY_MUTEX_INIT_FAST); + ndb_binlog_thread.init(); + /* Create injector thread */ - if (pthread_create(&ndb_binlog_thread, &connection_attrib, - ndb_binlog_thread_func, 0)) + if (ndb_binlog_thread.start()) { DBUG_PRINT("error", ("Could not create ndb injector thread")); pthread_cond_destroy(&injector_cond); @@ -6602,8 +6605,8 @@ injectApplyStatusWriteRow(injector::tran extern ulong opt_ndb_report_thresh_binlog_epoch_slip; extern ulong opt_ndb_report_thresh_binlog_mem_usage; -pthread_handler_t -ndb_binlog_thread_func(void *arg) +void +Ndb_binlog_thread::do_run() { THD *thd; /* needs to be first for thread_stack */ Ndb *i_ndb= 0; @@ -6625,7 +6628,6 @@ ndb_binlog_thread_func(void *arg) /* Set up the Thread */ - my_thread_init(); DBUG_ENTER("ndb_binlog_thread"); thd= new THD; /* note that contructor of THD uses DBUG_ */ @@ -6648,9 +6650,7 @@ ndb_binlog_thread_func(void *arg) pthread_cond_signal(&injector_cond); DBUG_LEAVE; // Must match DBUG_ENTER() - my_thread_end(); - pthread_exit(0); - return NULL; // Avoid compiler warnings + return; } lex_start(thd); @@ -6672,7 +6672,6 @@ ndb_binlog_thread_func(void *arg) */ sql_print_information("Starting Cluster Binlog Thread"); - pthread_detach_this_thread(); thd->real_id= pthread_self(); mysql_mutex_lock(&LOCK_thread_count); threads.append(thd); @@ -7534,9 +7533,7 @@ restart_cluster_failure: DBUG_PRINT("exit", ("ndb_binlog_thread")); DBUG_LEAVE; // Must match DBUG_ENTER() - my_thread_end(); - pthread_exit(0); - return NULL; // Avoid compiler warnings + return; } bool === added file 'sql/ndb_binlog_thread.cc' --- a/sql/ndb_binlog_thread.cc 1970-01-01 00:00:00 +0000 +++ b/sql/ndb_binlog_thread.cc 2012-09-21 13:15:00 +0000 @@ -0,0 +1,26 @@ +/* + Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "ndb_binlog_thread.h" + +Ndb_binlog_thread::Ndb_binlog_thread() +{ +} + +Ndb_binlog_thread::~Ndb_binlog_thread() +{ +} === added file 'sql/ndb_binlog_thread.h' --- a/sql/ndb_binlog_thread.h 1970-01-01 00:00:00 +0000 +++ b/sql/ndb_binlog_thread.h 2012-09-21 13:15:00 +0000 @@ -0,0 +1,35 @@ +/* + Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef NDB_BINLOG_THREAD_H +#define NDB_BINLOG_THREAD_H + +#include "ndb_component.h" + +class Ndb_binlog_thread : public Ndb_component +{ +public: + Ndb_binlog_thread(); + virtual ~Ndb_binlog_thread(); + +private: + virtual int do_init() { return 0;} + virtual void do_run(); + virtual int do_deinit() { return 0;} +}; + +#endif === added file 'sql/ndb_util_thread.cc' --- a/sql/ndb_util_thread.cc 1970-01-01 00:00:00 +0000 +++ b/sql/ndb_util_thread.cc 2012-09-21 13:19:24 +0000 @@ -0,0 +1,34 @@ +/* + Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "ndb_util_thread.h" + +Ndb_util_thread::Ndb_util_thread() + : running(-1) +{ + pthread_mutex_init(&LOCK, MY_MUTEX_INIT_FAST); + pthread_cond_init(&COND, NULL); + pthread_cond_init(&COND_ready, NULL); +} + +Ndb_util_thread::~Ndb_util_thread() +{ + assert(running <= 0); + pthread_mutex_destroy(&LOCK); + pthread_cond_destroy(&COND); + pthread_cond_destroy(&COND_ready); +} === modified file 'storage/ndb/CMakeLists.txt' --- a/storage/ndb/CMakeLists.txt 2012-04-11 12:07:25 +0000 +++ b/storage/ndb/CMakeLists.txt 2012-09-21 13:19:24 +0000 @@ -90,6 +90,8 @@ SET(NDBCLUSTER_SOURCES ../../sql/ndb_local_schema.cc ../../sql/ndb_repl_tab.cc ../../sql/ndb_conflict.cc + ../../sql/ndb_binlog_thread.cc + ../../sql/ndb_util_thread.cc ) # Include directories used when building ha_ndbcluster No bundle (reason: useless for push emails).