List:Commits« Previous MessageNext Message »
From:Jim Starkey Date:June 22 2007 5:30pm
Subject:bk commit into 6.0-falcon tree (jas:1.2591)
View as plain text  
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-22 13:30:17-04:00, jas@stripped +3 -0
  Work in progress on new transaction management
  schema.

  storage/falcon/Transaction.cpp@stripped, 2007-06-22 13:30:14-04:00, jas@stripped +49 -27
    Work in progress on new transaction management
    schema.

  storage/falcon/Transaction.h@stripped, 2007-06-22 13:30:14-04:00, jas@stripped +1 -1
    Work in progress on new transaction management
    schema.

  storage/falcon/TransactionManager.cpp@stripped, 2007-06-22 13:30:14-04:00, jas@stripped +6 -21
    Work in progress on new transaction management
    schema.

# 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.17/storage/falcon/TransactionManager.cpp	2007-06-22 13:30:24 -04:00
+++ 1.18/storage/falcon/TransactionManager.cpp	2007-06-22 13:30:24 -04:00
@@ -102,7 +102,6 @@
 	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
@@ -110,7 +109,6 @@
 	for (int n = 0; n < EXTRA_TRANSACTIONS; ++n)
 		{
 		Transaction *trans = new Transaction(connection, 0);
-		trans->inList = true;
 		activeTransactions.append(trans);
 		}
 	
@@ -334,34 +332,21 @@
 {
 	Sync syncCommitted(&committedTransactions.syncObject, "TransactionManager::removeCommittedTransaction");
 	syncCommitted.lock(Exclusive);
-	
-	/***
-	Transaction *t;
-	
-	for (t = committedTransactions.first; t && t != transaction; t = t->next)
-		;
-	
-	ASSERT(t);
-	***/
-	
-	if (transaction->inList)
-		{
-		transaction->inList = false;
-		committedTransactions.remove(transaction);
-		syncCommitted.unlock();
-		transaction->release();
-		}
-
+	committedTransactions.remove(transaction);
+	syncCommitted.unlock();
+	transaction->release();
 }
 
 int TransactionManager::expungeTransaction(Transaction *transaction)
 {
+	Sync syncCommitted(&committedTransactions.syncObject, "TransactionManager::expungeTransaction");
+	syncCommitted.lock(Shared);
 	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())
+		if (trans->transactionId > transaction->transactionId)
 			count += trans->expungeTransaction(transaction);
 
 	return count;

--- 1.100/storage/falcon/Transaction.cpp	2007-06-22 13:30:24 -04:00
+++ 1.101/storage/falcon/Transaction.cpp	2007-06-22 13:30:24 -04:00
@@ -105,7 +105,7 @@
 	committedRecords = 0;
 	numberStates = 0;
 	blockedBy = 0;
-	inList = false;
+	inList = true;
 	//scavenged = false;
 	
 	if (seq == 0)
@@ -137,7 +137,9 @@
 		syncDependencies.lock(Shared);
 
 		for (Transaction *transaction = transactionManager->activeTransactions.first; transaction; transaction = transaction->next)
-			if (transaction->isActive() && !transaction->systemTransaction)
+			if (transaction->isActive() && 
+				 !transaction->systemTransaction &&
+				 transaction->transactionId < transactionId)
 				{
 				transaction->addRef();
 				INTERLOCKED_INCREMENT(transaction->dependencies);
@@ -154,13 +156,14 @@
 
 Transaction::~Transaction()
 {
+	ASSERT(!inList);
+
 	if (state == Active)
 		{
 		ASSERT(false);
 		syncActive.unlock();
 		}
 
-	//validateDependencies(true);
 	delete [] states;
 	delete [] xid;
 	
@@ -220,7 +223,6 @@
 		}
 
 	TransactionManager *transactionManager = database->transactionManager;
-	//transactionManager->validateDependencies();
 	addRef();
 
 //#ifndef XA_ENABLED
@@ -260,7 +262,6 @@
 	releaseDependencies();
 	database->flushInversion(this);
 	syncActiveTransactions.lock(Exclusive);
-	inList = false;
 	transactionManager->activeTransactions.remove(this);
 	
 	for (RecordVersion *record = records; record; record = record->next)
@@ -270,7 +271,9 @@
 			--record->table->cardinality;
 			
 	syncActiveTransactions.unlock();
-
+	Sync syncCommitted(&transactionManager->committedTransactions.syncObject, "Transaction::commit");
+	syncCommitted.lock(Exclusive);
+	transactionManager->committedTransactions.append(this);
 	database->commit(this);
 
 	delete [] xid;
@@ -286,19 +289,13 @@
 	
 	// Add ourselves to the list of lingering committed transactions
 	
-	Sync syncCommitted(&transactionManager->committedTransactions.syncObject, "Transaction::commit");
-	syncCommitted.lock(Exclusive);
-	transactionManager->committedTransactions.append(this);
-	inList = true;
 	release();
-	//transactionManager->validateDependencies();
 }
 
 
 void Transaction::commitNoUpdates(void)
 {
 	TransactionManager *transactionManager = database->transactionManager;
-	//transactionManager->validateDependencies();
 	state = CommittingReadOnly;
 	addRef();
 	ASSERT(!deferredIndexes);
@@ -318,9 +315,27 @@
 		sync.lock(Exclusive);
 		int initial = dependencies;
 		int count = transactionManager->expungeTransaction(this);
+
+		if (dependencies && n == 0)
+			{
+			Log::debug("dangling dependencies for tid %d\n", transactionId);
+
+			for (Transaction *t = transactionManager->activeTransactions.first; t; t = t->next)
+				{
+				t->print();
+
+				for (int n = 0; n < t->numberStates; ++n)
+					ASSERT(t->states[n].transactionId != transactionId);
+				}
+			}
+		}
+
+	if (dependencies)
+		{
+		Log::debug("dangling dependencies for transaction %d\n", transactionId);
+		dependencies = 0;
 		}
 
-	ASSERT(dependencies == 0);
 	syncActiveTransactions.unlock();
 	state = Committed;
 	syncActive.unlock();
@@ -338,7 +353,6 @@
 	transactionId = 0;
 	state = Available;
 	release();
-	//transactionManager->validateDependencies();
 }
 
 void Transaction::rollback()
@@ -390,15 +404,17 @@
 	xid = NULL;
 	xidLength = 0;
 	
-	Sync sync (&transactionManager->activeTransactions.syncObject, "Transaction::rollback");
-	sync.lock (Exclusive);
+	//Sync sync (&transactionManager->activeTransactions.syncObject, "Transaction::rollback");
+	//sync.lock (Exclusive);
 	++transactionManager->rolledBack;
 	transactionManager->expungeTransaction(this);
+	ASSERT(dependencies == 0);
 	connection = NULL;
-	inList = false;
-	transactionManager->activeTransactions.remove(this);
-	sync.unlock();
-	release();
+	//inList = false;
+	//transactionManager->activeTransactions.remove(this);
+	//sync.unlock();
+	//release();
+	state = Available;
 }
 
 
@@ -616,7 +632,6 @@
     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)
 		{
@@ -634,8 +649,6 @@
 				transaction->releaseDependency();
 			}
 		}
-
-	//database->transactionManager->validateDependencies();
 }
 
 /*
@@ -693,6 +706,8 @@
 		return CommittedAndOlder;
 		}
 
+	ASSERT(transaction->transactionId == transId);
+
 	if (transaction == this)
 		return Us;
 
@@ -861,6 +876,7 @@
 
 int Transaction::release()
 {
+	ASSERT(useCount > dependencies);
 	int count = INTERLOCKED_DECREMENT(useCount);
 
 	if (count == 0)
@@ -1048,6 +1064,7 @@
 
 void Transaction::releaseDependency(void)
 {
+	ASSERT(useCount >= 2);
 	ASSERT(dependencies > 0);
 	ASSERT(state != Available);
 	int count = INTERLOCKED_DECREMENT(dependencies);
@@ -1060,17 +1077,22 @@
 
 void Transaction::fullyCommitted(void)
 {
+	ASSERT(inList);
+
+	if (useCount < 2)
+		Log::debug("Transaction::fullyCommitted: funny use count\n");
+
 	writeComplete();
 	releaseCommittedTransaction();
 }
 
 void Transaction::releaseCommittedTransaction(void)
 {
-	ASSERT(useCount >= 2);
-	int use = release();
+	release();
 
-	if ((use == 1) && (state == Committed) && (dependencies == 0) && !writePending)
-		database->transactionManager->removeCommittedTransaction(this);
+	if ((useCount == 1) && (state == Committed) && (dependencies == 0) && !writePending)
+		if (COMPARE_EXCHANGE(&inList, true, false))
+			database->transactionManager->removeCommittedTransaction(this);
 }
 
 void Transaction::validateDependencies(bool noDependencies)

--- 1.49/storage/falcon/Transaction.h	2007-06-22 13:30:24 -04:00
+++ 1.50/storage/falcon/Transaction.h	2007-06-22 13:30:24 -04:00
@@ -148,7 +148,6 @@
 	bool			writePending;
 	bool			pendingPageWrites;
 	bool			hasLocks;
-	bool			inList;
 	SyncObject		syncActive;
 	SyncObject		syncIndexes;
 	uint64			totalRecordData;	// total bytes of record data for this transaction (unchilled + thawed)
@@ -163,6 +162,7 @@
 	volatile INTERLOCK_TYPE	state;
 	volatile INTERLOCK_TYPE	dependencies;
 	volatile INTERLOCK_TYPE	useCount;
+	volatile INTERLOCK_TYPE	inList;
 
 protected:
 	RecordVersion	*records;
Thread
bk commit into 6.0-falcon tree (jas:1.2591)Jim Starkey22 Jun