From: Date: September 10 2008 11:25pm Subject: bzr commit into mysql-6.0-falcon branch (klewis:2822) List-Archive: http://lists.mysql.com/commits/53740 Message-Id: <200809102125.m8ALP3Fa004042@mail.mysql.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit #At file:///C:/Work/bzr/Merge/mysql-6.0-falcon-team/ 2822 Kevin Lewis 2008-09-10 Various cleanup changes modified: storage/falcon/Cache.cpp storage/falcon/Cache.h storage/falcon/Index.cpp storage/falcon/SerialLogFile.cpp storage/falcon/Transaction.cpp per-file messages: storage/falcon/Cache.cpp Cleanup code. Add blank lines, move comments. syncHashTable[loop].setName does not need to be called twice. The second call at the bottome of teh Cache constructor is correct because the deadlock detector eeds to see each of these SyncObjects as the same one, because they can be randomly at runtime. Be sure that each declaration of Sync has a unique location string for the syncHandler. storage/falcon/Cache.h spacing storage/falcon/Index.cpp Add commented lines where we should start refCounting the pointer from the Index::deferredIndexes queue into each of its deferredIndexes. Good practice, but not required since the pointer from the DeferredIndex::index indicates whether there is a pointer from the index back. storage/falcon/SerialLogFile.cpp white space cleanup storage/falcon/Transaction.cpp Clarify unique location strings for the syncHandler. === modified file 'storage/falcon/Cache.cpp' --- a/storage/falcon/Cache.cpp 2008-09-09 20:57:57 +0000 +++ b/storage/falcon/Cache.cpp 2008-09-10 21:24:50 +0000 @@ -78,7 +78,7 @@ Cache::Cache(Database *db, int pageSz, i unsigned int highBit; for (highBit=0x01; highBit < (unsigned int)hashSz; highBit= highBit << 1) { } - // if there are more than 4096 buckets then lets round down + // If there are more than 4096 buckets then lets round down // else lets round up if (highBit >= 0x00001000) { // use power of two rounded down @@ -98,18 +98,15 @@ Cache::Cache(Database *db, int pageSz, i hashTable = new Bdb* [hashSize]; memset (hashTable, 0, sizeof (Bdb*) * hashSize); #ifdef DEBUG_SYNC_HASH_TABLE_SIZE - syncHashTable = new SyncObject [DEBUG_SYNC_HASH_TABLE_SIZE]; + syncHashTable = new SyncObject [DEBUG_SYNC_HASH_TABLE_SIZE]; for (int loop = 0; loop < DEBUG_SYNC_HASH_TABLE_SIZE; loop ++) syncHashTable[loop].setName("Cache::syncHashTable"); #else /* DEBUG_SYNC_HASH_TABLE_SIZE */ - syncHashTable = new SyncObject [hashSize]; + syncHashTable = new SyncObject [hashSize]; for (int loop = 0; loop < hashSize; loop ++) - { - char tmpName[128]; - snprintf(tmpName,120,"Cache::syncHashTable[%d]",loop); - syncHashTable[loop].setName(tmpName); - } + syncHashTable[loop].setName("Cache::syncHashTable"); #endif /* DEBUG_SYNC_HASH_TABLE_SIZE */ + sectorCache = new SectorCache(sectorCacheSize / SECTOR_BUFFER_SIZE, pageSize); uint64 n = ((uint64) pageSize * numberBuffers + cacheHunkSize - 1) / cacheHunkSize; @@ -300,8 +297,9 @@ Bdb* Cache::fetchPage(Dbb *dbb, int32 pa int slot = PAGENUM_2_SLOT(pageNumber); Sync lockHash (&syncHashTable[PAGENUM_2_LOCK_INDEX(pageNumber, slot)], "Cache::fetchPage"); + // Assume we'll be inserting this new BDB. Set new page number. */ + bdbAvailable = getFreeBuffer(); - /* assume we'll be inserting this new BDB. Set new page number. */ bdbAvailable->pageNumber = pageNumber; bdbAvailable->dbb = dbb; @@ -394,6 +392,7 @@ Bdb* Cache::fakePage(Dbb *dbb, int32 pag #endif /* If we already have a buffer for this, we're done */ + bdb = lockFindBdbIncrementUseCount(dbb, pageNumber); if (!bdb) { @@ -408,8 +407,9 @@ Bdb* Cache::fakePage(Dbb *dbb, int32 pag int slot = PAGENUM_2_SLOT(pageNumber); Sync lockHash (&syncHashTable[PAGENUM_2_LOCK_INDEX(pageNumber, slot)], "Cache::fetchPage"); + // Assume we'll be inserting this new BDB. Set new page number. + bdbAvailable = getFreeBuffer(); - /* assume we'll be inserting this new BDB. Set new page number. */ bdbAvailable->pageNumber = pageNumber; bdbAvailable->dbb = dbb; @@ -519,7 +519,7 @@ void Cache::moveToHeadAlreadyLocked(Bdb Bdb* Cache::getFreeBuffer(void) { - Sync bufferQueueLock (&bufferQueue.syncObject, "Cache::getFreeBuffer"); + Sync bufferQueueLock (&bufferQueue.syncObject, "Cache::getFreeBuffer(queue)"); unsigned int count; Bdb *bdb; @@ -557,6 +557,7 @@ Bdb* Cache::getFreeBuffer(void) #endif // CHECK_STALLED_BDB } } + if (!bdb) // find a candidate that is NOT in use, could be dirty for (bdb = bufferQueue.last; bdb; bdb = bdb->prior) @@ -574,7 +575,7 @@ Bdb* Cache::getFreeBuffer(void) if (bdb->pageNumber >= 0) { int slotRemove = PAGENUM_2_SLOT(bdb->pageNumber); - Sync lockHashRemove (&syncHashTable[PAGENUM_2_LOCK_INDEX(bdb->pageNumber, slotRemove)], "Cache::getFreeBuffer"); + Sync lockHashRemove (&syncHashTable[PAGENUM_2_LOCK_INDEX(bdb->pageNumber, slotRemove)], "Cache::getFreeBuffer(remove)"); lockHashRemove.lock(Exclusive); if (bdb->useCount != 1) @@ -849,9 +850,7 @@ bool Cache::hasDirtyPages(Dbb *dbb) for (Bdb *bdb = firstDirty; bdb; bdb = bdb->nextDirty) if (bdb->dbb == dbb) - { return true; - } return false; } @@ -915,9 +914,9 @@ void Cache::ioThread(void* arg) void Cache::ioThread(void) { - Sync syncThread(&syncThreads, "Cache::ioThread"); + Sync syncThread(&syncThreads, "Cache::ioThread(threads)"); syncThread.lock(Shared); - Sync flushLock(&syncFlush, "Cache::ioThread"); + Sync flushLock(&syncFlush, "Cache::ioThread(flush)"); Priority priority(database->ioScheduler); Thread *thread = Thread::getThread("Cache::ioThread"); UCHAR *rawBuffer = new UCHAR[ASYNC_BUFFER_SIZE]; === modified file 'storage/falcon/Cache.h' --- a/storage/falcon/Cache.h 2008-09-02 16:08:11 +0000 +++ b/storage/falcon/Cache.h 2008-09-10 21:24:50 +0000 @@ -87,21 +87,21 @@ public: SyncObject syncObject; PageWriter *pageWriter; - Database *database; + Database *database; int numberBuffers; - bool panicShutdown; - bool flushing; + bool panicShutdown; + bool flushing; protected: - void moveToHead (Bdb *bdb); - void moveToHeadAlreadyLocked (Bdb *bdb); + void moveToHead (Bdb *bdb); + void moveToHeadAlreadyLocked (Bdb *bdb); Bdb* getFreeBuffer(void); Bdb* findBdb(Dbb* dbb, int32 pageNumber, int slot); Bdb* findBdb(Dbb* dbb, int32 pageNumber); Bdb* lockFindBdbIncrementUseCount(Dbb* dbb, int32 pageNumber); Bdb* lockFindBdbIncrementUseCount(int32 pageNumber, int slot); - int64 flushArg; + int64 flushArg; Bdb *bdbs; Bdb *endBdbs; Queue bufferQueue; @@ -110,7 +110,7 @@ protected: Bdb *firstDirty; Bdb *lastDirty; Bitmap *flushBitmap; - char **bufferHunks; + char **bufferHunks; Thread **ioThreads; SectorCache *sectorCache; SyncObject syncFlush; === modified file 'storage/falcon/Index.cpp' --- a/storage/falcon/Index.cpp 2008-08-19 03:33:01 +0000 +++ b/storage/falcon/Index.cpp 2008-09-10 21:24:50 +0000 @@ -123,6 +123,7 @@ Index::~Index() { ASSERT(deferredIndex->index == this); deferredIndex->detachIndex(); +// deferredIndex->releaseRef(); } } @@ -277,6 +278,7 @@ DeferredIndex *Index::getDeferredIndex(T deferredIndex = new DeferredIndex(this, transaction); sync.lock(Exclusive); deferredIndexes.append(deferredIndex); +// deferredIndex->addRef(); sync.unlock(); transaction->add(deferredIndex); @@ -843,6 +845,7 @@ void Index::detachDeferredIndex(Deferred Sync sync(&deferredIndexes.syncObject, "Index::detachDeferredIndex(1)"); sync.lock(Exclusive); deferredIndexes.remove(deferredIndex); +// deferredIndex->releaseRef(); sync.unlock(); if ( (database->configuration->useDeferredIndexHash) === modified file 'storage/falcon/SerialLogFile.cpp' --- a/storage/falcon/SerialLogFile.cpp 2008-09-05 22:36:19 +0000 +++ b/storage/falcon/SerialLogFile.cpp 2008-09-10 21:24:50 +0000 @@ -128,7 +128,7 @@ void SerialLogFile::open(JString filenam if (create) - handle = ::open(filename, O_RDWR | O_BINARY | O_CREAT|O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); + handle = ::open(filename, O_RDWR | O_BINARY | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); else handle = ::open(filename, O_RDWR | O_BINARY); === modified file 'storage/falcon/Transaction.cpp' --- a/storage/falcon/Transaction.cpp 2008-09-10 19:51:03 +0000 +++ b/storage/falcon/Transaction.cpp 2008-09-10 21:24:50 +0000 @@ -397,7 +397,7 @@ void Transaction::rollback() // Rollback pending record versions from newest to oldest in case // there are multiple record versions on a prior record chain - Sync syncRec(&syncRecords, "Transaction::rollback(1.5)"); + Sync syncRec(&syncRecords, "Transaction::rollback(records)"); syncRec.lock(Exclusive); while (firstRecord) @@ -451,7 +451,7 @@ void Transaction::rollback() xidLength = 0; } - Sync syncActiveTransactions (&transactionManager->activeTransactions.syncObject, "Transaction::rollback(2)"); + Sync syncActiveTransactions (&transactionManager->activeTransactions.syncObject, "Transaction::rollback(active)"); syncActiveTransactions.lock (Exclusive); ++transactionManager->rolledBack;