Vlad, Looks good, OK to push. Great job!
Vladislav Vaintroub wrote:
> #At file:///G:/bzr/bug35255/
>
> 2970 Vladislav Vaintroub 2009-01-15
> 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 calledon 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 2008-12-19 18:45:32 +0000
> +++ b/storage/falcon/Dbb.cpp 2009-01-15 09:23:38 +0000
> @@ -374,6 +374,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;
> @@ -625,7 +627,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 2008-12-19 18:45:32 +0000
> +++ b/storage/falcon/Dbb.h 2009-01-15 09:23:38 +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)
>
> @@ -200,6 +201,7 @@ public:
> bool utf8;
> bool noLog;
> Section **sections;
> + Mutex sectionsMutex;
> int debug;
> int sequence;
> int odsVersion;
>
>