List:Commits« Previous MessageNext Message »
From:U-ROWVWADEjas Date:February 8 2008 4:35pm
Subject:bk commit into 6.0 tree (jas:1.2806)
View as plain text  
Below is the list of changes that have just been committed into a local
6.0 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, 2008-02-08 11:35:08-05:00, jas@rowvwade. +10 -0
  Moved record version update validation from 
  Dbb::validateAndUpdateRecord to Section::updateRecord
  so a lock can be help between validation and the
  actual update.  Dbb::validateAndUdateRecord then
  became redundant and was removed.

  storage/falcon/Dbb.cpp@stripped, 2008-02-08 11:32:31-05:00, jas@rowvwade. +0 -13
    Moved record version update validation from 
    Dbb::validateAndUpdateRecord to Section::updateRecord
    so a lock can be help between validation and the
    actual update.  Dbb::validateAndUdateRecord then
    became redundant and was removed.

  storage/falcon/Dbb.h@stripped, 2008-02-08 11:32:31-05:00, jas@rowvwade. +0 -1
    Eliminated declaration for Dbb:validateAndUpdateRecord.

  storage/falcon/SRLUpdateRecords.cpp@stripped, 2008-02-08 11:32:32-05:00, jas@rowvwade. +5 -2
    Added mechanism for a debug "traceRecord".

  storage/falcon/Section.cpp@stripped, 2008-02-08 11:34:54-05:00, jas@rowvwade. +55 -17
    Moved record version update validation from 
    Dbb::validateAndUpdateRecord to Section::updateRecord
    so a lock can be help between validation and the
    actual update.  Dbb::validateAndUdateRecord then
    became redundant and was removed.
    
    Also factor "reserve record number" into separate method
    and created debugging methods for ad hoc usage (currently
    commented out).

  storage/falcon/Section.h@stripped, 2008-02-08 11:34:55-05:00, jas@rowvwade. +5 -0
    Factored out "reserverRecordNumber" as separate method.

  storage/falcon/SerialLog.cpp@stripped, 2008-02-08 11:34:55-05:00, jas@rowvwade. +1 -0
    Added debugging "traceRecord" for debugging serial log
    commits and recoveries.

  storage/falcon/SerialLog.h@stripped, 2008-02-08 11:34:55-05:00, jas@rowvwade. +1 -0
    Added debugging "traceRecord" for debugging serial log
    commits and recoveries.

  storage/falcon/Table.cpp@stripped, 2008-02-08 11:34:56-05:00, jas@rowvwade. +2 -1
    Reserve record number when initiating a delete operation.

  storage/falcon/Transaction.cpp@stripped, 2008-02-08 11:34:56-05:00, jas@rowvwade. +38 -32
    Revised Transaction::commitNoUpdates to back off until
    all dependencies are resolved.

  storage/falcon/TransactionManager.cpp@stripped, 2008-02-08 11:34:56-05:00, jas@rowvwade. +19 -8
    Fixed TransactionManager::findOldestActive to consider
    committed transaction pending completion as well as active
    transactions.

diff -Nrup a/storage/falcon/Dbb.cpp b/storage/falcon/Dbb.cpp
--- a/storage/falcon/Dbb.cpp	2008-01-31 14:25:43 -05:00
+++ b/storage/falcon/Dbb.cpp	2008-02-08 11:32:31 -05:00
@@ -342,19 +342,6 @@ void Dbb::updateBlob(Section *blobSectio
 		}
 }
 
-void Dbb::validateAndUpdateRecord(int32 sectionId, int32 recordId, Stream* stream, TransId transId, bool earlyWrite)
-{
-	Section *section = findSection (sectionId);
-	
-	if (section->table && !section->table->validateUpdate(recordId, transId))
-		return;
-		
-	section->updateRecord (recordId, stream, transId, earlyWrite);
-
-	if (!earlyWrite && !serialLog->recovering && transId)
-		serialLog->setPhysicalBlock(transId);
-}
-
 void Dbb::updateRecord(int32 sectionId, int32 recordId, Stream *stream, TransId transId, bool earlyWrite)
 {
 	Section *section = findSection (sectionId);
diff -Nrup a/storage/falcon/Dbb.h b/storage/falcon/Dbb.h
--- a/storage/falcon/Dbb.h	2008-01-19 12:59:10 -05:00
+++ b/storage/falcon/Dbb.h	2008-02-08 11:32:31 -05:00
@@ -115,7 +115,6 @@ public:
 	void	enableSerialLog();
 	void	rollback (TransId transId, bool updateTransaction);
 	void	updateRecord(int32 sectionId, int32 recordId, Stream *stream, TransId transId, bool earlyWrite);
-	void	validateAndUpdateRecord(int32 sectionId, int32 recordNumber, Stream* stream, TransId transactionId, bool earlyWrite);
 	void	prepareTransaction(TransId transId, int xidLength, const UCHAR *xid);
 	void	commit(Transaction *transaction);
 	void	reportStatistics();
diff -Nrup a/storage/falcon/SRLUpdateRecords.cpp b/storage/falcon/SRLUpdateRecords.cpp
--- a/storage/falcon/SRLUpdateRecords.cpp	2008-01-19 12:59:11 -05:00
+++ b/storage/falcon/SRLUpdateRecords.cpp	2008-02-08 11:32:32 -05:00
@@ -260,7 +260,10 @@ void SRLUpdateRecords::redo(void)
 			int recordNumber = getInt(&p);
 			int length = getInt(&p);
 			log->updateSectionUseVector(sectionId, tableSpaceId, -1);
-			
+
+			if (log->traceRecord && recordNumber == log->traceRecord)
+				print();
+					
 			if (log->bumpSectionIncarnation(sectionId, tableSpaceId, objInUse))
 				{
 				Dbb *dbb = log->getDbb(tableSpaceId);
@@ -335,7 +338,7 @@ void SRLUpdateRecords::commit(void)
 				{
 				Stream stream;
 				stream.putSegment(length, (const char*) p, false);
-				dbb->validateAndUpdateRecord(sectionId, recordNumber, &stream, transactionId, false);
+				dbb->updateRecord(sectionId, recordNumber, &stream, transactionId, false);
 				}
 			else
 				dbb->updateRecord(sectionId, recordNumber, NULL, transactionId, false);
diff -Nrup a/storage/falcon/Section.cpp b/storage/falcon/Section.cpp
--- a/storage/falcon/Section.cpp	2008-01-30 10:35:19 -05:00
+++ b/storage/falcon/Section.cpp	2008-02-08 11:34:54 -05:00
@@ -41,6 +41,7 @@
 #include "Transaction.h"
 #include "PageInventoryPage.h"
 #include "SQLError.h"
+#include "Table.h"
 
 //#define STOP_PAGE	114
 //#define STOP_SECTION	40
@@ -79,6 +80,7 @@ Section::Section(Dbb *pDbb, int32 id, Tr
 	reservedRecordNumbers = NULL;
 	freeLines = NULL;
 	table = NULL;
+	//records = new Bitmap;
 	syncObject.setName("Section::syncObject");
 	syncInsert.setName("Section::syncInsert");
 }
@@ -362,7 +364,7 @@ int32 Section::insertStub(TransId transI
 
 			int indexSlot = indexSequence % dbb->pagesPerSection;
 
-			if (pages->pages [indexSlot])
+			if (pages->pages[indexSlot])
 				{
 				bdb = dbb->handoffPage(bdb, pages->pages [indexSlot], PAGE_record_locator, Exclusive);
 				BDB_HISTORY(bdb);
@@ -374,7 +376,7 @@ int32 Section::insertStub(TransId transI
 
 				dbb->setPrecedence(bdb, newBdb->pageNumber);
 				bdb->mark(transId);
-				pages->pages [indexSlot] = newBdb->pageNumber;
+				pages->pages[indexSlot] = newBdb->pageNumber;
 				bdb->release(REL_HISTORY);
 
 				bdb = newBdb;
@@ -451,7 +453,7 @@ int32 Section::insertStub(TransId transI
 				if (nextLine % linesPerSection == 0)
 					markFull(true, sequence, transId);
 				}
-				
+			
 			return line;
 			}
 
@@ -472,8 +474,8 @@ void Section::reInsertStub(int32 recordN
 {
 	Bdb *bdb = fetchLocatorPage (root, recordNumber, Exclusive, transId);
 	BDB_HISTORY(bdb);
+	
 	if (!bdb)
-		//NOT_YET_IMPLEMENTED;
 		return;
 
 	RecordLocatorPage *locatorPage = (RecordLocatorPage*) bdb->buffer;
@@ -502,16 +504,8 @@ void Section::updateRecord(int32 recordN
 	// If the record number has been reserved, don't bother to delete it.
 
 	if (!stream)
-		{
-		Sync sync (&syncInsert, "Section::updateRecord");
-		sync.lock (Exclusive);
-
-		if (!reservedRecordNumbers)
-			reservedRecordNumbers = new Bitmap;
-
-		reservedRecordNumbers->set (recordNumber);
-		}
-
+		reserveRecordNumber(recordNumber);
+	
 	// Find section page and slot for record number within section
 
 	int32 slot = recordNumber / dbb->linesPerPage;
@@ -524,7 +518,14 @@ void Section::updateRecord(int32 recordN
 	ASSERT (pageNumber);
 	bdb = dbb->handoffPage (bdb, pageNumber, PAGE_record_locator, Exclusive);
 	BDB_HISTORY(bdb);
+	
+	if (!dbb->serialLog->recovering && table && !table->validateUpdate(recordNumber, transId))
+		{
+		bdb->release();
 		
+		return;
+		}
+
 	// We've found the section index page.  Mark it
 
 	bdb->mark(transId);
@@ -791,6 +792,7 @@ bool Section::fetchRecord(int32 recordNu
 {
 	Bdb *bdb = fetchLocatorPage(root, recordNumber, Shared, transId);
 	BDB_HISTORY(bdb);
+	
 	if (!bdb)
 		return false;
 
@@ -1162,9 +1164,10 @@ void Section::expungeRecord(int32 record
 	Sync sync (&syncInsert, "Section::expungeRecord");
 	sync.lock (Exclusive);
 
-	if (reservedRecordNumbers && reservedRecordNumbers->isSet (recordNumber))
+	if (reservedRecordNumbers && reservedRecordNumbers->isSet(recordNumber))
 		{
-		reservedRecordNumbers->clear (recordNumber);
+		reservedRecordNumbers->clear(recordNumber);
+		
 		if (reservedRecordNumbers->count == 0)
 			{
 			reservedRecordNumbers->release();
@@ -1175,7 +1178,7 @@ void Section::expungeRecord(int32 record
 	if (!freeLines)
 		freeLines = new Bitmap;
 
-	freeLines->set (recordNumber);
+	freeLines->set(recordNumber);
 }
 
 void Section::markFull(bool isFull, int sequence, TransId transId)
@@ -1503,3 +1506,38 @@ void Section::redoBlobDelete(Dbb* dbb, i
 	page->setIndexSlot(locatorLine, 0, 0, dbb->pageSize);
 	bdb->release(REL_HISTORY);
 }
+
+void Section::reserveRecordNumber(int32 recordNumber)
+{
+	Sync sync (&syncInsert, "Section::reserveRecordNumber");
+	sync.lock (Exclusive);
+
+	if (!reservedRecordNumbers)
+		reservedRecordNumbers = new Bitmap;
+
+	reservedRecordNumbers->set(recordNumber);
+}
+
+/*** save for debugging
+void Section::setRecordFlag(int32 recordNumber)
+{
+	Sync sync(&syncObject, "Section::setRecordFlag");
+	sync.lock(Exclusive);
+	records->set(recordNumber);
+}
+
+void Section::clearRecordFlag(int32 recordNumber)
+{
+	Sync sync(&syncObject, "Section::clearRecordFlag");
+	sync.lock(Exclusive);
+	records->clear(recordNumber);
+}
+
+bool Section::checkRecordFlag(int32 recordNumber)
+{
+	Sync sync(&syncObject, "Section::checkRecordFlag");
+	sync.lock(Shared);
+	
+	return records->isSet(recordNumber);
+}
+***/
diff -Nrup a/storage/falcon/Section.h b/storage/falcon/Section.h
--- a/storage/falcon/Section.h	2008-01-19 12:59:11 -05:00
+++ b/storage/falcon/Section.h	2008-02-08 11:34:55 -05:00
@@ -58,10 +58,14 @@ public:
 	void		storeRecord (RecordLocatorPage *recordLocatorPage, int32 indexPageNumber, RecordIndex *index, Stream *stream, TransId transId, bool earlyWrite);
 	int			deleteLine (Bdb *bdb, int line, int32 sectionPageNumber, TransId transId, RecordLocatorPage *locatorPage, int locatorLine);
 	void		updateRecord (int32 recordId, Stream *stream, TransId transId, bool earlyWrite);
+	void		reserveRecordNumber(int32 recordNumber);
 	int32		insertStub (TransId transId);
 	int32		getSectionRoot();
 	Bdb*		getSectionPage(int sequence, LockType lockType, TransId transId);
 	Bdb*		fetchLocatorPage (int32 root, int32 recordNumber, LockType lockType, TransId transId);
+	//void		setRecordFlag(int32 recordNumber);
+	//void		clearRecordFlag(int32 recordNumber);
+	//bool		checkRecordFlag(int32 recordNumber);
 
 	static void		redoSectionPromotion(Dbb* dbb, int sectionId, int32 rootPageNumber, int pageLength, const UCHAR* pageData, int32 newPageNumber);
 	void			redoRecordLocatorPage(int sequence, int32 pageNumber, bool isPostFlush);
@@ -94,6 +98,7 @@ public:
 	Table			*table;						// if known
 	Bitmap			*reservedRecordNumbers;
 	Bitmap			*freeLines;
+	//Bitmap		*records;					// save for debugging
 	short			level;
 	SparseArray<int,100>	sectionPages;
 };
diff -Nrup a/storage/falcon/SerialLog.cpp b/storage/falcon/SerialLog.cpp
--- a/storage/falcon/SerialLog.cpp	2008-01-28 15:40:24 -05:00
+++ b/storage/falcon/SerialLog.cpp	2008-02-08 11:34:55 -05:00
@@ -96,6 +96,7 @@ SerialLog::SerialLog(Database *db, JStri
 	recoverySections = NULL;
 	recoveryPhase = 0;
 	tracePage = TRACE_PAGE;
+	traceRecord = 0;
 	chilledRecords = 0;
 	chilledBytes = 0;
 	windowReads = 0;
diff -Nrup a/storage/falcon/SerialLog.h b/storage/falcon/SerialLog.h
--- a/storage/falcon/SerialLog.h	2008-01-24 15:00:01 -05:00
+++ b/storage/falcon/SerialLog.h	2008-02-08 11:34:55 -05:00
@@ -218,6 +218,7 @@ public:
 	uint64				priorDelta;
 	int					priorWrites;
 	int32				tracePage;
+	int32				traceRecord;
 	uint32				chilledRecords;
 	uint64				chilledBytes;
 	
diff -Nrup a/storage/falcon/Table.cpp b/storage/falcon/Table.cpp
--- a/storage/falcon/Table.cpp	2008-02-05 16:50:30 -05:00
+++ b/storage/falcon/Table.cpp	2008-02-08 11:34:56 -05:00
@@ -1398,7 +1398,8 @@ void Table::deleteRecord(Transaction * t
 			
 		transaction->addRecord(record);
 		}
-		
+	
+	dataSection->reserveRecordNumber(record->recordNumber);
 	record->release();
 	fireTriggers(transaction, PostDelete, orgRecord, NULL);
 }
diff -Nrup a/storage/falcon/Transaction.cpp b/storage/falcon/Transaction.cpp
--- a/storage/falcon/Transaction.cpp	2008-02-05 16:50:30 -05:00
+++ b/storage/falcon/Transaction.cpp	2008-02-08 11:34:56 -05:00
@@ -338,28 +338,29 @@ void Transaction::commitNoUpdates(void)
 	
 	Sync sync(&syncObject, "Transaction::commitNoUpdates");
 	sync.lock(Exclusive);
-
-	if (dependencies)
+	Thread *thread = NULL;
+	int wait = 1;
+	
+	for (int n = 0; dependencies && n < 10; ++n)
 		{
 		transactionManager->expungeTransaction(this);
 	
+		if (!dependencies)
+			break;
+			
 		// There is a tiny race condition between another thread releasing a dependency and
-		// TransactionManager::expungeTransaction doing thte same thing.  So spin.
+		// TransactionManager::expungeTransaction doing the same thing.  So spin.
 		
-		if (dependencies)
+		if (thread)
 			{
-			Thread *thread = NULL;
-			
-			for (int n = 0; dependencies && n < 10; ++n)
-				if (thread)
-					thread->sleep(1);
-				else
-					thread = Thread::getThread("Transaction::commitNoUpdates");
-
-			ASSERT(dependencies == 0);
+			thread->sleep(wait);
+			wait <<= 1;
 			}
+		else
+			thread = Thread::getThread("Transaction::commitNoUpdates");
 		}
-		
+	
+	ASSERT(dependencies == 0);	
 	sync.unlock();
 	delete [] xid;
 	xid = NULL;
@@ -464,12 +465,13 @@ 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);
-	int n = 0;
 	
-	for (TransState *s = states, *end = s + numberStates; s < end; ++s, ++n)
+	for (TransState *s = states, *end = s + numberStates; s < end; ++s)
 		if (s->transaction == transaction)
 			{
 			if (COMPARE_EXCHANGE_POINTER(&s->transaction, transaction, NULL))
@@ -749,25 +751,29 @@ void Transaction::releaseDependencies()
 
 void Transaction::commitRecords()
 {
-	RecordVersion *recordList = firstRecord;
-	
-	//if (COMPARE_EXCHANGE(&cleanupNeeded, (INTERLOCK_TYPE) 1, (INTERLOCK_TYPE) 0))
-	if (recordList && COMPARE_EXCHANGE_POINTER(&firstRecord, recordList, NULL))
+	for (RecordVersion *recordList; recordList = firstRecord;)
 		{
-		chillPoint = &firstRecord;
-		recordPtr = &firstRecord;
-		lastRecord = NULL;
-
-		for (RecordVersion *record; (record = recordList);)
+		if (recordList && COMPARE_EXCHANGE_POINTER(&firstRecord, recordList, NULL))
 			{
-			ASSERT (record->useCount > 0);
-			recordList = record->nextInTrans;
-			record->nextInTrans = NULL;
-			record->prevInTrans = NULL;
-			record->commit();
-			record->release();
-			committedRecords++;
+			chillPoint = &firstRecord;
+			recordPtr = &firstRecord;
+			lastRecord = NULL;
+
+			for (RecordVersion *record; (record = recordList);)
+				{
+				ASSERT (record->useCount > 0);
+				recordList = record->nextInTrans;
+				record->nextInTrans = NULL;
+				record->prevInTrans = NULL;
+				record->commit();
+				record->release();
+				committedRecords++;
+				}
+			
+			return;
 			}
+			
+		Log::debug("Transaction::commitRecords failed\n");
 		}
 }
 
diff -Nrup a/storage/falcon/TransactionManager.cpp b/storage/falcon/TransactionManager.cpp
--- a/storage/falcon/TransactionManager.cpp	2008-02-05 16:50:31 -05:00
+++ b/storage/falcon/TransactionManager.cpp	2008-02-08 11:34:56 -05:00
@@ -70,18 +70,28 @@ TransactionManager::~TransactionManager(
 
 TransId TransactionManager::findOldestActive()
 {
-	Sync sync (&activeTransactions.syncObject, "TransactionManager::findOldestActive");
-	sync.lock (Shared);
+	Sync syncCommitted(&committedTransactions.syncObject, "TransactionManager::findOldestActive");
+	syncCommitted.lock(Shared);
+	TransId oldestActive = transactionSequence;
+	
+	for (Transaction *trans = committedTransactions.first; trans; trans = trans->next)
+		oldestActive = MIN(trans->transactionId, oldestActive);
+
+	syncCommitted.unlock();
+	Sync sync(&activeTransactions.syncObject, "TransactionManager::findOldestActive");
+	sync.lock(Shared);
 	Transaction *oldest = findOldest();
 
 	if (oldest)
 		{
-		//oldest->scavenged = false;
-	
-		return oldest->oldestActive;
+		//Log::debug("Oldest transaction %d, oldest ancestor %d, oldest committed %d\n",  oldest->transactionId, oldest->oldestActive, oldestActive);
+					
+		return MIN(oldest->oldestActive, oldestActive);
 		}
-		
-	return transactionSequence;
+	
+	//Log::debug("No active, current %d, oldest committed %d\n", transactionSequence, oldestActive);
+	
+	return oldestActive;
 }
 
 Transaction* TransactionManager::findOldest(void)
@@ -374,7 +384,8 @@ void TransactionManager::expungeTransact
 	syncActiveTrans.lock(Shared);
 
 	for (Transaction *trans = activeTransactions.first; trans; trans = trans->next)
-		if (trans->state != Available && trans->transactionId > transaction->transactionId)
+		if ((trans->state != Available && trans->state != Initializing))
+			 //&& trans->transactionId > transaction->transactionId)
 			trans->expungeTransaction(transaction);
 }
 
Thread
bk commit into 6.0 tree (jas:1.2806)U-ROWVWADEjas8 Feb