List:Commits« Previous MessageNext Message »
From:cpowers Date:February 10 2008 7:39pm
Subject:bk commit into 6.0 tree (cpowers:1.2810) BUG#33634
View as plain text  
Below is the list of changes that have just been committed into a local
6.0 repository of cpowers. When cpowers 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-10 13:39:01-06:00, cpowers@stripped +6 -0
  Bug#33634, Falcon queries are starved for a long time
  
  Until Falcon supports multiple system transactions, concurrent access to the single system
  transaction must be serialized at some points, primarily within create and delete table.  
  - Added sync object to protect transaction savepoint lists.
  - Serialized system transaction access with an exclusive lock on syncSysConnection
    in Statement::createTable and Table::dropTable.
  - Enabled oldesActiveSavepointId in Record::scavenge().
  
  Note that care must be taken to ensure that Database::syncTables is acquired before Database::syncSysConnection.

  storage/falcon/Database.cpp@stripped, 2008-02-10 13:38:56-06:00, cpowers@stripped +1 -1
    Use getSystemTransaction() instead of systemConnection->getTransaction()

  storage/falcon/RecordVersion.cpp@stripped, 2008-02-10 13:38:56-06:00, cpowers@stripped +3 -3
    Until now, RecordVersion::scavenge() ignored the oldestActiveSavePointId parameter. However, there are
    two instances (Table::update 1&2) where the savePointId is passed explicitly to scavenge(), so
    the oldestActiveSavePointId parameter is now used in place of RecordVersion::savePointId.

  storage/falcon/Statement.cpp@stripped, 2008-02-10 13:38:56-06:00, cpowers@stripped +3 -0
    Protect system transaction and Table::create within exclusive lock of syncSysConnection.

  storage/falcon/Table.cpp@stripped, 2008-02-10 13:38:56-06:00, cpowers@stripped +2 -2
    Change syncSysConnection shared lock to exclusive lock in Table::Drop.

  storage/falcon/Transaction.cpp@stripped, 2008-02-10 13:38:56-06:00, cpowers@stripped +54 -31
    Added syncSavepoints to allow concurrent access to savePoints and freeSavePoints.

  storage/falcon/Transaction.h@stripped, 2008-02-10 13:38:56-06:00, cpowers@stripped +4 -3
    Minor style change.

diff -Nrup a/storage/falcon/Database.cpp b/storage/falcon/Database.cpp
--- a/storage/falcon/Database.cpp	2008-01-26 16:52:21 -06:00
+++ b/storage/falcon/Database.cpp	2008-02-10 13:38:56 -06:00
@@ -1810,7 +1810,7 @@ void Database::ticker()
 
 int Database::createSequence(int64 initialValue)
 {
-	Transaction *transaction = systemConnection->getTransaction();
+	Transaction *transaction = getSystemTransaction();
 
 	return dbb->createSequence (initialValue, TRANSACTION_ID(transaction));
 }
diff -Nrup a/storage/falcon/RecordVersion.cpp b/storage/falcon/RecordVersion.cpp
--- a/storage/falcon/RecordVersion.cpp	2008-01-29 12:00:08 -06:00
+++ b/storage/falcon/RecordVersion.cpp	2008-02-10 13:38:56 -06:00
@@ -174,9 +174,9 @@ void RecordVersion::scavenge(TransId tar
 	Record *rec = priorVersion;
 	Record *ptr = NULL;
 	
-	// Loop through versions 'till we find somebody rec (or run out of versions looking
+	// Remove prior record versions assigned to the savepoint being released
 	
-	for (; rec && rec->getTransactionId() == targetTransactionId && rec->getSavePointId() >= savePointId;
+	for (; rec && rec->getTransactionId() == targetTransactionId && rec->getSavePointId() >= oldestActiveSavePointId;
 		  rec = rec->getPriorVersion())
 		{
 		ptr = rec;
@@ -186,7 +186,7 @@ void RecordVersion::scavenge(TransId tar
 		Transaction *trans = rec->getTransaction();
 
 		if (trans)
-			trans->removeRecord( (RecordVersion*) rec);
+			trans->removeRecord((RecordVersion*) rec);
 		}
 	
 	// If we didn't find anyone, there's nothing to do
diff -Nrup a/storage/falcon/Statement.cpp b/storage/falcon/Statement.cpp
--- a/storage/falcon/Statement.cpp	2007-12-04 15:16:23 -06:00
+++ b/storage/falcon/Statement.cpp	2008-02-10 13:38:56 -06:00
@@ -221,10 +221,13 @@ void Statement::createTable(Syntax * syn
 
 	if (!database->formatting)
 		{
+		Sync sync (&database->syncSysConnection, "Statement::createTable");
+		sync.lock(Exclusive);
 		Transaction *sysTransaction = database->getSystemTransaction();
 		table->create ((connection == database->systemConnection) ? "SYSTEM TABLE" : "TABLE", sysTransaction);
 		table->save();
 		database->roleModel->addUserPrivilege (connection->user, table, ALL_PRIVILEGES);
+		sync.unlock();
 		database->commitSystemTransaction();
 		}
 
diff -Nrup a/storage/falcon/Table.cpp b/storage/falcon/Table.cpp
--- a/storage/falcon/Table.cpp	2008-02-08 11:46:37 -06:00
+++ b/storage/falcon/Table.cpp	2008-02-10 13:38:56 -06:00
@@ -1480,7 +1480,8 @@ void Table::drop(Transaction *transactio
 
 
 	Sync sync(&database->syncSysConnection, "Table::drop");
-	sync.lock(Shared);
+	//sync.lock(Shared);
+	sync.lock(Exclusive);
 	Transaction *sysTransaction = database->getSystemTransaction();
 
 	for (Index *index = indexes; index; index = index->next)
@@ -1500,7 +1501,6 @@ void Table::drop(Transaction *transactio
 		statement = database->prepareStatement(sql);
 		statement->setString(1, schemaName);
 		statement->setString(2, name);
-		//int count = 
 		statement->executeUpdate();
 		statement->close();
 		}
diff -Nrup a/storage/falcon/Transaction.cpp b/storage/falcon/Transaction.cpp
--- a/storage/falcon/Transaction.cpp	2008-02-08 11:58:41 -06:00
+++ b/storage/falcon/Transaction.cpp	2008-02-10 13:38:56 -06:00
@@ -126,6 +126,7 @@ void Transaction::initialize(Connection*
 	syncObject.setName("Transaction::syncObject");
 	syncActive.setName("Transaction::syncActive");
 	syncIndexes.setName("Transaction::syncIndexes");
+	syncIndexes.setName("Transaction::syncSavepoints");
 	//scavenged = false;
 	
 	if (seq == 0)
@@ -212,7 +213,7 @@ Transaction::~Transaction()
 		removeRecord(record);
 		}
 	
-	releaseSavePoints();
+	releaseSavepoints();
 	
 	if (deferredIndexes)
 		{
@@ -230,7 +231,7 @@ void Transaction::commit()
 	if (!isActive())
 		throw SQLEXCEPTION (RUNTIME_ERROR, "transaction is not active");
 
-	releaseSavePoints();
+	releaseSavepoints();
 
 	if (!hasUpdates)
 		{
@@ -395,7 +396,7 @@ void Transaction::rollback()
 		releaseDeferredIndexes();
 		}
 		
-	releaseSavePoints();
+	releaseSavepoints();
 	TransactionManager *transactionManager = database->transactionManager;
 	Transaction *rollbackTransaction = transactionManager->rolledBackTransaction;
 	//state = RolledBack;
@@ -465,10 +466,6 @@ void Transaction::rollback()
 
 void Transaction::expungeTransaction(Transaction * transaction)
 {
-	//Sync sync(&syncObject, "Transaction::expungeTransaction");
-	//sync.lock(Shared);
-	//TransId oldId = transactionId;
-	//int orgState = state;
 	ASSERT(states != NULL || numberStates == 0);
 	
 	for (TransState *s = states, *end = s + numberStates; s < end; ++s)
@@ -487,7 +484,7 @@ void Transaction::prepare(int xidLen, co
 		throw SQLEXCEPTION (RUNTIME_ERROR, "transaction is not active");
 
 	Log::log(LogXARecovery, "Prepare transaction %d: xidLen = %d\n", transactionId, xidLen);
-	releaseSavePoints();
+	releaseSavepoints();
 
 	xidLength = xidLen;
 
@@ -751,7 +748,7 @@ void Transaction::releaseDependencies()
 
 void Transaction::commitRecords()
 {
-	for (RecordVersion *recordList; recordList = firstRecord;)
+	for (RecordVersion *recordList; (recordList = firstRecord);)
 		{
 		if (recordList && COMPARE_EXCHANGE_POINTER(&firstRecord, recordList, NULL))
 			{
@@ -994,10 +991,16 @@ int Transaction::release()
 
 int Transaction::createSavepoint()
 {
+	Sync sync(&syncSavepoints, "Transaction::createSavepoint");
 	SavePoint *savePoint;
 	
 	ASSERT((savePoints || freeSavePoints) ? (savePoints != freeSavePoints) : true);
 	
+	// System transactions require an exclusive lock for concurrent access
+	
+	if (systemTransaction)
+		sync.lock(Exclusive);
+	
 	if ( (savePoint = freeSavePoints) )
 		freeSavePoints = savePoint->next;
 	else
@@ -1015,6 +1018,13 @@ int Transaction::createSavepoint()
 
 void Transaction::releaseSavepoint(int savePointId)
 {
+	Sync sync(&syncSavepoints, "Transaction::releaseSavepoint");
+
+	// System transactions require an exclusive lock for concurrent access
+
+	if (systemTransaction)
+		sync.lock(Exclusive);
+	
 	for (SavePoint **ptr = &savePoints, *savePoint; (savePoint = *ptr); ptr = &savePoint->next)
 		if (savePoint->id == savePointId)
 			{
@@ -1041,9 +1051,43 @@ void Transaction::releaseSavepoint(int s
 	//throw SQLError(RUNTIME_ERROR, "invalid savepoint");
 }
 
+void Transaction::releaseSavepoints(void)
+{
+	Sync sync(&syncSavepoints, "Transaction::releaseSavepoints");
+	SavePoint *savePoint;
+	
+	// System transactions require an exclusive lock for concurrent access
+
+	if (systemTransaction)
+		sync.lock(Exclusive);
+	
+	
+	while ( (savePoint = savePoints) )
+		{
+		savePoints = savePoint->next;
+		
+		if (savePoint < localSavePoints || savePoint >= localSavePoints + LOCAL_SAVE_POINTS)
+			delete savePoint;
+		}
+
+	while ( (savePoint = freeSavePoints) )
+		{
+		freeSavePoints = savePoint->next;
+		
+		if (savePoint < localSavePoints || savePoint >= localSavePoints + LOCAL_SAVE_POINTS)
+			delete savePoint;
+		}
+}
+
 void Transaction::rollbackSavepoint(int savePointId)
 {
-	SavePoint *savePoint = savePoints;
+	Sync sync(&syncSavepoints, "Transaction::rollbackSavepoints");
+	SavePoint *savePoint;
+
+	// System transactions require an exclusive lock for concurrent access
+
+	if (systemTransaction)
+		sync.lock(Exclusive);
 
 	// Be sure the target savepoint is valid before rollong them back.
 	
@@ -1283,27 +1327,6 @@ void Transaction::validateDependencies(b
 			ASSERT(!noDependencies);
 			ASSERT(state->transaction->transactionId == state->transactionId);
 			}
-}
-
-void Transaction::releaseSavePoints(void)
-{
-	SavePoint *savePoint;
-	
-	while ( (savePoint = savePoints) )
-		{
-		savePoints = savePoint->next;
-		
-		if (savePoint < localSavePoints || savePoint >= localSavePoints + LOCAL_SAVE_POINTS)
-			delete savePoint;
-		}
-
-	while ( (savePoint = freeSavePoints) )
-		{
-		freeSavePoints = savePoint->next;
-		
-		if (savePoint < localSavePoints || savePoint >= localSavePoints + LOCAL_SAVE_POINTS)
-			delete savePoint;
-		}
 }
 
 void Transaction::printBlockage(void)
diff -Nrup a/storage/falcon/Transaction.h b/storage/falcon/Transaction.h
--- a/storage/falcon/Transaction.h	2008-01-22 16:40:59 -06:00
+++ b/storage/falcon/Transaction.h	2008-02-10 13:38:56 -06:00
@@ -112,9 +112,10 @@ public:
 	bool		hasUncommittedRecords(Table* table);
 	void		writeComplete(void);
 	void		releaseDependency(void);
-	void		rollbackSavepoint (int savepointId);
-	void		releaseSavepoint(int savepointId);
 	int			createSavepoint();
+	void		releaseSavepoint(int savepointId);
+	void		releaseSavepoints(void);
+	void		rollbackSavepoint (int savepointId);
 	void		scavengeRecords(int ageGroup);
 	void		add(DeferredIndex* deferredIndex);
 	void		initialize(Connection* cnct, TransId seq);
@@ -130,7 +131,6 @@ public:
 	void		releaseCommittedTransaction(void);
 	void		commitNoUpdates(void);
 	void		validateDependencies(bool noDependencies);
-	void		releaseSavePoints(void);
 	void		printBlocking(int level);
 	void		releaseDeferredIndexes(void);
 	void		releaseDeferredIndexes(Table* table);
@@ -172,6 +172,7 @@ public:
 	SyncObject		syncActive;
 	SyncObject		syncIndexes;
 	SyncObject		syncObject;
+	SyncObject		syncSavepoints;
 	uint64			totalRecordData;	// total bytes of record data for this transaction (unchilled + thawed)
 	uint32			totalRecords;		// total record count
 	uint32			chilledRecords;		// total chilled record count
Thread
bk commit into 6.0 tree (cpowers:1.2810) BUG#33634cpowers10 Feb