Below is the list of changes that have just been committed into a local
6.0-falcon repository of . When 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-06-20 13:55:19-04:00, jas@rowvwade. +4 -0
Split Transaction::commit to separate methods for read/write and
read/only transactions.
storage/falcon/Transaction.cpp@stripped, 2007-06-20 13:55:11-04:00, jas@rowvwade. +78 -84
Split Transaction::commit to separate methods for read/write and
read/only transactions.
storage/falcon/Transaction.h@stripped, 2007-06-20 13:55:12-04:00, jas@rowvwade. +1 -0
Split Transaction::commit to separate methods for read/write and
read/only transactions.
storage/falcon/TransactionManager.cpp@stripped, 2007-06-20 13:55:12-04:00, jas@rowvwade. +32 -0
Minor reorganization. Also added another diagnostic
method.
storage/falcon/TransactionManager.h@stripped, 2007-06-20 13:55:12-04:00, jas@rowvwade. +5 -3
Added method to lookup transaction by transaction id.
# 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: jas
# Host: rowvwade.
# Root: D:/MySQL/mysql-5.1-falcon
--- 1.14/storage/falcon/TransactionManager.cpp 2007-06-20 13:55:40 -04:00
+++ 1.15/storage/falcon/TransactionManager.cpp 2007-06-20 13:55:40 -04:00
@@ -327,13 +327,45 @@
{
Sync syncCommitted(&committedTransactions.syncObject, "TransactionManager::removeCommittedTransaction");
syncCommitted.lock(Exclusive);
+
+ /***
Transaction *t;
for (t = committedTransactions.first; t && t != transaction; t = t->next)
;
ASSERT(t);
+ ***/
+
committedTransactions.remove(transaction);
syncCommitted.unlock();
transaction->release();
+}
+
+void TransactionManager::expungeTransaction(Transaction *transaction)
+{
+ for (Transaction *trans = activeTransactions.first; trans; trans = trans->next)
+ if (trans->transactionId > transaction->transactionId && trans->isActive())
+ trans->expungeTransaction(transaction);
+}
+
+Transaction* TransactionManager::findTransaction(int transactionId)
+{
+ Sync sync(&committedTransactions.syncObject, "TransactionManager::findTransaction");
+ sync.lock(Shared);
+ Transaction *transaction;
+
+ for (transaction = activeTransactions.first; transaction; transaction = transaction->next)
+ if (transaction->transactionId == transactionId)
+ return transaction;
+
+ sync.unlock();
+ Sync syncCommitted(&committedTransactions.syncObject, "TransactionManager::findTransaction");
+ syncCommitted.lock(Shared);
+
+ for (transaction = committedTransactions.first; transaction; transaction = transaction->next)
+ if (transaction->transactionId == transactionId)
+ return transaction;
+
+ return NULL;
}
--- 1.12/storage/falcon/TransactionManager.h 2007-06-20 13:55:40 -04:00
+++ 1.13/storage/falcon/TransactionManager.h 2007-06-20 13:55:40 -04:00
@@ -40,6 +40,10 @@
Transaction* findOldest(void);
void getTransactionInfo(InfoTable* infoTable);
void purgeTransactions(Transaction *newlyCommitted);
+ void getSummaryInfo(InfoTable* infoTable);
+ void reportStatistics(void);
+ void removeCommittedTransaction(Transaction* transaction);
+ void expungeTransaction(Transaction *transaction);
INTERLOCK_TYPE transactionSequence;
Database *database;
@@ -50,9 +54,7 @@
int priorRolledBack;
Queue<Transaction> activeTransactions;
Queue<Transaction> committedTransactions;
- void getSummaryInfo(InfoTable* infoTable);
- void reportStatistics(void);
- void removeCommittedTransaction(Transaction* transaction);
+ Transaction* findTransaction(int transactionId);
};
#endif
--- 1.97/storage/falcon/Transaction.cpp 2007-06-20 13:55:40 -04:00
+++ 1.98/storage/falcon/Transaction.cpp 2007-06-20 13:55:40 -04:00
@@ -126,19 +126,19 @@
{
delete [] states;
statesAllocated = count;
- states = new TransState [statesAllocated];
+ states = new TransState[statesAllocated];
}
if (count)
for (Transaction *transaction = transactionManager->activeTransactions.first; transaction; transaction = transaction->next)
if (transaction->isActive() && !transaction->systemTransaction)
{
+ transaction->addRef();
+ INTERLOCKED_INCREMENT(transaction->dependencies);
TransState *state = states + numberStates++;
state->transaction = transaction;
state->transactionId = transaction->transactionId;
state->state = transaction->state;
- transaction->addRef();
- INTERLOCKED_INCREMENT(transaction->dependencies);
}
state = Active;
@@ -199,11 +199,18 @@
void Transaction::commit()
{
ASSERT((records != NULL) || (chillPoint == &records));
- TransactionManager *transactionManager = database->transactionManager;
-
+
if (!isActive())
throw SQLEXCEPTION (RUNTIME_ERROR, "transaction is not active");
+ if (!hasUpdates)
+ {
+ commitNoUpdates();
+
+ return;
+ }
+
+ TransactionManager *transactionManager = database->transactionManager;
addRef();
//#ifndef XA_ENABLED
@@ -227,31 +234,7 @@
releaseRecordLocks();
Sync syncActiveTransactions(&transactionManager->activeTransactions.syncObject, "Transaction::commit");
-
- if (hasUpdates)
- database->serialLog->preCommit(this);
- else
- {
- syncActiveTransactions.lock(Shared);
-
- if (dependencies)
- for (Transaction *trans = transactionManager->activeTransactions.first; trans; trans = trans->next)
- if (trans->transactionId > transactionId && trans->isActive())
- trans->expungeTransaction(this);
-
- if (dependencies)
- {
- Sync sync2(&transactionManager->committedTransactions.syncObject, "Transaction::commit");
- sync2.lock(Shared);
-
- for (Transaction *trans = transactionManager->committedTransactions.first; trans; trans = trans->next)
- for (TransState *s = trans->states, *end = s + trans->numberStates; s < end; ++s)
- ASSERT(s->transaction != this);
- }
-
- syncActiveTransactions.unlock();
- }
-
+ database->serialLog->preCommit(this);
state = Committed;
syncActive.unlock();
@@ -265,24 +248,17 @@
record->table->postCommit (this, record);
releaseDependencies();
-
- if (hasUpdates)
- {
- database->flushInversion(this);
-
- syncActiveTransactions.lock(Exclusive);
- transactionManager->activeTransactions.remove(this);
-
- for (RecordVersion *record = records; record; record = record->next)
- if (!record->priorVersion)
- ++record->table->cardinality;
- else if (record->state == recDeleted && record->table->cardinality > 0)
- --record->table->cardinality;
-
- syncActiveTransactions.unlock();
- }
- else
- writeComplete();
+ database->flushInversion(this);
+ syncActiveTransactions.lock(Exclusive);
+ transactionManager->activeTransactions.remove(this);
+
+ for (RecordVersion *record = records; record; record = record->next)
+ if (!record->priorVersion)
+ ++record->table->cardinality;
+ else if (record->state == recDeleted && record->table->cardinality > 0)
+ --record->table->cardinality;
+
+ syncActiveTransactions.unlock();
database->commit(this);
@@ -299,41 +275,58 @@
// Add ourselves to the list of lingering committed transactions
- if (hasUpdates)
- {
- Sync syncCommitted(&transactionManager->committedTransactions.syncObject, "Transaction::commit");
- syncCommitted.lock(Exclusive);
- transactionManager->committedTransactions.append(this);
- release();
-
- // And, while we're at it, check for any fully mature transactions to ditch
-
- /***
- for (Transaction *transaction, *next = transactionManager->committedTransactions.first; (transaction = next);)
- {
- next = transaction->next;
+ Sync syncCommitted(&transactionManager->committedTransactions.syncObject, "Transaction::commit");
+ syncCommitted.lock(Exclusive);
+ transactionManager->committedTransactions.append(this);
+ release();
+}
- if ((transaction->state == Committed) &&
- (transaction->dependencies == 0) &&
- !transaction->writePending)
- {
- if (transaction->useCount > 1)
- continue; // Done this way to set a break point.
- transaction->commitRecords();
- transactionManager->committedTransactions.remove(transaction);
- transaction->release();
- }
- }
- ***/
- }
- else
+void Transaction::commitNoUpdates(void)
+{
+ TransactionManager *transactionManager = database->transactionManager;
+ addRef();
+ ASSERT(!deferredIndexes);
+
+ ++transactionManager->committed;
+
+ if (hasLocks)
+ releaseRecordLocks();
+
+ Sync syncActiveTransactions(&transactionManager->activeTransactions.syncObject, "Transaction::commitNoUpdates");
+ syncActiveTransactions.lock(Shared);
+ releaseDependencies();
+
+ if (dependencies)
+ transactionManager->expungeTransaction(this);
+
+ if (dependencies)
{
- release();
- transactionId = 0;
- state = Available;
+ Sync sync2(&transactionManager->committedTransactions.syncObject, "Transaction::commitNoUpdates");
+ sync2.lock(Shared);
+
+ for (Transaction *trans = transactionManager->committedTransactions.first; trans; trans = trans->next)
+ for (TransState *s = trans->states, *end = s + trans->numberStates; s < end; ++s)
+ ASSERT(s->transaction != this);
}
+
+ syncActiveTransactions.unlock();
+ state = Committed;
+ syncActive.unlock();
+ //writeComplete();
+ writePending = false;
+ //database->commit(this);
+
+ delete [] xid;
+ xid = NULL;
+ xidLength = 0;
+ // If there's no reason to stick around, just go away
+
+ connection = NULL;
+ transactionId = 0;
+ state = Available;
+ release();
}
void Transaction::rollback()
@@ -388,11 +381,7 @@
Sync sync (&transactionManager->activeTransactions.syncObject, "Transaction::rollback");
sync.lock (Exclusive);
++transactionManager->rolledBack;
-
- for (Transaction *trans = transactionManager->activeTransactions.first; trans; trans = trans->next)
- if (trans->isActive())
- trans->expungeTransaction(this);
-
+ transactionManager->expungeTransaction(this);
connection = NULL;
transactionManager->activeTransactions.remove(this);
sync.unlock();
@@ -606,7 +595,12 @@
for (TransState *state = states, *end = states + numberStates; state < end; ++state)
if (state->transaction)
{
- ASSERT(state->transaction->transactionId == state->transactionId);
+ if (state->transaction->transactionId != state->transactionId)
+ {
+ Transaction *transaction = database->transactionManager->findTransaction(state->transactionId);
+ ASSERT(false);
+ }
+
state->transaction->releaseDependency();
state->transaction = NULL;
}
--- 1.46/storage/falcon/Transaction.h 2007-06-20 13:55:40 -04:00
+++ 1.47/storage/falcon/Transaction.h 2007-06-20 13:55:40 -04:00
@@ -170,6 +170,7 @@
public:
void fullyCommitted(void);
void releaseCommittedTransaction(void);
+ void commitNoUpdates(void);
};
#endif // !defined(AFX_TRANSACTION_H__02AD6A4D_A433_11D2_AB5B_0000C01D2301__INCLUDED_)
| Thread |
|---|
| • bk commit into 6.0-falcon tree (jas:1.2588) | U-ROWVWADEjas | 20 Jun |