From: Date: August 17 2008 12:04am Subject: bzr commit into mysql-6.0-falcon branch (cpowers:2788) Bug#38044 List-Archive: http://lists.mysql.com/commits/51810 X-Bug: 38044 Message-Id: <20080816220440.15AAF1DB072A@xeno.mysql.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit #At file:///home/cpowers/work/dev/dev-04a/mysql/ 2788 Christopher Powers 2008-08-16 Bug#38044 Falcon crash in StorageTable::compareKey Removed debugging code Added StorageTableShare::syncIndexes modified: storage/falcon/Index.cpp storage/falcon/Index.h storage/falcon/StorageTable.cpp storage/falcon/StorageTable.h storage/falcon/StorageTableShare.cpp storage/falcon/StorageTableShare.h storage/falcon/Table.cpp storage/falcon/ha_falcon.cpp per-file messages: storage/falcon/Index.cpp Removed debug code storage/falcon/Index.h Removed debug code storage/falcon/StorageTable.cpp Removed debug code Renamed haveShareLock to indexesLocked storage/falcon/StorageTable.h Removed debug code Renamed haveShareLock to indexesLocked storage/falcon/StorageTableShare.cpp Removed debug code Added syncIndexes storage/falcon/StorageTableShare.h Removed debug code Added syncIndexes storage/falcon/Table.cpp Added comments storage/falcon/ha_falcon.cpp Removed debug code Lock StorageTableShare::syncIndexes for index operations === modified file 'storage/falcon/Index.cpp' --- a/storage/falcon/Index.cpp 2008-08-16 18:06:36 +0000 +++ b/storage/falcon/Index.cpp 2008-08-16 22:04:29 +0000 @@ -85,7 +85,7 @@ Index::Index(Table * tbl, const char * i void Index::init(Table *tbl, const char *indexName, int indexType, int count) { - useCount = 1; + // useCount = 1; // debug table = tbl; database = table->database; dbb = table->dbb; @@ -117,7 +117,7 @@ void Index::init(Table *tbl, const char Index::~Index() { - ASSERT(useCount <= 2); + // ASSERT(useCount <= 2); // debug if (deferredIndexes.first) { @@ -1144,6 +1144,7 @@ void Index::scanDIHash(IndexKey* scanKey } } +#if 0 //debug void Index::lock(bool exclusiveLock) { syncObject.lock(NULL, (exclusiveLock) ? Exclusive : Shared); @@ -1170,7 +1171,7 @@ void Index::release() Table *t = table; const char *tableName = table->name; ***/ - //delete this; //cwp disabled for debug + //delete this; // disabled for debug } } - +#endif === modified file 'storage/falcon/Index.h' --- a/storage/falcon/Index.h 2008-08-16 18:06:36 +0000 +++ b/storage/falcon/Index.h 2008-08-16 22:04:29 +0000 @@ -129,10 +129,13 @@ public: Index(Table *tbl, const char *indexName, int indexType, int id, int numberFields); virtual ~Index(); + /*** debug virtual void lock(bool exclusiveLock); virtual void unlock(void); void release(); void addRef(); + volatile INTERLOCK_TYPE useCount; + ***/ Table *table; Database *database; @@ -162,7 +165,6 @@ public: SyncObject syncDIHash; SyncObject syncUnique; IndexWalker* positionIndex(IndexKey* lowKey, IndexKey* highKey, int searchFlags, Transaction* transaction); - volatile INTERLOCK_TYPE useCount; }; #endif // !defined(AFX_INDEX_H__02AD6A44_A433_11D2_AB5B_0000C01D2301__INCLUDED_) === modified file 'storage/falcon/StorageTable.cpp' --- a/storage/falcon/StorageTable.cpp 2008-08-16 18:06:36 +0000 +++ b/storage/falcon/StorageTable.cpp 2008-08-16 22:04:29 +0000 @@ -51,7 +51,7 @@ StorageTable::StorageTable(StorageConnec upperBound = lowerBound = NULL; record = NULL; recordLocked = false; - haveShareLock = false; + indexesLocked = false; } StorageTable::~StorageTable(void) @@ -100,8 +100,6 @@ int StorageTable::truncateTable(void) return ret; } - - int StorageTable::insert(void) { try @@ -188,10 +186,10 @@ void StorageTable::transactionEnded(void int StorageTable::setCurrentIndex(int indexId) { - if (!haveShareLock) + if (!indexesLocked) { - share->lock(); - haveShareLock = true; + share->lockIndexes(); + indexesLocked = true; } if (!(currentIndex = share->getIndex(indexId))) @@ -200,10 +198,12 @@ int StorageTable::setCurrentIndex(int in return StorageErrorNoIndex; } + /*** debug if (currentIndex->index) - currentIndex->index->addRef(); //cwp debug + currentIndex->index->addRef(); else currentIndex->index = NULL; + ***/ upperBound = lowerBound = NULL; searchFlags = 0; @@ -212,16 +212,18 @@ int StorageTable::setCurrentIndex(int in int StorageTable::clearCurrentIndex() { + /*** debug if (currentIndex) - if (currentIndex->index) //cwp tbd + if (currentIndex->index) currentIndex->index->release(); else - currentIndex->index = NULL; // cwp debug + currentIndex->index = NULL; + ***/ - if (haveShareLock) + if (indexesLocked) { - share->unlock(); - haveShareLock = false; + share->unlockIndexes(); + indexesLocked = false; } currentIndex = NULL; @@ -256,7 +258,6 @@ int StorageTable::indexScan(int indexOrd return 0; } - void StorageTable::clearBitmap(void) { if (bitmap) === modified file 'storage/falcon/StorageTable.h' --- a/storage/falcon/StorageTable.h 2008-08-16 18:06:36 +0000 +++ b/storage/falcon/StorageTable.h 2008-08-16 22:04:29 +0000 @@ -128,7 +128,7 @@ public: Stream insertStream; int searchFlags; bool recordLocked; - bool haveShareLock; + bool indexesLocked; }; #endif === modified file 'storage/falcon/StorageTableShare.cpp' --- a/storage/falcon/StorageTableShare.cpp 2008-08-16 18:06:36 +0000 +++ b/storage/falcon/StorageTableShare.cpp 2008-08-16 22:04:29 +0000 @@ -108,6 +108,16 @@ void StorageTableShare::unlock(void) syncIndexes->unlock(); } +void StorageTableShare::lockIndexes(bool exclusiveLock) +{ + syncIndexes->lock(NULL, (exclusiveLock) ? Exclusive : Shared); +} + +void StorageTableShare::unlockIndexes(void) +{ + syncIndexes->unlock(); +} + int StorageTableShare::open(void) { if (!table) @@ -242,11 +252,11 @@ const char* StorageTableShare::cleanupTa return buffer; } -const char* StorageTableShare::createIndexName(const char *rawName, char *indexName) +char* StorageTableShare::createIndexName(const char *rawName, char *indexName) { - char nameBuffer[256]; + char nameBuffer[indexNameSize]; cleanupFieldName(rawName, nameBuffer, sizeof(nameBuffer)); - sprintf(indexName, "%s$%s", name, nameBuffer); + sprintf(indexName, "%s$%s", name.getString(), nameBuffer); return indexName; } @@ -255,6 +265,8 @@ int StorageTableShare::createIndex(Stora if (!table) open(); + // Always get syncIndexes before syncObject + Sync syncIndex(syncIndexes, "StorageTableShare::createIndex(1)"); syncIndex.lock(Exclusive); @@ -274,6 +286,8 @@ int StorageTableShare::dropIndex(Storage if (!table) open(); + // Always get syncIndexes before syncObject + Sync syncIndex(syncIndexes, "StorageTableShare::dropIndex(1)"); syncIndex.lock(Exclusive); @@ -342,8 +356,8 @@ int StorageTableShare::setIndex(int inde indexDesc->index = table->primaryKey; else { - char indexName[256]; - sprintf(indexName, "%s$%s", name, indexDesc->name); + char indexName[indexNameSize]; + sprintf(indexName, "%s$%s", name.getString(), indexDesc->name.getString()); indexDesc->index = table->findIndex(indexName); } @@ -366,7 +380,7 @@ void StorageTableShare::clearIndex(Stora for (int n = indexDesc->id; n < numberIndexes-1; n++) { indexes.vector[n] = indexes.vector[n+1]; - indexes.vector[n]->id = n; //cwp: assume that index id will match server + indexes.vector[n]->id = n; // assume that index id will match server } indexes.zap(numberIndexes-1); @@ -456,21 +470,6 @@ int StorageTableShare::setSequenceValue( return 0; } -// Get index id using the external (server) index name - -int StorageTableShare::getIndexId(const char* indexName) -{ - Sync sync(syncObject, "StorageTableShare::getIndexId(indexName)"); - sync.lock(Shared); - - if (indexes.length > 0) - for (int n = 0; n < numberIndexes; ++n) - if (strcmp(indexes.get(n)->name, indexName) == 0) - return n; - - return -1; -} - // Get index id using the internal (Falcon) index name int StorageTableShare::getIndexId(const char* schemaName, const char* indexName) === modified file 'storage/falcon/StorageTableShare.h' --- a/storage/falcon/StorageTableShare.h 2008-08-16 18:06:36 +0000 +++ b/storage/falcon/StorageTableShare.h 2008-08-16 22:04:29 +0000 @@ -27,6 +27,7 @@ typedef __int64 INT64; static const int MaxIndexSegments = 16; +static const int indexNameSize = 257; class StorageDatabase; class StorageConnection; @@ -104,6 +105,8 @@ public: virtual void lock(bool exclusiveLock=false); virtual void unlock(void); + virtual void lockIndexes(bool exclusiveLock=false); + virtual void unlockIndexes(void); virtual int createIndex(StorageConnection *storageConnection, StorageIndexDesc *indexDesc, int indexCount, const char *sql); virtual int dropIndex(StorageConnection *storageConnection, StorageIndexDesc *indexDesc, const char *sql); virtual int renameTable(StorageConnection *storageConnection, const char* newName); @@ -122,7 +125,6 @@ public: StorageIndexDesc* getIndex(int indexId); StorageIndexDesc* getIndex(int indexId, StorageIndexDesc *indexDesc); StorageIndexDesc* getIndex(const char *name); - int getIndexId(const char* indexName); int getIndexId(const char* schemaName, const char* indexName); int create(StorageConnection *storageConnection, const char* sql, int64 autoIncrementValue); int upgrade(StorageConnection *storageConnection, const char* sql, int64 autoIncrementValue); @@ -141,7 +143,7 @@ public: static const char* getDefaultRoot(void); static const char* cleanupTableName(const char* name, char* buffer, int bufferLength, char *schema, int schemaLength); - const char* createIndexName(const char *rawName, char *indexName); + char* createIndexName(const char *rawName, char *indexName); JString name; JString schemaName; === modified file 'storage/falcon/Table.cpp' --- a/storage/falcon/Table.cpp 2008-08-16 18:06:36 +0000 +++ b/storage/falcon/Table.cpp 2008-08-16 22:04:29 +0000 @@ -226,8 +226,11 @@ void Table::renameIndexes(const char *ne { if (index->type != PrimaryKey) { + + // Assume that index name is