Below is the list of changes that have just been committed into a local
6.0-falcon repository of jas. When jas 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-21 12:54:53-04:00, jas@stripped +5 -0
Track whether or not a transaction is in a tranaction
list.
storage/falcon/Database.cpp@stripped, 2007-06-21 12:53:52-04:00, jas@stripped +1 -1
Minor code simplification.
storage/falcon/Transaction.cpp@stripped, 2007-06-21 12:53:52-04:00, jas@stripped +50 -23
Work in progress.
storage/falcon/Transaction.h@stripped, 2007-06-21 12:53:52-04:00, jas@stripped +5 -3
Work in progress.
storage/falcon/TransactionManager.cpp@stripped, 2007-06-21 12:53:52-04:00, jas@stripped +33 -14
Track whether or not a transaction is in a tranaction
list.
storage/falcon/TransactionManager.h@stripped, 2007-06-21 12:53:52-04:00, jas@stripped +5 -4
Track whether or not a transaction is in a tranaction
list.
# 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: fluffy.netfrastructure.com
# Root: /home/mysql/mysql-5.1-falcon
--- 1.16/storage/falcon/TransactionManager.cpp 2007-06-21 12:55:00 -04:00
+++ 1.17/storage/falcon/TransactionManager.cpp 2007-06-21 12:55:00 -04:00
@@ -102,12 +102,17 @@
sync.unlock();
sync.lock(Exclusive);
transaction = new Transaction (connection, INTERLOCKED_INCREMENT(transactionSequence));
+ transaction->inList = true;
activeTransactions.append(transaction);
// And, just for yucks, add another 10 Available transactions
for (int n = 0; n < EXTRA_TRANSACTIONS; ++n)
- activeTransactions.append(new Transaction(connection, 0));
+ {
+ Transaction *trans = new Transaction(connection, 0);
+ trans->inList = true;
+ activeTransactions.append(trans);
+ }
return transaction;
}
@@ -236,14 +241,11 @@
transaction->getInfo(infoTable);
}
-void TransactionManager::purgeTransactions(Transaction *newlyCommitted)
+void TransactionManager::purgeTransactions()
{
Sync syncCommitted(&committedTransactions.syncObject, "Transaction::commit");
syncCommitted.lock(Exclusive);
- if (newlyCommitted)
- committedTransactions.append(newlyCommitted);
-
// And, while we're at it, check for any fully mature transactions to ditch
for (Transaction *transaction, *next = committedTransactions.first; (transaction = next);)
@@ -255,8 +257,13 @@
!transaction->writePending)
{
transaction->commitRecords();
- committedTransactions.remove(transaction);
- transaction->release();
+
+ if (transaction->inList)
+ {
+ transaction->inList = false;
+ committedTransactions.remove(transaction);
+ transaction->release();
+ }
}
}
}
@@ -337,16 +344,27 @@
ASSERT(t);
***/
- committedTransactions.remove(transaction);
- syncCommitted.unlock();
- transaction->release();
+ if (transaction->inList)
+ {
+ transaction->inList = false;
+ committedTransactions.remove(transaction);
+ syncCommitted.unlock();
+ transaction->release();
+ }
+
}
-void TransactionManager::expungeTransaction(Transaction *transaction)
+int TransactionManager::expungeTransaction(Transaction *transaction)
{
+ Sync sync(&syncDependencies, "TransactionManager::expungeTransaction");
+ sync.lock(Exclusive);
+ int count = 0;
+
for (Transaction *trans = activeTransactions.first; trans; trans = trans->next)
if (trans->transactionId > transaction->transactionId && trans->isActive())
- trans->expungeTransaction(transaction);
+ count += trans->expungeTransaction(transaction);
+
+ return count;
}
Transaction* TransactionManager::findTransaction(int transactionId)
@@ -370,14 +388,15 @@
return NULL;
}
-void TransactionManager::validateDepedendencies(void)
+void TransactionManager::validateDependencies(void)
{
Sync sync(&committedTransactions.syncObject, "TransactionManager::validateDepedendencies");
sync.lock(Shared);
Transaction *transaction;
for (transaction = activeTransactions.first; transaction; transaction = transaction->next)
- transaction->validateDependencies(false);
+ if (transaction->isActive())
+ transaction->validateDependencies(false);
sync.unlock();
Sync syncCommitted(&committedTransactions.syncObject, "TransactionManager::validateDepedendencies");
--- 1.14/storage/falcon/TransactionManager.h 2007-06-21 12:55:00 -04:00
+++ 1.15/storage/falcon/TransactionManager.h 2007-06-21 12:55:00 -04:00
@@ -39,23 +39,24 @@
void print(void);
Transaction* findOldest(void);
void getTransactionInfo(InfoTable* infoTable);
- void purgeTransactions(Transaction *newlyCommitted);
+ void purgeTransactions();
void getSummaryInfo(InfoTable* infoTable);
void reportStatistics(void);
void removeCommittedTransaction(Transaction* transaction);
- void expungeTransaction(Transaction *transaction);
+ int expungeTransaction(Transaction *transaction);
+ Transaction* findTransaction(int transactionId);
+ void validateDependencies(void);
INTERLOCK_TYPE transactionSequence;
Database *database;
SyncObject syncObject;
+ SyncObject syncDependencies;
int committed;
int rolledBack;
int priorCommitted;
int priorRolledBack;
Queue<Transaction> activeTransactions;
Queue<Transaction> committedTransactions;
- Transaction* findTransaction(int transactionId);
- void validateDepedendencies(void);
};
#endif
--- 1.78/storage/falcon/Database.cpp 2007-06-21 12:55:00 -04:00
+++ 1.79/storage/falcon/Database.cpp 2007-06-21 12:55:00 -04:00
@@ -1681,7 +1681,7 @@
int threshold = 0;
int64 total = 0;
- transactionManager->purgeTransactions(NULL);
+ transactionManager->purgeTransactions();
TransId oldestActiveTransaction = transactionManager->findOldestActive();
int n;
--- 1.99/storage/falcon/Transaction.cpp 2007-06-21 12:55:00 -04:00
+++ 1.100/storage/falcon/Transaction.cpp 2007-06-21 12:55:00 -04:00
@@ -105,6 +105,7 @@
committedRecords = 0;
numberStates = 0;
blockedBy = 0;
+ inList = false;
//scavenged = false;
if (seq == 0)
@@ -129,17 +130,24 @@
states = new TransState[statesAllocated];
}
+ Sync syncDependencies(&transactionManager->syncDependencies, "Transaciton::initialize");
+
if (count)
+ {
+ syncDependencies.lock(Shared);
+
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++;
+ TransState *state = states + numberStates;
state->transaction = transaction;
state->transactionId = transaction->transactionId;
state->state = transaction->state;
+ ++numberStates;
}
+ }
state = Active;
}
@@ -152,7 +160,7 @@
syncActive.unlock();
}
- validateDependencies(true);
+ //validateDependencies(true);
delete [] states;
delete [] xid;
@@ -212,7 +220,7 @@
}
TransactionManager *transactionManager = database->transactionManager;
- transactionManager->validateDepedendencies();
+ //transactionManager->validateDependencies();
addRef();
//#ifndef XA_ENABLED
@@ -252,6 +260,7 @@
releaseDependencies();
database->flushInversion(this);
syncActiveTransactions.lock(Exclusive);
+ inList = false;
transactionManager->activeTransactions.remove(this);
for (RecordVersion *record = records; record; record = record->next)
@@ -280,15 +289,17 @@
Sync syncCommitted(&transactionManager->committedTransactions.syncObject, "Transaction::commit");
syncCommitted.lock(Exclusive);
transactionManager->committedTransactions.append(this);
+ inList = true;
release();
- transactionManager->validateDepedendencies();
+ //transactionManager->validateDependencies();
}
void Transaction::commitNoUpdates(void)
{
TransactionManager *transactionManager = database->transactionManager;
- transactionManager->validateDepedendencies();
+ //transactionManager->validateDependencies();
+ state = CommittingReadOnly;
addRef();
ASSERT(!deferredIndexes);
@@ -301,19 +312,15 @@
syncActiveTransactions.lock(Shared);
releaseDependencies();
- if (dependencies)
- transactionManager->expungeTransaction(this);
-
- if (dependencies)
+ for (int n = 0; dependencies && n < 10; ++n)
{
- 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);
+ Sync sync(&transactionManager->syncDependencies, "Transaction::commitNoUpdate");
+ sync.lock(Exclusive);
+ int initial = dependencies;
+ int count = transactionManager->expungeTransaction(this);
}
+ ASSERT(dependencies == 0);
syncActiveTransactions.unlock();
state = Committed;
syncActive.unlock();
@@ -331,7 +338,7 @@
transactionId = 0;
state = Available;
release();
- transactionManager->validateDepedendencies();
+ //transactionManager->validateDependencies();
}
void Transaction::rollback()
@@ -388,21 +395,30 @@
++transactionManager->rolledBack;
transactionManager->expungeTransaction(this);
connection = NULL;
+ inList = false;
transactionManager->activeTransactions.remove(this);
sync.unlock();
release();
}
-void Transaction::expungeTransaction(Transaction * transaction)
+int Transaction::expungeTransaction(Transaction * transaction)
{
+ int count = 0;
+
for (TransState *state = states, *end = states + numberStates; state < end; ++state)
if (state->transaction == transaction)
{
- state->transaction = NULL;
- transaction->releaseDependency();
+ if (COMPARE_EXCHANGE_POINTER(&state->transaction, transaction, NULL))
+ {
+ transaction->releaseDependency();
+ ++count;
+ }
+
break;
}
+
+ return count;
}
void Transaction::prepare(int xidLen, const UCHAR *xidPtr)
@@ -597,18 +613,29 @@
if (!numberStates)
return;
+ TransactionManager *transactionManager = database->transactionManager;
+ //Sync sync(&transactionManager->syncDependencies, "Transaction::releaseDependencies");
+ //sync.lock(Exclusive);
+ //transactionManager->validateDependencies();
+
for (TransState *state = states, *end = states + numberStates; state < end; ++state)
- if (state->transaction)
+ {
+ Transaction *transaction = state->transaction;
+
+ if (transaction)
{
- if (state->transaction->transactionId != state->transactionId)
+ if (transaction->transactionId != state->transactionId)
{
Transaction *transaction = database->transactionManager->findTransaction(state->transactionId);
ASSERT(false);
}
- state->transaction->releaseDependency();
- state->transaction = NULL;
+ if (COMPARE_EXCHANGE_POINTER(&state->transaction, transaction, NULL))
+ transaction->releaseDependency();
}
+ }
+
+ //database->transactionManager->validateDependencies();
}
/*
--- 1.48/storage/falcon/Transaction.h 2007-06-21 12:55:00 -04:00
+++ 1.49/storage/falcon/Transaction.h 2007-06-21 12:55:00 -04:00
@@ -61,7 +61,8 @@
// And the remaining are for transactions pending reuse
Available,
- Initializing
+ Initializing,
+ CommittingReadOnly
};
struct TransState {
@@ -87,7 +88,7 @@
State getRelativeState(Record* record, uint32 flags);
State getRelativeState (Transaction *transaction, TransId transId, uint32 flags);
void removeRecord (RecordVersion *record);
- void expungeTransaction (Transaction *transaction);
+ int expungeTransaction (Transaction *transaction);
void commitRecords();
void releaseDependencies();
bool visible (Transaction *transaction);
@@ -135,7 +136,6 @@
SavePoint *freeSavePoints;
DeferredIndex *deferredIndexes;
int deferredIndexCount;
- int numberStates;
int statesAllocated;
int isolationLevel;
int xidLength;
@@ -148,6 +148,7 @@
bool writePending;
bool pendingPageWrites;
bool hasLocks;
+ bool inList;
SyncObject syncActive;
SyncObject syncIndexes;
uint64 totalRecordData; // total bytes of record data for this transaction (unchilled + thawed)
@@ -158,6 +159,7 @@
RecordVersion **chillPoint; // points to a pointer to the first non-chilled record
int scanIndexCount;
+ volatile int numberStates;
volatile INTERLOCK_TYPE state;
volatile INTERLOCK_TYPE dependencies;
volatile INTERLOCK_TYPE useCount;
| Thread |
|---|
| • bk commit into 6.0-falcon tree (jas:1.2590) | Jim Starkey | 21 Jun |