diff options
author | unknown <tomas@poseidon.(none)> | 2004-09-06 18:30:57 +0000 |
---|---|---|
committer | unknown <tomas@poseidon.(none)> | 2004-09-06 18:30:57 +0000 |
commit | d90b95ed31f029bb5c34ed2e1e701119919af1aa (patch) | |
tree | cd29d623bdf3acd31da3d6659f9f3ec2f5ca3d43 /ndb | |
parent | 5cccb45385438462bb1212eec90b43cf37537306 (diff) | |
download | mariadb-git-d90b95ed31f029bb5c34ed2e1e701119919af1aa.tar.gz |
fixed so that ndbcluster and mysqld can be started independently
fixed some error codes in Ndb so that 4009-cluster failure is returned when cluster is not up
Diffstat (limited to 'ndb')
-rw-r--r-- | ndb/src/ndbapi/Ndb.cpp | 68 | ||||
-rw-r--r-- | ndb/src/ndbapi/NdbDictionaryImpl.cpp | 7 | ||||
-rw-r--r-- | ndb/src/ndbapi/Ndbif.cpp | 9 | ||||
-rw-r--r-- | ndb/src/ndbapi/Ndbinit.cpp | 1 | ||||
-rw-r--r-- | ndb/src/ndbapi/ndb_cluster_connection.cpp | 23 | ||||
-rw-r--r-- | ndb/src/ndbapi/ndberror.c | 3 |
6 files changed, 69 insertions, 42 deletions
diff --git a/ndb/src/ndbapi/Ndb.cpp b/ndb/src/ndbapi/Ndb.cpp index 2c952425b1e..2b95384324d 100644 --- a/ndb/src/ndbapi/Ndb.cpp +++ b/ndb/src/ndbapi/Ndb.cpp @@ -246,6 +246,7 @@ Ndb::waitUntilReady(int timeout) int secondsCounter = 0; int milliCounter = 0; int noChecksSinceFirstAliveFound = 0; + int id; if (theInitState != Initialised) { // Ndb::init is not called @@ -254,39 +255,48 @@ Ndb::waitUntilReady(int timeout) } do { - unsigned int foundAliveNode = 0; - TransporterFacade *tp = TransporterFacade::instance(); - tp->lock_mutex(); - for (unsigned int i = 0; i < theNoOfDBnodes; i++) { - const NodeId nodeId = theDBnodes[i]; - //************************************************ - // If any node is answering, ndb is answering - //************************************************ - if (tp->get_node_alive(nodeId) != 0) { - foundAliveNode++; + if ((id = theNode) != 0) { + unsigned int foundAliveNode = 0; + TransporterFacade *tp = TransporterFacade::instance(); + tp->lock_mutex(); + for (unsigned int i = 0; i < theNoOfDBnodes; i++) { + const NodeId nodeId = theDBnodes[i]; + //************************************************ + // If any node is answering, ndb is answering + //************************************************ + if (tp->get_node_alive(nodeId) != 0) { + foundAliveNode++; + }//if + }//for + + tp->unlock_mutex(); + if (foundAliveNode == theNoOfDBnodes) { + DBUG_RETURN(0); }//if - }//for - - tp->unlock_mutex(); - if (foundAliveNode == theNoOfDBnodes) { - DBUG_RETURN(0); - }//if - if (foundAliveNode > 0) { - noChecksSinceFirstAliveFound++; - }//if - if (noChecksSinceFirstAliveFound > 30) { - DBUG_RETURN(0); - }//if + if (foundAliveNode > 0) { + noChecksSinceFirstAliveFound++; + }//if + if (noChecksSinceFirstAliveFound > 30) { + DBUG_RETURN(0); + }//if + }//if theNode != 0 + if (secondsCounter >= timeout) + break; NdbSleep_MilliSleep(100); milliCounter += 100; if (milliCounter >= 1000) { secondsCounter++; milliCounter = 0; }//if - } while ( secondsCounter < timeout ); + } while (1); + if (id == 0) { + theError.code = 4269; + DBUG_RETURN(-1); + } if (noChecksSinceFirstAliveFound > 0) { DBUG_RETURN(0); }//if + theError.code = 4009; DBUG_RETURN(-1); } @@ -789,8 +799,10 @@ Ndb::readAutoIncrementValue(const char* aTableName) { DEBUG_TRACE("readtAutoIncrementValue"); const NdbTableImpl* table = theDictionary->getTable(aTableName); - if (table == 0) + if (table == 0) { + theError= theDictionary->getNdbError(); return ~0; + } Uint64 tupleId = readTupleIdFromNdb(table->m_tableId); return tupleId; } @@ -821,8 +833,10 @@ Ndb::setAutoIncrementValue(const char* aTableName, Uint64 val, bool increase) { DEBUG_TRACE("setAutoIncrementValue " << val); const NdbTableImpl* table = theDictionary->getTable(aTableName); - if (table == 0) + if (table == 0) { + theError= theDictionary->getNdbError(); return false; + } return setTupleIdInNdb(table->m_tableId, val, increase); } @@ -841,8 +855,10 @@ Ndb::setTupleIdInNdb(const char* aTableName, Uint64 val, bool increase ) { DEBUG_TRACE("setTupleIdInNdb"); const NdbTableImpl* table = theDictionary->getTable(aTableName); - if (table == 0) + if (table == 0) { + theError= theDictionary->getNdbError(); return false; + } return setTupleIdInNdb(table->m_tableId, val, increase); } diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/ndb/src/ndbapi/NdbDictionaryImpl.cpp index b0c007d7790..b221966896e 100644 --- a/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -1500,8 +1500,11 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb, if (!alter && haveAutoIncrement) { // if (!ndb.setAutoIncrementValue(impl.m_internalName.c_str(), autoIncrementValue)) { if (!ndb.setAutoIncrementValue(impl.m_externalName.c_str(), autoIncrementValue)) { - m_error.code = 4336; - ndb.theError = m_error; + if (ndb.theError.code == 0) { + m_error.code = 4336; + ndb.theError = m_error; + } else + m_error= ndb.theError; ret = -1; // errorcode set in initialize_autoincrement } } diff --git a/ndb/src/ndbapi/Ndbif.cpp b/ndb/src/ndbapi/Ndbif.cpp index 4560ed09b6a..f2245e11ef1 100644 --- a/ndb/src/ndbapi/Ndbif.cpp +++ b/ndb/src/ndbapi/Ndbif.cpp @@ -185,10 +185,10 @@ Ndb::executeMessage(void* NdbObject, void Ndb::connected(Uint32 ref) { theMyRef= ref; - theNode= refToNode(ref); + Uint32 tmpTheNode= refToNode(ref); Uint64 tBlockNo= refToBlock(ref); if (theNdbBlockNumber >= 0){ - assert(theMyRef == numberToRef(theNdbBlockNumber, theNode)); + assert(theMyRef == numberToRef(theNdbBlockNumber, tmpTheNode)); } TransporterFacade * theFacade = TransporterFacade::instance(); @@ -201,18 +201,19 @@ void Ndb::connected(Uint32 ref) } } theFirstTransId = ((Uint64)tBlockNo << 52)+ - ((Uint64)theNode << 40); + ((Uint64)tmpTheNode << 40); theFirstTransId += theFacade->m_max_trans_id; // assert(0); DBUG_PRINT("info",("connected with ref=%x, id=%d, no_db_nodes=%d, first_trans_id=%lx", theMyRef, - theNode, + tmpTheNode, theNoOfDBnodes, theFirstTransId)); startTransactionNodeSelectionData.init(theNoOfDBnodes, theDBnodes); theCommitAckSignal = new NdbApiSignal(theMyRef); theDictionary->m_receiver.m_reference= theMyRef; + theNode= tmpTheNode; // flag that Ndb object is initialized } void diff --git a/ndb/src/ndbapi/Ndbinit.cpp b/ndb/src/ndbapi/Ndbinit.cpp index 743d66216d7..9ec500b2a46 100644 --- a/ndb/src/ndbapi/Ndbinit.cpp +++ b/ndb/src/ndbapi/Ndbinit.cpp @@ -125,7 +125,6 @@ void Ndb::setup(Ndb_cluster_connection *ndb_cluster_connection, theNode= 0; theFirstTransId= 0; theMyRef= 0; - theNoOfDBnodes= 0; fullyQualifiedNames = true; diff --git a/ndb/src/ndbapi/ndb_cluster_connection.cpp b/ndb/src/ndbapi/ndb_cluster_connection.cpp index 24df793c0d2..b737a3cfa62 100644 --- a/ndb/src/ndbapi/ndb_cluster_connection.cpp +++ b/ndb/src/ndbapi/ndb_cluster_connection.cpp @@ -54,14 +54,15 @@ void Ndb_cluster_connection::connect_thread() { DBUG_ENTER("Ndb_cluster_connection::connect_thread"); int r; - while (g_run_connect_thread) { + do { if ((r = connect(1)) == 0) break; if (r == -1) { printf("Ndb_cluster_connection::connect_thread error\n"); - abort(); + DBUG_ASSERT(false); + g_run_connect_thread= 0; } - } + } while (g_run_connect_thread); if (m_connect_callback) (*m_connect_callback)(); DBUG_VOID_RETURN; @@ -69,13 +70,19 @@ void Ndb_cluster_connection::connect_thread() int Ndb_cluster_connection::start_connect_thread(int (*connect_callback)(void)) { + int r; DBUG_ENTER("Ndb_cluster_connection::start_connect_thread"); m_connect_callback= connect_callback; - m_connect_thread= NdbThread_Create(run_ndb_cluster_connection_connect_thread, - (void**)this, - 32768, - "ndb_cluster_connection", - NDB_THREAD_PRIO_LOW); + if ((r = connect(1)) == 1) + m_connect_thread= NdbThread_Create(run_ndb_cluster_connection_connect_thread, + (void**)this, + 32768, + "ndb_cluster_connection", + NDB_THREAD_PRIO_LOW); + else if (r < 0) + DBUG_RETURN(-1) + else if (m_connect_callback) + (*m_connect_callback)(); DBUG_RETURN(0); } diff --git a/ndb/src/ndbapi/ndberror.c b/ndb/src/ndbapi/ndberror.c index 66a89326a66..7991004e3d0 100644 --- a/ndb/src/ndbapi/ndberror.c +++ b/ndb/src/ndbapi/ndberror.c @@ -424,7 +424,8 @@ ErrorBundle ErrorCodes[] = { { 4266, AE, "Invalid blob seek position" }, { 4267, IE, "Corrupted blob value" }, { 4268, IE, "Error in blob head update forced rollback of transaction" }, - { 4268, IE, "Unknown blob error" } + { 4268, IE, "Unknown blob error" }, + { 4269, IE, "No connection to ndb management server" } }; static |