Loading sql/ha_ndbcluster.cc +16 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,16 @@ extern my_bool opt_ndb_optimized_node_selection; extern const char *opt_ndbcluster_connectstring; // ndb interface initialization/cleanup #ifdef __cplusplus extern "C" { #endif extern void ndb_init_internal(); extern void ndb_end_internal(); #ifdef __cplusplus } #endif const char *ndb_distribution_names[]= {"KEYHASH", "LINHASH", NullS}; TYPELIB ndb_distribution_typelib= { array_elements(ndb_distribution_names)-1, "", ndb_distribution_names, NULL }; Loading Loading @@ -6392,6 +6402,9 @@ static int ndbcluster_init() if (have_ndbcluster != SHOW_OPTION_YES) DBUG_RETURN(0); // nothing else to do // Initialize ndb interface ndb_init_internal(); // Set connectstring if specified if (opt_ndbcluster_connectstring != 0) DBUG_PRINT("connectstring", ("%s", opt_ndbcluster_connectstring)); Loading Loading @@ -6540,6 +6553,9 @@ static int ndbcluster_end(ha_panic_function type) delete g_ndb_cluster_connection; g_ndb_cluster_connection= NULL; // cleanup ndb interface ndb_end_internal(); pthread_mutex_destroy(&ndbcluster_mutex); pthread_mutex_destroy(&LOCK_ndb_util_thread); pthread_cond_destroy(&COND_ndb_util_thread); Loading sql/ha_ndbcluster_binlog.cc +18 −13 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ #include "slave.h" #include "ha_ndbcluster_binlog.h" #include "NdbDictionary.hpp" #include "ndb_cluster_connection.hpp" #include <util/NdbAutoPtr.hpp> #ifdef ndb_dynamite Loading Loading @@ -111,8 +112,7 @@ static NDB_SCHEMA_OBJECT *ndb_get_schema_object(const char *key, static void ndb_free_schema_object(NDB_SCHEMA_OBJECT **ndb_schema_object, bool have_lock); /* instantiated in storage/ndb/src/ndbapi/Ndbif.cpp */ extern Uint64 g_latest_trans_gci; static Uint64 *p_latest_trans_gci= 0; /* Global variables for holding the binlog_index table reference Loading Loading @@ -439,7 +439,7 @@ static void ndbcluster_binlog_wait(THD *thd) { DBUG_ENTER("ndbcluster_binlog_wait"); const char *save_info= thd ? thd->proc_info : 0; ulonglong wait_epoch= g_latest_trans_gci; ulonglong wait_epoch= *p_latest_trans_gci; int count= 30; if (thd) thd->proc_info= "Waiting for ndbcluster binlog update to " Loading Loading @@ -3284,6 +3284,7 @@ static void ndb_free_schema_object(NDB_SCHEMA_OBJECT **ndb_schema_object, DBUG_VOID_RETURN; } pthread_handler_t ndb_binlog_thread_func(void *arg) { THD *thd; /* needs to be first for thread_stack */ Loading @@ -3292,6 +3293,7 @@ pthread_handler_t ndb_binlog_thread_func(void *arg) Thd_ndb *thd_ndb=0; int ndb_update_binlog_index= 1; injector *inj= injector::instance(); #ifdef RUN_NDB_BINLOG_TIMER Timer main_timer; #endif Loading Loading @@ -3380,6 +3382,8 @@ pthread_handler_t ndb_binlog_thread_func(void *arg) */ injector_thd= thd; injector_ndb= i_ndb; p_latest_trans_gci= injector_ndb->get_ndb_cluster_connection().get_latest_trans_gci(); schema_ndb= s_ndb; ndb_binlog_thread_running= 1; if (opt_bin_log) Loading Loading @@ -3476,7 +3480,7 @@ pthread_handler_t ndb_binlog_thread_func(void *arg) "ndb_latest_handled_binlog_epoch: %u, while current epoch: %u. " "RESET MASTER should be issued. Resetting ndb_latest_handled_binlog_epoch.", (unsigned) ndb_latest_handled_binlog_epoch, (unsigned) schema_gci); g_latest_trans_gci= 0; *p_latest_trans_gci= 0; ndb_latest_handled_binlog_epoch= 0; ndb_latest_applied_binlog_epoch= 0; ndb_latest_received_binlog_epoch= 0; Loading @@ -3503,7 +3507,7 @@ pthread_handler_t ndb_binlog_thread_func(void *arg) } do_ndbcluster_binlog_close_connection= BCCC_running; for ( ; !((abort_loop || do_ndbcluster_binlog_close_connection) && ndb_latest_handled_binlog_epoch >= g_latest_trans_gci) && ndb_latest_handled_binlog_epoch >= *p_latest_trans_gci) && do_ndbcluster_binlog_close_connection != BCCC_restart; ) { #ifndef DBUG_OFF Loading @@ -3511,8 +3515,8 @@ pthread_handler_t ndb_binlog_thread_func(void *arg) { DBUG_PRINT("info", ("do_ndbcluster_binlog_close_connection: %d, " "ndb_latest_handled_binlog_epoch: %llu, " "g_latest_trans_gci: %llu", do_ndbcluster_binlog_close_connection, ndb_latest_handled_binlog_epoch, g_latest_trans_gci)); "*p_latest_trans_gci: %llu", do_ndbcluster_binlog_close_connection, ndb_latest_handled_binlog_epoch, *p_latest_trans_gci)); } #endif #ifdef RUN_NDB_BINLOG_TIMER Loading Loading @@ -3548,7 +3552,7 @@ pthread_handler_t ndb_binlog_thread_func(void *arg) } if ((abort_loop || do_ndbcluster_binlog_close_connection) && (ndb_latest_handled_binlog_epoch >= g_latest_trans_gci || (ndb_latest_handled_binlog_epoch >= *p_latest_trans_gci || !ndb_binlog_running)) break; /* Shutting down server */ Loading Loading @@ -3598,11 +3602,11 @@ pthread_handler_t ndb_binlog_thread_func(void *arg) { DBUG_PRINT("info", ("do_ndbcluster_binlog_close_connection= BCCC_restart")); do_ndbcluster_binlog_close_connection= BCCC_restart; if (ndb_latest_received_binlog_epoch < g_latest_trans_gci && ndb_binlog_running) if (ndb_latest_received_binlog_epoch < *p_latest_trans_gci && ndb_binlog_running) { sql_print_error("NDB Binlog: latest transaction in epoch %lld not in binlog " "as latest received epoch is %lld", g_latest_trans_gci, ndb_latest_received_binlog_epoch); *p_latest_trans_gci, ndb_latest_received_binlog_epoch); } } } Loading Loading @@ -3784,11 +3788,11 @@ pthread_handler_t ndb_binlog_thread_func(void *arg) { DBUG_PRINT("info", ("do_ndbcluster_binlog_close_connection= BCCC_restart")); do_ndbcluster_binlog_close_connection= BCCC_restart; if (ndb_latest_received_binlog_epoch < g_latest_trans_gci && ndb_binlog_running) if (ndb_latest_received_binlog_epoch < *p_latest_trans_gci && ndb_binlog_running) { sql_print_error("NDB Binlog: latest transaction in epoch %lld not in binlog " "as latest received epoch is %lld", g_latest_trans_gci, ndb_latest_received_binlog_epoch); *p_latest_trans_gci, ndb_latest_received_binlog_epoch); } } } Loading Loading @@ -3861,6 +3865,7 @@ pthread_handler_t ndb_binlog_thread_func(void *arg) /* don't mess with the injector_ndb anymore from other threads */ injector_thd= 0; injector_ndb= 0; p_latest_trans_gci= 0; schema_ndb= 0; pthread_mutex_unlock(&injector_mutex); thd->db= 0; // as not to try to free memory Loading Loading @@ -3960,7 +3965,7 @@ ndbcluster_show_status_binlog(THD* thd, stat_print_fn *stat_print, "latest_handled_binlog_epoch=%s, " "latest_applied_binlog_epoch=%s", llstr(ndb_latest_epoch, buff1), llstr(g_latest_trans_gci, buff2), llstr(*p_latest_trans_gci, buff2), llstr(ndb_latest_received_binlog_epoch, buff3), llstr(ndb_latest_handled_binlog_epoch, buff4), llstr(ndb_latest_applied_binlog_epoch, buff5)); Loading storage/ndb/include/ndbapi/Ndb.hpp +9 −0 Original line number Diff line number Diff line Loading @@ -1093,6 +1093,15 @@ public: ~Ndb(); #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL /** * The current ndb_cluster_connection get_ndb_cluster_connection. * * @return the current connection */ Ndb_cluster_connection& get_ndb_cluster_connection(); #endif #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL /** * The current catalog name can be fetched by getCatalogName. Loading storage/ndb/include/ndbapi/NdbTransaction.hpp +2 −1 Original line number Diff line number Diff line Loading @@ -735,6 +735,7 @@ private: Uint32 theTCConPtr; // Transaction Co-ordinator connection pointer. Uint64 theTransactionId; // theTransactionId of the transaction Uint32 theGlobalCheckpointId; // The gloabl checkpoint identity of the transaction Uint64 *p_latest_trans_gci; // Reference to latest gci for connection ConStatusType theStatus; // The status of the connection enum CompletionStatus { NotCompleted, Loading @@ -753,7 +754,7 @@ private: bool theTransactionIsStarted; bool theInUseState; bool theSimpleState; Uint8 m_abortOption; // Type of commit Uint8 m_abortOption; // Type of commi enum ListState { NotInList, Loading storage/ndb/include/ndbapi/ndb_cluster_connection.hpp +2 −0 Original line number Diff line number Diff line Loading @@ -114,6 +114,8 @@ public: void init_get_next_node(Ndb_cluster_connection_node_iter &iter); unsigned int get_next_node(Ndb_cluster_connection_node_iter &iter); Uint64 *get_latest_trans_gci(); #endif private: Loading Loading
sql/ha_ndbcluster.cc +16 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,16 @@ extern my_bool opt_ndb_optimized_node_selection; extern const char *opt_ndbcluster_connectstring; // ndb interface initialization/cleanup #ifdef __cplusplus extern "C" { #endif extern void ndb_init_internal(); extern void ndb_end_internal(); #ifdef __cplusplus } #endif const char *ndb_distribution_names[]= {"KEYHASH", "LINHASH", NullS}; TYPELIB ndb_distribution_typelib= { array_elements(ndb_distribution_names)-1, "", ndb_distribution_names, NULL }; Loading Loading @@ -6392,6 +6402,9 @@ static int ndbcluster_init() if (have_ndbcluster != SHOW_OPTION_YES) DBUG_RETURN(0); // nothing else to do // Initialize ndb interface ndb_init_internal(); // Set connectstring if specified if (opt_ndbcluster_connectstring != 0) DBUG_PRINT("connectstring", ("%s", opt_ndbcluster_connectstring)); Loading Loading @@ -6540,6 +6553,9 @@ static int ndbcluster_end(ha_panic_function type) delete g_ndb_cluster_connection; g_ndb_cluster_connection= NULL; // cleanup ndb interface ndb_end_internal(); pthread_mutex_destroy(&ndbcluster_mutex); pthread_mutex_destroy(&LOCK_ndb_util_thread); pthread_cond_destroy(&COND_ndb_util_thread); Loading
sql/ha_ndbcluster_binlog.cc +18 −13 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ #include "slave.h" #include "ha_ndbcluster_binlog.h" #include "NdbDictionary.hpp" #include "ndb_cluster_connection.hpp" #include <util/NdbAutoPtr.hpp> #ifdef ndb_dynamite Loading Loading @@ -111,8 +112,7 @@ static NDB_SCHEMA_OBJECT *ndb_get_schema_object(const char *key, static void ndb_free_schema_object(NDB_SCHEMA_OBJECT **ndb_schema_object, bool have_lock); /* instantiated in storage/ndb/src/ndbapi/Ndbif.cpp */ extern Uint64 g_latest_trans_gci; static Uint64 *p_latest_trans_gci= 0; /* Global variables for holding the binlog_index table reference Loading Loading @@ -439,7 +439,7 @@ static void ndbcluster_binlog_wait(THD *thd) { DBUG_ENTER("ndbcluster_binlog_wait"); const char *save_info= thd ? thd->proc_info : 0; ulonglong wait_epoch= g_latest_trans_gci; ulonglong wait_epoch= *p_latest_trans_gci; int count= 30; if (thd) thd->proc_info= "Waiting for ndbcluster binlog update to " Loading Loading @@ -3284,6 +3284,7 @@ static void ndb_free_schema_object(NDB_SCHEMA_OBJECT **ndb_schema_object, DBUG_VOID_RETURN; } pthread_handler_t ndb_binlog_thread_func(void *arg) { THD *thd; /* needs to be first for thread_stack */ Loading @@ -3292,6 +3293,7 @@ pthread_handler_t ndb_binlog_thread_func(void *arg) Thd_ndb *thd_ndb=0; int ndb_update_binlog_index= 1; injector *inj= injector::instance(); #ifdef RUN_NDB_BINLOG_TIMER Timer main_timer; #endif Loading Loading @@ -3380,6 +3382,8 @@ pthread_handler_t ndb_binlog_thread_func(void *arg) */ injector_thd= thd; injector_ndb= i_ndb; p_latest_trans_gci= injector_ndb->get_ndb_cluster_connection().get_latest_trans_gci(); schema_ndb= s_ndb; ndb_binlog_thread_running= 1; if (opt_bin_log) Loading Loading @@ -3476,7 +3480,7 @@ pthread_handler_t ndb_binlog_thread_func(void *arg) "ndb_latest_handled_binlog_epoch: %u, while current epoch: %u. " "RESET MASTER should be issued. Resetting ndb_latest_handled_binlog_epoch.", (unsigned) ndb_latest_handled_binlog_epoch, (unsigned) schema_gci); g_latest_trans_gci= 0; *p_latest_trans_gci= 0; ndb_latest_handled_binlog_epoch= 0; ndb_latest_applied_binlog_epoch= 0; ndb_latest_received_binlog_epoch= 0; Loading @@ -3503,7 +3507,7 @@ pthread_handler_t ndb_binlog_thread_func(void *arg) } do_ndbcluster_binlog_close_connection= BCCC_running; for ( ; !((abort_loop || do_ndbcluster_binlog_close_connection) && ndb_latest_handled_binlog_epoch >= g_latest_trans_gci) && ndb_latest_handled_binlog_epoch >= *p_latest_trans_gci) && do_ndbcluster_binlog_close_connection != BCCC_restart; ) { #ifndef DBUG_OFF Loading @@ -3511,8 +3515,8 @@ pthread_handler_t ndb_binlog_thread_func(void *arg) { DBUG_PRINT("info", ("do_ndbcluster_binlog_close_connection: %d, " "ndb_latest_handled_binlog_epoch: %llu, " "g_latest_trans_gci: %llu", do_ndbcluster_binlog_close_connection, ndb_latest_handled_binlog_epoch, g_latest_trans_gci)); "*p_latest_trans_gci: %llu", do_ndbcluster_binlog_close_connection, ndb_latest_handled_binlog_epoch, *p_latest_trans_gci)); } #endif #ifdef RUN_NDB_BINLOG_TIMER Loading Loading @@ -3548,7 +3552,7 @@ pthread_handler_t ndb_binlog_thread_func(void *arg) } if ((abort_loop || do_ndbcluster_binlog_close_connection) && (ndb_latest_handled_binlog_epoch >= g_latest_trans_gci || (ndb_latest_handled_binlog_epoch >= *p_latest_trans_gci || !ndb_binlog_running)) break; /* Shutting down server */ Loading Loading @@ -3598,11 +3602,11 @@ pthread_handler_t ndb_binlog_thread_func(void *arg) { DBUG_PRINT("info", ("do_ndbcluster_binlog_close_connection= BCCC_restart")); do_ndbcluster_binlog_close_connection= BCCC_restart; if (ndb_latest_received_binlog_epoch < g_latest_trans_gci && ndb_binlog_running) if (ndb_latest_received_binlog_epoch < *p_latest_trans_gci && ndb_binlog_running) { sql_print_error("NDB Binlog: latest transaction in epoch %lld not in binlog " "as latest received epoch is %lld", g_latest_trans_gci, ndb_latest_received_binlog_epoch); *p_latest_trans_gci, ndb_latest_received_binlog_epoch); } } } Loading Loading @@ -3784,11 +3788,11 @@ pthread_handler_t ndb_binlog_thread_func(void *arg) { DBUG_PRINT("info", ("do_ndbcluster_binlog_close_connection= BCCC_restart")); do_ndbcluster_binlog_close_connection= BCCC_restart; if (ndb_latest_received_binlog_epoch < g_latest_trans_gci && ndb_binlog_running) if (ndb_latest_received_binlog_epoch < *p_latest_trans_gci && ndb_binlog_running) { sql_print_error("NDB Binlog: latest transaction in epoch %lld not in binlog " "as latest received epoch is %lld", g_latest_trans_gci, ndb_latest_received_binlog_epoch); *p_latest_trans_gci, ndb_latest_received_binlog_epoch); } } } Loading Loading @@ -3861,6 +3865,7 @@ pthread_handler_t ndb_binlog_thread_func(void *arg) /* don't mess with the injector_ndb anymore from other threads */ injector_thd= 0; injector_ndb= 0; p_latest_trans_gci= 0; schema_ndb= 0; pthread_mutex_unlock(&injector_mutex); thd->db= 0; // as not to try to free memory Loading Loading @@ -3960,7 +3965,7 @@ ndbcluster_show_status_binlog(THD* thd, stat_print_fn *stat_print, "latest_handled_binlog_epoch=%s, " "latest_applied_binlog_epoch=%s", llstr(ndb_latest_epoch, buff1), llstr(g_latest_trans_gci, buff2), llstr(*p_latest_trans_gci, buff2), llstr(ndb_latest_received_binlog_epoch, buff3), llstr(ndb_latest_handled_binlog_epoch, buff4), llstr(ndb_latest_applied_binlog_epoch, buff5)); Loading
storage/ndb/include/ndbapi/Ndb.hpp +9 −0 Original line number Diff line number Diff line Loading @@ -1093,6 +1093,15 @@ public: ~Ndb(); #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL /** * The current ndb_cluster_connection get_ndb_cluster_connection. * * @return the current connection */ Ndb_cluster_connection& get_ndb_cluster_connection(); #endif #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL /** * The current catalog name can be fetched by getCatalogName. Loading
storage/ndb/include/ndbapi/NdbTransaction.hpp +2 −1 Original line number Diff line number Diff line Loading @@ -735,6 +735,7 @@ private: Uint32 theTCConPtr; // Transaction Co-ordinator connection pointer. Uint64 theTransactionId; // theTransactionId of the transaction Uint32 theGlobalCheckpointId; // The gloabl checkpoint identity of the transaction Uint64 *p_latest_trans_gci; // Reference to latest gci for connection ConStatusType theStatus; // The status of the connection enum CompletionStatus { NotCompleted, Loading @@ -753,7 +754,7 @@ private: bool theTransactionIsStarted; bool theInUseState; bool theSimpleState; Uint8 m_abortOption; // Type of commit Uint8 m_abortOption; // Type of commi enum ListState { NotInList, Loading
storage/ndb/include/ndbapi/ndb_cluster_connection.hpp +2 −0 Original line number Diff line number Diff line Loading @@ -114,6 +114,8 @@ public: void init_get_next_node(Ndb_cluster_connection_node_iter &iter); unsigned int get_next_node(Ndb_cluster_connection_node_iter &iter); Uint64 *get_latest_trans_gci(); #endif private: Loading