#At file:///G:/bzr/mysql-6.0-falcon-team/ based on revid:vvaintroub@stripped
3016 Vladislav Vaintroub 2009-02-13
Bug#35255 : test falcon_bug_22165 fails sporadically.
Problem : Crashes happen in a concurrent workload with inserts/create table/drop
table, or insert/alter table. The reason for assertions is a race condition in Dbb::findSection() function, that is called on the first insert() after table is created ot altered. When 2 threads are looking for the same section in Dbb::sections hashtable at the very same time and do not find it , they will insert 2 equal entries into the table. One entry will be deleted, when table is dropped. Another entry will stay and will with high probability become invalid when section for this table is reused (invalid means root page does not match sectionId). In this case, next access to section will fail with an assert.
The fix is to synchronize access to the Dbb::section hashtable with a mutex .There are very few calls to Dbb::findSection in normal case, so synchronization will not introduce performance losses.
modified:
storage/falcon/Dbb.cpp
storage/falcon/Dbb.h
=== modified file 'storage/falcon/Dbb.cpp'
--- a/storage/falcon/Dbb.cpp 2009-02-10 22:50:04 +0000
+++ b/storage/falcon/Dbb.cpp 2009-02-13 15:53:28 +0000
@@ -372,6 +372,8 @@ Section* Dbb::findSection(int32 sectionI
int slot = sectionId % SECTION_HASH_SIZE;
Section *section;
+ Sync sync (§ionsMutex, "Dbb::findSection");
+ sync.lock(Exclusive);
for (section = sections [slot]; section; section = section->hash)
if (section->sectionId == sectionId)
return section;
@@ -619,7 +621,10 @@ void Dbb::deleteSection(int32 sectionId,
Section::deleteSection (this, sectionId, transId);
Section *section;
-
+
+ Sync sync(§ionsMutex, "Dbb::deleteSection");
+ sync.lock(Exclusive);
+
for (Section **ptr = sections + slot; (section = *ptr); ptr = §ion->hash)
if (section->sectionId == sectionId)
{
=== modified file 'storage/falcon/Dbb.h'
--- a/storage/falcon/Dbb.h 2009-02-02 13:00:38 +0000
+++ b/storage/falcon/Dbb.h 2009-02-13 15:53:28 +0000
@@ -29,6 +29,7 @@
#include "PageType.h"
#include "SyncObject.h"
#include "SparseArray.h"
+#include "Mutex.h"
#define TRANSACTION_ID(transaction) ((transaction) ? transaction->transactionId : 0)
@@ -203,6 +204,7 @@ public:
bool utf8;
bool noLog;
Section *sections[SECTION_HASH_SIZE];
+ Mutex sectionsMutex;
int debug;
int sequence;
int odsVersion;
| Thread |
|---|
| • bzr commit into mysql-6.0-falcon-team branch (vvaintroub:3016)Bug#35255 | Vladislav Vaintroub | 13 Feb |