From: Mikael Ronstrom Date: November 15 2012 11:43am Subject: bzr push into mysql-5.5-cluster-7.2 branch (mikael.ronstrom:4003 to 4008) List-Archive: http://lists.mysql.com/commits/145277 Message-Id: <201211151144.qAFBiRpr013539@dator6> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 4008 Mikael Ronstrom 2012-11-15 Added NdbMutex_Deinit for statically allocated mutexes modified: sql/ha_ndbcluster.cc sql/ha_ndbcluster_connection.cc sql/ha_ndbcluster_connection.h storage/ndb/include/portlib/NdbMutex.h storage/ndb/src/common/portlib/NdbMutex.c storage/ndb/src/ndbapi/TransporterFacade.cpp storage/ndb/src/ndbapi/ndb_cluster_connection.cpp 4007 Mikael Ronstrom 2012-11-12 Added comment for clarification modified: storage/ndb/src/ndbapi/TransporterFacade.cpp 4006 Mikael Ronstrom 2012-11-12 Removed unused and unnecessary functions modified: storage/ndb/src/ndbapi/TransporterFacade.cpp storage/ndb/src/ndbapi/TransporterFacade.hpp 4005 Mikael Ronstrom 2012-11-12 Moved mutex locks to make it clearer what is protected modified: storage/ndb/src/ndbapi/TransporterFacade.cpp 4004 Mikael Ronstrom 2012-11-12 Remove unneeded parameter modified: storage/ndb/src/ndbapi/TransporterFacade.cpp storage/ndb/src/ndbapi/TransporterFacade.hpp 4003 Mikael Ronstrom 2012-11-09 [merge] merge modified: storage/ndb/src/kernel/blocks/backup/Backup.cpp === modified file 'sql/ha_ndbcluster.cc' --- a/sql/ha_ndbcluster.cc revid:mikael.ronstrom@stripped +++ b/sql/ha_ndbcluster.cc revid:mikael.ronstrom@stripped @@ -11914,7 +11914,6 @@ static int ndbcluster_init(void *p) (global_opti_node_select & 1), opt_ndb_connectstring, opt_ndb_nodeid, - 1, opt_ndb_recv_thread_activation_threshold)) { DBUG_PRINT("error", ("Could not initiate connection to cluster")); @@ -17215,7 +17214,6 @@ void ndb_recv_thread_cpu_mask_update() { ndb_set_recv_thread_cpu(recv_thread_cpuid_array, - 1, recv_thread_num_cpus); } === modified file 'sql/ha_ndbcluster_connection.cc' --- a/sql/ha_ndbcluster_connection.cc revid:mikael.ronstrom@stripped +++ b/sql/ha_ndbcluster_connection.cc revid:mikael.ronstrom@stripped @@ -46,7 +46,6 @@ ndbcluster_connect(int (*connect_callbac bool optimized_node_select, const char* connect_string, uint force_nodeid, - uint num_recv_threads, uint recv_thread_activation_threshold) { NDB_TICKS end_time; @@ -79,7 +78,6 @@ ndbcluster_connect(int (*connect_callbac g_ndb_cluster_connection->set_name(buf); } g_ndb_cluster_connection->set_optimized_node_selection(optimized_node_select); - g_ndb_cluster_connection->set_num_recv_threads(num_recv_threads); g_ndb_cluster_connection->set_recv_thread_activation_threshold( recv_thread_activation_threshold); @@ -140,7 +138,6 @@ ndbcluster_connect(int (*connect_callbac g_pool[i]->set_name(buf); } g_pool[i]->set_optimized_node_selection(optimized_node_select); - g_pool[i]->set_num_recv_threads(num_recv_threads); g_pool[i]->set_recv_thread_activation_threshold(recv_thread_activation_threshold); } } @@ -307,20 +304,15 @@ int ndb_set_recv_thread_activation_thres int ndb_set_recv_thread_cpu(Uint16 *cpuid_array, - Uint32 num_recv_threads, Uint32 cpuid_array_size) { - Uint32 num_cpu_needed = num_recv_threads * g_pool_alloc; - Uint32 cpu_index = 0; + Uint32 num_cpu_needed = g_pool_alloc; if (cpuid_array_size == 0) { for (Uint32 i = 0; i < g_pool_alloc; i++) { - for (Uint32 j = 0; j < num_recv_threads; j++) - { - g_pool[i]->unset_recv_thread_cpu(j); - } + g_pool[i]->unset_recv_thread_cpu(0); } return 0; } @@ -336,13 +328,9 @@ ndb_set_recv_thread_cpu(Uint16 *cpuid_ar } for (Uint32 i = 0; i < g_pool_alloc; i++) { - for (Uint32 j = 0; j < num_recv_threads; j++) - { - g_pool[i]->set_recv_thread_cpu(&cpuid_array[cpu_index], - (Uint32)1, - j); - cpu_index++; - } + g_pool[i]->set_recv_thread_cpu(&cpuid_array[i], + (Uint32)1, + 0); } return 0; } === modified file 'sql/ha_ndbcluster_connection.h' --- a/sql/ha_ndbcluster_connection.h revid:mikael.ronstrom@stripped +++ b/sql/ha_ndbcluster_connection.h revid:mikael.ronstrom@stripped @@ -21,7 +21,6 @@ int ndbcluster_connect(int (*connect_cal bool optimized_node_select, const char* connect_string, uint force_nodeid, - uint num_recv_threads, uint recv_thread_activation_threshold); void ndbcluster_disconnect(void); @@ -32,7 +31,6 @@ void ndb_set_latest_trans_gci(ulonglong int ndb_has_node_id(uint id); int ndb_set_recv_thread_activation_threshold(Uint32 threshold); int ndb_set_recv_thread_cpu(Uint16 *cpuid_array, - Uint32 num_recv_threads, Uint32 cpuid_array_size); void ndb_get_connection_stats(Uint64* statsArr); === modified file 'storage/ndb/include/portlib/NdbMutex.h' --- a/storage/ndb/include/portlib/NdbMutex.h revid:mikael.ronstrom@stripped +++ b/storage/ndb/include/portlib/NdbMutex.h revid:mikael.ronstrom@stripped @@ -81,6 +81,7 @@ int NdbMutex_InitWithName(NdbMutex* p_mu * * returnvalue: 0 = succeeded, -1 = failed */ int NdbMutex_Destroy(NdbMutex* p_mutex); +int NdbMutex_Deinit(NdbMutex* p_mutex); /** * Lock a mutex === modified file 'storage/ndb/src/common/portlib/NdbMutex.c' --- a/storage/ndb/src/common/portlib/NdbMutex.c revid:mikael.ronstrom@stripped +++ b/storage/ndb/src/common/portlib/NdbMutex.c revid:mikael.ronstrom@stripped @@ -137,7 +137,7 @@ int NdbMutex_InitWithName(NdbMutex* pNdb DBUG_RETURN(result); } -int NdbMutex_Destroy(NdbMutex* p_mutex) +int NdbMutex_Deinit(NdbMutex* p_mutex) { int result; @@ -154,8 +154,17 @@ int NdbMutex_Destroy(NdbMutex* p_mutex) result = pthread_mutex_destroy(p_mutex); #endif - NdbMem_Free(p_mutex); + return result; +} +int NdbMutex_Destroy(NdbMutex* p_mutex) +{ + int result; + + if (p_mutex == NULL) + return -1; + result = NdbMutex_Deinit(p_mutex); + NdbMem_Free(p_mutex); return result; } === modified file 'storage/ndb/src/ndbapi/TransporterFacade.cpp' --- a/storage/ndb/src/ndbapi/TransporterFacade.cpp revid:mikael.ronstrom@stripped +++ b/storage/ndb/src/ndbapi/TransporterFacade.cpp revid:mikael.ronstrom@stripped @@ -486,7 +486,7 @@ link_buffer(TFBuffer* dst, const TFBuffe static const Uint32 SEND_THREAD_NO = 0; void -TransporterFacade::wakeup_send_thread(Uint32 node) +TransporterFacade::wakeup_send_thread(void) { Guard g(m_send_thread_mutex); if (m_send_thread_nodes.get(SEND_THREAD_NO) == false) @@ -506,9 +506,9 @@ void TransporterFacade::threadMainSend(v m_socket_server.startServer(); - NdbMutex_Lock(m_send_thread_mutex); while(!theStopReceive) { + NdbMutex_Lock(m_send_thread_mutex); if (m_send_thread_nodes.get(SEND_THREAD_NO) == false) { NdbCondition_WaitTimeout(m_send_thread_cond, @@ -560,9 +560,7 @@ void TransporterFacade::threadMainSend(v } } while (!theStopReceive && all_empty == false); - NdbMutex_Lock(m_send_thread_mutex); } - NdbMutex_Unlock(m_send_thread_mutex); theTransporterRegistry->stopSending(); m_socket_server.stopServer(); @@ -658,18 +656,6 @@ TransporterFacade::become_poll_owner(trp } int -TransporterFacade::set_num_recv_threads(Uint32 num_recv_threads) -{ - return -1; -} - -int -TransporterFacade::get_num_recv_threads() const -{ - return 1; -} - -int TransporterFacade::unset_recv_thread_cpu(Uint32 recv_thread_id) { if (recv_thread_id != 0) @@ -764,6 +750,8 @@ void TransporterFacade::threadMainReceiv /* We only take the step to become poll owner in receive thread if we are sufficiently active, at least e.g. 16 threads active. + We check this condition without mutex, there is no issue with + what we select here, both paths will work. */ if (m_num_active_clients > min_active_clients_recv_thread) { @@ -1210,6 +1198,10 @@ TransporterFacade::~TransporterFacade() NdbMutex_Lock(thePollMutex); delete theTransporterRegistry; NdbMutex_Unlock(thePollMutex); + for (Uint32 i = 0; i < NDB_ARRAY_SIZE(m_send_buffers); i++) + { + NdbMutex_Deinit(&m_send_buffers[i].m_mutex); + } NdbMutex_Destroy(thePollMutex); NdbMutex_Destroy(m_open_close_mutex); NdbMutex_Destroy(m_send_thread_mutex); @@ -2595,7 +2587,7 @@ TransporterFacade::flush_and_send_buffer if (wake) { - wakeup_send_thread(node); + wakeup_send_thread(); } } === modified file 'storage/ndb/src/ndbapi/TransporterFacade.hpp' --- a/storage/ndb/src/ndbapi/TransporterFacade.hpp revid:mikael.ronstrom@stripped +++ b/storage/ndb/src/ndbapi/TransporterFacade.hpp revid:mikael.ronstrom@stripped @@ -184,8 +184,6 @@ public: interface. */ #define NO_RECV_THREAD_CPU_ID 0xFFFF - int set_num_recv_threads(Uint32 num_recv_threads); - int get_num_recv_threads() const; int unset_recv_thread_cpu(Uint32 recv_thread_id); int set_recv_thread_cpu(Uint16 *cpuid_array, Uint32 array_len, @@ -380,7 +378,7 @@ private: TFBuffer m_out_buffer; } m_send_buffers[MAX_NODES]; - void wakeup_send_thread(Uint32 node); + void wakeup_send_thread(void); NdbMutex * m_send_thread_mutex; NdbCondition * m_send_thread_cond; NodeBitmask m_send_thread_nodes; === modified file 'storage/ndb/src/ndbapi/ndb_cluster_connection.cpp' --- a/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp revid:mikael.ronstrom@stripped +++ b/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp revid:mikael.ronstrom@stripped @@ -92,26 +92,6 @@ const char *Ndb_cluster_connection::get_ } int -Ndb_cluster_connection::set_num_recv_threads(Uint32 num_recv_threads) -{ - if (m_impl.m_transporter_facade) - { - return m_impl.m_transporter_facade->set_num_recv_threads(num_recv_threads); - } - return -1; -} - -int -Ndb_cluster_connection::get_num_recv_threads() const -{ - if (m_impl.m_transporter_facade) - { - return m_impl.m_transporter_facade->get_num_recv_threads(); - } - return -1; -} - -int Ndb_cluster_connection::unset_recv_thread_cpu(Uint32 recv_thread_id) { if (m_impl.m_transporter_facade) No bundle (reason: useless for push emails).