Below is the list of changes that have just been committed into a local
5.1 repository of jonas. When jonas 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@stripped, 2007-01-04 15:30:18+01:00, jonas@stripped +10 -0
ndb - fix a bunch of static variable for multi cluster support
(mysql-5.1-wl2325-5.0)
sql/ha_ndbcluster.cc@stripped, 2007-01-04 15:30:16+01:00, jonas@stripped +13 -0
start using new ndb_init method
storage/ndb/include/transporter/TransporterRegistry.hpp@stripped, 2007-01-04 15:30:16+01:00, jonas@stripped +1 -0
remove static variable
storage/ndb/src/common/transporter/Packer.cpp@stripped, 2007-01-04 15:30:16+01:00, jonas@stripped +2 -2
remove static variable
storage/ndb/src/common/transporter/TransporterRegistry.cpp@stripped, 2007-01-04 15:30:16+01:00, jonas@stripped +7 -7
remove static variable
storage/ndb/src/common/util/ndb_init.c@stripped, 2007-01-04 15:30:16+01:00, jonas@stripped +20 -0
start using new ndb_init method
storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp@stripped, 2007-01-04 15:30:16+01:00, jonas@stripped +0 -39
remove static variable
storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp@stripped, 2007-01-04 15:30:16+01:00, jonas@stripped +5 -23
remove static variable
storage/ndb/src/ndbapi/NdbEventOperationImpl.hpp@stripped, 2007-01-04 15:30:16+01:00, jonas@stripped +1 -1
remove static variable
storage/ndb/src/ndbapi/ndb_cluster_connection.cpp@stripped, 2007-01-04 15:30:16+01:00, jonas@stripped +56 -6
remove static variable
storage/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp@stripped, 2007-01-04 15:30:16+01:00, jonas@stripped +4 -0
remove static variable
# 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: jonas
# Host: perch.ndb.mysql.com
# Root: /home/jonas/src/mysql-5.1-wl2325-5.0
--- 1.22/storage/ndb/include/transporter/TransporterRegistry.hpp 2007-01-04 15:30:22 +01:00
+++ 1.23/storage/ndb/include/transporter/TransporterRegistry.hpp 2007-01-04 15:30:22 +01:00
@@ -361,6 +361,7 @@
Uint32 poll_SHM(Uint32 timeOutMillis);
int m_shm_own_pid;
+ int m_transp_count;
};
#endif // Define of TransporterRegistry_H
--- 1.7/storage/ndb/src/common/transporter/Packer.cpp 2007-01-04 15:30:22 +01:00
+++ 1.8/storage/ndb/src/common/transporter/Packer.cpp 2007-01-04 15:30:22 +01:00
@@ -213,8 +213,8 @@
Uint32 * eodPtr,
NodeId remoteNodeId,
IOState state) {
- static SignalHeader signalHeader;
- static LinearSectionPtr ptr[3];
+ SignalHeader signalHeader;
+ LinearSectionPtr ptr[3];
Uint32 loop_count = 0;
if(state == NoHalt || state == HaltOutput){
while ((readPtr < eodPtr) && (loop_count < MAX_RECEIVED_SIGNALS)) {
--- 1.63/storage/ndb/src/common/transporter/TransporterRegistry.cpp 2007-01-04 15:30:22 +01:00
+++ 1.64/storage/ndb/src/common/transporter/TransporterRegistry.cpp 2007-01-04 15:30:22 +01:00
@@ -80,14 +80,15 @@
TransporterRegistry::TransporterRegistry(void * callback,
unsigned _maxTransporters,
- unsigned sizeOfLongSignalMemory)
+ unsigned sizeOfLongSignalMemory) :
+ m_mgm_handle(0),
+ m_transp_count(0)
{
DBUG_ENTER("TransporterRegistry::TransporterRegistry");
nodeIdSpecified = false;
maxTransporters = _maxTransporters;
sendCounter = 1;
- m_mgm_handle= 0;
callbackObj=callback;
@@ -1002,7 +1003,6 @@
#endif
}
-static int x = 0;
void
TransporterRegistry::performSend()
{
@@ -1070,7 +1070,7 @@
}
#endif
#ifdef NDB_TCP_TRANSPORTER
- for (i = x; i < nTCPTransporters; i++)
+ for (i = m_transp_count; i < nTCPTransporters; i++)
{
TCP_Transporter *t = theTCPTransporters[i];
if (t && t->hasDataToSend() && t->isConnected() &&
@@ -1079,7 +1079,7 @@
t->doSend();
}
}
- for (i = 0; i < x && i < nTCPTransporters; i++)
+ for (i = 0; i < m_transp_count && i < nTCPTransporters; i++)
{
TCP_Transporter *t = theTCPTransporters[i];
if (t && t->hasDataToSend() && t->isConnected() &&
@@ -1088,8 +1088,8 @@
t->doSend();
}
}
- x++;
- if (x == nTCPTransporters) x = 0;
+ m_transp_count++;
+ if (m_transp_count == nTCPTransporters) m_transp_count = 0;
#endif
#endif
#ifdef NDB_SCI_TRANSPORTER
--- 1.95/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp 2007-01-04 15:30:22 +01:00
+++ 1.96/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp 2007-01-04 15:30:22 +01:00
@@ -740,8 +740,6 @@
m_local_table_data_size= 0;
}
-static int f_dictionary_count = 0;
-
NdbDictionaryImpl::~NdbDictionaryImpl()
{
NdbElement_t<Ndb_local_table_info> * curr = m_localHash.m_tableHash.getNext(0);
@@ -754,25 +752,6 @@
curr = m_localHash.m_tableHash.getNext(curr);
}
-
- m_globalHash->lock();
- if(--f_dictionary_count == 0){
- delete NdbDictionary::Column::FRAGMENT;
- delete NdbDictionary::Column::FRAGMENT_MEMORY;
- delete NdbDictionary::Column::ROW_COUNT;
- delete NdbDictionary::Column::COMMIT_COUNT;
- delete NdbDictionary::Column::ROW_SIZE;
- delete NdbDictionary::Column::RANGE_NO;
- delete NdbDictionary::Column::RECORDS_IN_RANGE;
- NdbDictionary::Column::FRAGMENT= 0;
- NdbDictionary::Column::FRAGMENT_MEMORY= 0;
- NdbDictionary::Column::ROW_COUNT= 0;
- NdbDictionary::Column::COMMIT_COUNT= 0;
- NdbDictionary::Column::ROW_SIZE= 0;
- NdbDictionary::Column::RANGE_NO= 0;
- NdbDictionary::Column::RECORDS_IN_RANGE= 0;
- }
- m_globalHash->unlock();
} else {
assert(curr == 0);
}
@@ -829,24 +808,6 @@
{
m_globalHash = &tf->m_globalDictCache;
if(m_receiver.setTransporter(ndb, tf)){
- m_globalHash->lock();
- if(f_dictionary_count++ == 0){
- NdbDictionary::Column::FRAGMENT=
- NdbColumnImpl::create_pseudo("NDB$FRAGMENT");
- NdbDictionary::Column::FRAGMENT_MEMORY=
- NdbColumnImpl::create_pseudo("NDB$FRAGMENT_MEMORY");
- NdbDictionary::Column::ROW_COUNT=
- NdbColumnImpl::create_pseudo("NDB$ROW_COUNT");
- NdbDictionary::Column::COMMIT_COUNT=
- NdbColumnImpl::create_pseudo("NDB$COMMIT_COUNT");
- NdbDictionary::Column::ROW_SIZE=
- NdbColumnImpl::create_pseudo("NDB$ROW_SIZE");
- NdbDictionary::Column::RANGE_NO=
- NdbColumnImpl::create_pseudo("NDB$RANGE_NO");
- NdbDictionary::Column::RECORDS_IN_RANGE=
- NdbColumnImpl::create_pseudo("NDB$RECORDS_IN_RANGE");
- }
- m_globalHash->unlock();
return true;
}
return false;
--- 1.25/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp 2007-01-04 15:30:22 +01:00
+++ 1.26/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp 2007-01-04 15:30:22 +01:00
@@ -530,9 +530,6 @@
* Each Ndb object has a Object.
*/
-// ToDo ref count this so it get's destroyed
-NdbMutex *NdbEventBuffer::p_add_drop_mutex= 0;
-
NdbEventBuffer::NdbEventBuffer(Ndb *ndb) :
m_system_nodes(ndb->theImpl->theNoOfDBnodes),
m_ndb(ndb),
@@ -554,16 +551,9 @@
exit(-1);
}
m_mutex= ndb->theImpl->theWaiter.m_mutex;
- lock();
- if (p_add_drop_mutex == 0)
- {
- if ((p_add_drop_mutex = NdbMutex_Create()) == NULL) {
- ndbout_c("NdbEventBuffer: NdbMutex_Create() failed");
- exit(-1);
- }
- }
- unlock();
-
+ m_add_drop_mutex =
+ m_ndb->theImpl->m_ndb_cluster_connection.m_event_add_drop_mutex;
+
// ToDo set event buffer size
// pre allocate event data array
m_sz= 0;
@@ -602,14 +592,6 @@
}
NdbCondition_Destroy(p_cond);
-
- lock();
- if (p_add_drop_mutex)
- {
- NdbMutex_Destroy(p_add_drop_mutex);
- p_add_drop_mutex = 0;
- }
- unlock();
}
void
@@ -780,12 +762,12 @@
void
NdbEventBuffer::add_drop_lock()
{
- NdbMutex_Lock(p_add_drop_mutex);
+ NdbMutex_Lock(m_add_drop_mutex);
}
void
NdbEventBuffer::add_drop_unlock()
{
- NdbMutex_Unlock(p_add_drop_mutex);
+ NdbMutex_Unlock(m_add_drop_mutex);
}
static
--- 1.9/storage/ndb/src/ndbapi/NdbEventOperationImpl.hpp 2007-01-04 15:30:22 +01:00
+++ 1.10/storage/ndb/src/ndbapi/NdbEventOperationImpl.hpp 2007-01-04 15:30:22 +01:00
@@ -243,7 +243,7 @@
void reportStatus();
// Global Mutex used for some things
- static NdbMutex *p_add_drop_mutex;
+ NdbMutex *m_add_drop_mutex;
#ifdef VM_TRACE
const char *m_latest_command;
--- 1.251/sql/ha_ndbcluster.cc 2007-01-04 15:30:22 +01:00
+++ 1.252/sql/ha_ndbcluster.cc 2007-01-04 15:30:22 +01:00
@@ -38,6 +38,15 @@
#include "slave.h"
#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+ extern void ndb_init_internal();
+ extern void ndb_end_internal();
+#ifdef __cplusplus
+}
+#endif
+
// options from from mysqld.cc
extern my_bool opt_ndb_optimized_node_selection;
extern enum ndb_distribution opt_ndb_distribution_id;
@@ -5368,6 +5377,8 @@
if (have_ndbcluster != SHOW_OPTION_YES)
goto ndbcluster_init_error;
+ ndb_init_internal();
+
// Set connectstring if specified
if (opt_ndbcluster_connectstring != 0)
DBUG_PRINT("connectstring", ("%s", opt_ndbcluster_connectstring));
@@ -5510,6 +5521,7 @@
if (g_ndb_cluster_connection)
delete g_ndb_cluster_connection;
g_ndb_cluster_connection= NULL;
+ ndb_end_internal();
have_ndbcluster= SHOW_OPTION_DISABLED; // If we couldn't use handler
DBUG_RETURN(TRUE);
}
@@ -5582,6 +5594,7 @@
if (g_ndb_cluster_connection)
delete g_ndb_cluster_connection;
g_ndb_cluster_connection= NULL;
+ ndb_end_internal();
hash_free(&ndbcluster_open_tables);
pthread_mutex_destroy(&ndbcluster_mutex);
--- 1.3/storage/ndb/src/common/util/ndb_init.c 2007-01-04 15:30:22 +01:00
+++ 1.4/storage/ndb/src/common/util/ndb_init.c 2007-01-04 15:30:22 +01:00
@@ -16,6 +16,24 @@
#include <ndb_global.h>
#include <my_sys.h>
+#include <NdbMutex.h>
+
+NdbMutex *g_ndb_init_mutex = NULL;
+
+void
+ndb_init_internal()
+{
+ if (g_ndb_init_mutex == 0)
+ g_ndb_init_mutex = NdbMutex_Create();
+}
+
+void
+ndb_end_internal()
+{
+ if (g_ndb_init_mutex)
+ NdbMutex_Destroy(g_ndb_init_mutex);
+}
+
int
ndb_init()
@@ -25,11 +43,13 @@
write(2, err, strlen(err));
exit(1);
}
+ ndb_init_internal();
return 0;
}
void
ndb_end(int flags)
{
+ ndb_end_internal();
my_end(flags);
}
--- 1.37/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp 2007-01-04 15:30:22 +01:00
+++ 1.38/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp 2007-01-04 15:30:22 +01:00
@@ -35,13 +35,14 @@
#include <EventLogger.hpp>
EventLogger g_eventLogger;
-static int g_run_connect_thread= 0;
-
#include <NdbMutex.h>
#ifdef VM_TRACE
NdbMutex *ndb_print_state_mutex= NULL;
#endif
+extern NdbMutex* g_ndb_init_mutex;
+static int g_ndb_connection_count = 0;
+
/*
* Ndb_cluster_connection
*/
@@ -87,7 +88,6 @@
pthread_handler_t run_ndb_cluster_connection_connect_thread(void *me)
{
- g_run_connect_thread= 1;
((Ndb_cluster_connection_impl*) me)->connect_thread();
return me;
}
@@ -273,6 +273,7 @@
m_connect_thread= 0;
m_connect_callback= 0;
+ m_run_connect_thread = 0;
#ifdef VM_TRACE
if (ndb_print_state_mutex == NULL)
@@ -288,8 +289,30 @@
m_config_retriever= 0;
}
+ m_event_add_drop_mutex = NdbMutex_Create();
m_transporter_facade= new TransporterFacade();
+ NdbMutex_Lock(g_ndb_init_mutex);
+ if (g_ndb_connection_count == 0)
+ {
+ NdbDictionary::Column::FRAGMENT=
+ NdbColumnImpl::create_pseudo("NDB$FRAGMENT");
+ NdbDictionary::Column::FRAGMENT_MEMORY=
+ NdbColumnImpl::create_pseudo("NDB$FRAGMENT_MEMORY");
+ NdbDictionary::Column::ROW_COUNT=
+ NdbColumnImpl::create_pseudo("NDB$ROW_COUNT");
+ NdbDictionary::Column::COMMIT_COUNT=
+ NdbColumnImpl::create_pseudo("NDB$COMMIT_COUNT");
+ NdbDictionary::Column::ROW_SIZE=
+ NdbColumnImpl::create_pseudo("NDB$ROW_SIZE");
+ NdbDictionary::Column::RANGE_NO=
+ NdbColumnImpl::create_pseudo("NDB$RANGE_NO");
+ NdbDictionary::Column::RECORDS_IN_RANGE=
+ NdbColumnImpl::create_pseudo("NDB$RECORDS_IN_RANGE");
+ }
+ g_ndb_connection_count++;
+ NdbMutex_Unlock(g_ndb_init_mutex);
+
DBUG_VOID_RETURN;
}
@@ -303,7 +326,7 @@
if (m_connect_thread)
{
void *status;
- g_run_connect_thread= 0;
+ m_run_connect_thread= 0;
NdbThread_WaitFor(m_connect_thread, &status);
NdbThread_Destroy(&m_connect_thread);
m_connect_thread= 0;
@@ -313,6 +336,7 @@
delete m_transporter_facade;
m_transporter_facade = 0;
}
+
if (m_config_retriever)
{
delete m_config_retriever;
@@ -325,6 +349,31 @@
ndb_print_state_mutex= NULL;
}
#endif
+ NdbMutex_Destroy(m_event_add_drop_mutex);
+ m_event_add_drop_mutex = NULL;
+
+ NdbMutex_Lock(g_ndb_init_mutex);
+ assert(g_ndb_connection_count);
+ g_ndb_connection_count--;
+ if (g_ndb_connection_count == 0)
+ {
+ delete NdbDictionary::Column::FRAGMENT;
+ delete NdbDictionary::Column::FRAGMENT_MEMORY;
+ delete NdbDictionary::Column::ROW_COUNT;
+ delete NdbDictionary::Column::COMMIT_COUNT;
+ delete NdbDictionary::Column::ROW_SIZE;
+ delete NdbDictionary::Column::RANGE_NO;
+ delete NdbDictionary::Column::RECORDS_IN_RANGE;
+ NdbDictionary::Column::FRAGMENT= 0;
+ NdbDictionary::Column::FRAGMENT_MEMORY= 0;
+ NdbDictionary::Column::ROW_COUNT= 0;
+ NdbDictionary::Column::COMMIT_COUNT= 0;
+ NdbDictionary::Column::ROW_SIZE= 0;
+ NdbDictionary::Column::RANGE_NO= 0;
+ NdbDictionary::Column::RECORDS_IN_RANGE= 0;
+ }
+ NdbMutex_Unlock(g_ndb_init_mutex);
+
DBUG_VOID_RETURN;
}
@@ -537,6 +586,7 @@
{
DBUG_ENTER("Ndb_cluster_connection_impl::connect_thread");
int r;
+ m_run_connect_thread = 1;
do {
NdbSleep_SecSleep(1);
if ((r = connect(0,0,0)) == 0)
@@ -544,12 +594,12 @@
if (r == -1) {
printf("Ndb_cluster_connection::connect_thread error\n");
DBUG_ASSERT(false);
- g_run_connect_thread= 0;
+ m_run_connect_thread= 0;
} else {
// Wait before making a new connect attempt
NdbSleep_SecSleep(1);
}
- } while (g_run_connect_thread);
+ } while (m_run_connect_thread);
if (m_connect_callback)
(*m_connect_callback)();
DBUG_VOID_RETURN;
--- 1.5/storage/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp 2007-01-04 15:30:22 +01:00
+++ 1.6/storage/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp 2007-01-04 15:30:22 +01:00
@@ -74,10 +74,14 @@
TransporterFacade *m_transporter_facade;
ConfigRetriever *m_config_retriever;
+
+ int m_run_connect_thread;
NdbThread *m_connect_thread;
int (*m_connect_callback)(void);
int m_optimized_node_selection;
+
+ NdbMutex* m_event_add_drop_mutex;
};
#endif
| Thread |
|---|
| • bk commit into 5.1 tree (jonas:1.2081) | jonas | 4 Jan |