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, 2008-02-06 20:54:59+01:00, jonas@stripped +2 -0
ndb - wl3600 [ 2/ 11 ]
Move commit mutex from SchemaOp* to SchemaTrans
A mutex is always taken before commit
And released after commit
With the current "per op" mutexes, it's possible for a backup
to contain only some blob-tables
(this is also behaviour before wl3600)
Alas, the correct behaviour is to have the mutexes on transaction level
---
This also removes the IT_REPEAT from createTable
storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp@stripped, 2008-02-06 20:54:57+01:00, jonas@stripped +80 -119
Move commit mutex from SchemaOp* to SchemaTrans
A mutex is always taken before commit
And released after commit
With the current "per op" mutexes, it's possible for a backup
to contain only some blob-tables
(this is also behaviour before wl3600)
Alas, the correct behaviour is to have the mutexes on transaction level
---
This also removes the IT_REPEAT from createTable
storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp@stripped, 2008-02-06 20:54:57+01:00, jonas@stripped +11 -6
Move commit mutex from SchemaOp* to SchemaTrans
A mutex is always taken before commit
And released after commit
With the current "per op" mutexes, it's possible for a backup
to contain only some blob-tables
(this is also behaviour before wl3600)
Alas, the correct behaviour is to have the mutexes on transaction level
---
This also removes the IT_REPEAT from createTable
diff -Nrup a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp
--- a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp 2008-01-09 06:39:13 +01:00
+++ b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp 2008-02-06 20:54:57 +01:00
@@ -5872,87 +5872,21 @@ Dbdict::createTable_commit(Signal* signa
D("createTable_commit" << V(itRepeat) << *op_ptr.p);
- if (itRepeat == 0) {
- jam();
-
- // take mutex at commit start
-
- if (trans_ptr.p->m_isMaster) {
- jam();
- Mutex mutex(signal, c_mutexMgr, createTabPtr.p->m_startLcpMutex);
- Callback c = {
- safe_cast(&Dbdict::createTab_startLcpMutex_locked),
- op_ptr.p->op_key
- };
- bool ok = mutex.lock(c);
- ndbrequire(ok);
- return;
- }
-
- Uint32 itFlags = SchemaTransImplConf::IT_REPEAT;
- sendTransConf(signal, trans_ptr, itFlags);
- return;
- }
-
- if (itRepeat == 1) {
- jam();
- bool savetodisk = !(tabPtr.p->m_bits & TableRecord::TR_Temporary);
-
- SchemaFile::TableEntry& te = createTabPtr.p->m_curr_entry;
- if (savetodisk)
- te.m_tableState = SchemaFile::TABLE_ADD_COMMITTED;
- else
- te.m_tableState = SchemaFile::TEMPORARY_TABLE_COMMITTED;
- te.m_transId = 0;
-
- Callback callback;
- callback.m_callbackData = op_ptr.p->op_key;
- callback.m_callbackFunction =
- safe_cast(&Dbdict::createTab_writeSchemaConf2);
-
- updateSchemaState(signal, tabPtr.i, &te, &callback, savetodisk, 1);
- return;
- }
-
- ndbrequire(itRepeat == 2);
- {
- jam();
-
- // release mutex at commit end
-
- if (trans_ptr.p->m_isMaster) {
- jam();
- Mutex mutex(signal, c_mutexMgr, createTabPtr.p->m_startLcpMutex);
- Callback c = {
- safe_cast(&Dbdict::createTab_startLcpMutex_unlocked),
- op_ptr.p->op_key
- };
- mutex.unlock(c);
- return;
- }
+ bool savetodisk = !(tabPtr.p->m_bits & TableRecord::TR_Temporary);
- sendTransConf(signal, trans_ptr);
- return;
- }
-}
-
-void
-Dbdict::createTab_startLcpMutex_locked(Signal* signal,
- Uint32 op_key,
- Uint32 ret)
-{
- jamEntry();
- D("createTab_startLcpMutex_locked");
-
- ndbrequire(ret == 0);
+ SchemaFile::TableEntry& te = createTabPtr.p->m_curr_entry;
+ if (savetodisk)
+ te.m_tableState = SchemaFile::TABLE_ADD_COMMITTED;
+ else
+ te.m_tableState = SchemaFile::TEMPORARY_TABLE_COMMITTED;
+ te.m_transId = 0;
- SchemaOpPtr op_ptr;
- CreateTableRecPtr createTabPtr;
- findSchemaOp(op_ptr, createTabPtr, op_key);
- ndbrequire(!op_ptr.isNull());
+ Callback callback;
+ callback.m_callbackData = op_ptr.p->op_key;
+ callback.m_callbackFunction =
+ safe_cast(&Dbdict::createTab_writeSchemaConf2);
- Uint32 itFlags = SchemaTransImplConf::IT_REPEAT;
- sendTransConf(signal, op_ptr, itFlags);
+ updateSchemaState(signal, tabPtr.i, &te, &callback, savetodisk, 1);
}
void
@@ -6040,32 +5974,9 @@ Dbdict::createTab_alterComplete(Signal*
#endif
}
- Uint32 itFlags = SchemaTransImplConf::IT_REPEAT;
- sendTransConf(signal, op_ptr, itFlags);
-}
-
-void
-Dbdict::createTab_startLcpMutex_unlocked(Signal* signal,
- Uint32 op_key,
- Uint32 ret)
-{
- jamEntry();
- D("createTab_startLcpMutex_unlocked");
-
- ndbrequire(ret == 0);
-
- SchemaOpPtr op_ptr;
- CreateTableRecPtr createTabPtr;
- findSchemaOp(op_ptr, createTabPtr, op_key);
- ndbrequire(!op_ptr.isNull());
-
- createTabPtr.p->m_startLcpMutex.release(c_mutexMgr);
-
- sendTransConf(signal, op_ptr);
+ sendTransConf(signal, op_ptr, 0);
}
-// CreateTable: ABORT
-
void
Dbdict::createTable_abortParse(Signal* signal, SchemaOpPtr op_ptr)
{
@@ -19331,17 +19242,6 @@ Dbdict::g_defaultPhaseList = {
g_defaultPhaseEntry
};
-void
-Dbdict::dummySimplePhase(Signal* signal, SchemaTransPtr trans_ptr)
-{
- jam();
- Uint32 itRepeat = getIteratorRepeat(trans_ptr);
-
- D("dummySimplePhase");
- ndbrequire(itRepeat == 0);
- sendTransConf(signal, trans_ptr);
-}
-
// SchemaTrans
bool
@@ -19950,13 +19850,11 @@ Dbdict::handleTransReply(Signal* signal,
jam();
runTransMaster(signal, trans_ptr);
}
- else if (tLoc.m_phase == TransPhase::End) {
+ else if (tLoc.m_phase == TransPhase::End)
+ {
jam();
- sendTransClientReply(signal, trans_ptr);
- // unlock
- const DictLockReq& lockReq = trans_ptr.p->m_lockReq;
- dict_lock_unlock(signal, &lockReq);
- releaseSchemaTrans(trans_ptr);
+ trans_commit_done(signal, trans_ptr);
+ return;
}
else {
ndbrequire(false);
@@ -20087,6 +19985,8 @@ Dbdict::runTransMaster(Signal* signal, S
D("runTransMaster");
TransLoc& tLoc = trans_ptr.p->m_transLoc;
+ bool is_prepare = tLoc.m_phase == TransPhase::Prepare;
+
if (tLoc.m_phase == TransPhase::Begin) {
jam();
// skip trans with no operations
@@ -20106,10 +20006,71 @@ Dbdict::runTransMaster(Signal* signal, S
ndbrequire(found);
}
+ if (is_prepare && tLoc.m_phase == TransPhase::Commit)
+ {
+ /**
+ * This is commit moment...
+ */
+ jam();
+ trans_commit(signal, trans_ptr);
+ return;
+ }
+
// always send to all in order to keep iterators synced
SectionHandle handle(this);
handle.m_cnt = 0;
sendTransReq(signal, trans_ptr, handle);
+}
+
+void
+Dbdict::trans_commit(Signal* signal, SchemaTransPtr trans_ptr)
+{
+ jam();
+ Mutex mutex(signal, c_mutexMgr, trans_ptr.p->m_commit_mutex);
+ Callback c = { safe_cast(&Dbdict::trans_commit_mutex_locked), trans_ptr.i };
+
+ // Todo should alloc mutex on SCHEMA_BEGIN
+ bool ok = mutex.lock(c);
+ ndbrequire(ok);
+}
+
+void
+Dbdict::trans_commit_mutex_locked(Signal* signal,
+ Uint32 transPtrI,
+ Uint32 ret)
+{
+ jamEntry();
+ SchemaTransPtr trans_ptr;
+ c_schemaTransPool.getPtr(trans_ptr, transPtrI);
+
+ SectionHandle handle(this);
+ handle.m_cnt = 0;
+ sendTransReq(signal, trans_ptr, handle);
+}
+
+void
+Dbdict::trans_commit_done(Signal* signal, SchemaTransPtr trans_ptr)
+{
+ Mutex mutex(signal, c_mutexMgr, trans_ptr.p->m_commit_mutex);
+ Callback c = { safe_cast(&Dbdict::trans_commit_mutex_unlocked), trans_ptr.i };
+
+ mutex.unlock(c);
+}
+
+void
+Dbdict::trans_commit_mutex_unlocked(Signal* signal,
+ Uint32 transPtrI,
+ Uint32 ret)
+{
+ jamEntry();
+ SchemaTransPtr trans_ptr;
+ c_schemaTransPool.getPtr(trans_ptr, transPtrI);
+
+ sendTransClientReply(signal, trans_ptr);
+ // unlock
+ const DictLockReq& lockReq = trans_ptr.p->m_lockReq;
+ dict_lock_unlock(signal, &lockReq);
+ releaseSchemaTrans(trans_ptr);
}
void
diff -Nrup a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp
--- a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp 2008-01-08 15:30:27 +01:00
+++ b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp 2008-02-06 20:54:57 +01:00
@@ -1773,9 +1773,6 @@ private:
Uint32 getGlobFlags(SchemaTransPtr trans_ptr,
const NdbNodeBitmask& nodes);
- // a dummy simple phase
- void dummySimplePhase(Signal*, SchemaTransPtr);
-
/*
* Trans client is the API client (not us, for recursive ops).
* Its state is shared by SchemaTrans / TxHandle (for takeover).
@@ -1850,6 +1847,11 @@ private:
// error is reset after each req/reply
ErrorInfo m_error;
+ /**
+ * Mutex handling
+ */
+ MutexHandle2<DIH_START_LCP_MUTEX> m_commit_mutex;
+
// magic is on when record is seized
enum { DICT_MAGIC = 0xd1c70002 };
Uint32 m_magic;
@@ -1865,7 +1867,7 @@ private:
m_takeOverTxKey = 0;
m_initNodes.clear();
m_failedNodes.clear();
- memset(&m_lockReq, 0, sizeof(m_lockReq)),
+ bzero(&m_lockReq, sizeof(m_lockReq));
m_opDepth = 0;
m_callback.m_callbackFunction = 0;
m_callback.m_callbackData = 0;
@@ -1903,6 +1905,11 @@ private:
void runTransMaster(Signal*, SchemaTransPtr);
void setTransMode(SchemaTransPtr, TransMode::Value, bool hold);
+ void trans_commit(Signal*, SchemaTransPtr);
+ void trans_commit_mutex_locked(Signal*, Uint32, Uint32);
+ void trans_commit_done(Signal* signal, SchemaTransPtr);
+ void trans_commit_mutex_unlocked(Signal*, Uint32, Uint32);
+
// participant
void recvTransReq(Signal*);
void recvTransParseReq(Signal*, SchemaTransPtr,
@@ -2218,11 +2225,9 @@ private:
void createTab_dihComplete(Signal*, Uint32 op_key, Uint32 ret);
// commit
- void createTab_startLcpMutex_locked(Signal*, Uint32 op_key, Uint32 ret);
void createTab_writeSchemaConf2(Signal*, Uint32 op_key, Uint32 ret);
void createTab_activate(Signal*, SchemaOpPtr, Callback*);
void createTab_alterComplete(Signal*, Uint32 op_key, Uint32 ret);
- void createTab_startLcpMutex_unlocked(Signal*, Uint32 op_key, Uint32 ret);
// abort prepare
void createTable_abortLocalConf(Signal*, Uint32 aux_op_key, Uint32 ret);
| Thread |
|---|
| • bk commit into 5.1 tree (jonas:1.2842) | jonas | 6 Feb |