2898 Kevin Lewis 2008-11-02
Code cleanup
modified:
storage/falcon/MemMgr.cpp
storage/falcon/SerialLogFile.cpp
2897 Kevin Lewis 2008-11-02
Bug#40112 - DeferredIndexWalker::next() was not prepared for the first
leaf bucket to be empty. But it can become empty after several verbs
in the same transaction change the same records.
When the same record is changed more than once in the same transaction,
the older unneeded versions are deleted along with the index entries.
Even though DeferredIndex key nodes can be deleted, the buckets are not.
If the first leaf bucket is empty, DeferredIndexWalker::next() would
return NULL on the first call. In SRLUpdateIndex::append(), this would
result that nothing would be put into the Serial log at commit time for
this DeferredIndex. Then this DefferedIndex would not get put into
index pages.
The solution is to only return NULL on the first call to
DeferredIndexWalker::next() if the first leaf bucket is empty AND there
is no parent bucket. Otherwise, use the normal mechanism to advance to
the next slot.
modified:
storage/falcon/DeferredIndexWalker.cpp
storage/falcon/Transaction.cpp
=== modified file 'storage/falcon/DeferredIndexWalker.cpp'
--- a/storage/falcon/DeferredIndexWalker.cpp 2008-10-16 02:53:35 +0000
+++ b/storage/falcon/DeferredIndexWalker.cpp 2008-11-03 00:33:04 +0000
@@ -110,10 +110,16 @@ DINode* DeferredIndexWalker::next(void)
{
nodePending = false;
- return currentNode = (slot >= leaf->count) ? NULL : leaf->nodes[slot];
+ if (slot < leaf->count)
+ return (currentNode = leaf->nodes[slot]);
+
+ if (!deferredIndex->levels)
+ return NULL; // Only one bucket and it is empty
+ // else the first leaf is empty. Back up a level.
}
+ else
+ ++slot;
- ++slot;
DIBucket *bucket;
for (;;)
=== modified file 'storage/falcon/MemMgr.cpp'
--- a/storage/falcon/MemMgr.cpp 2008-10-31 15:42:42 +0000
+++ b/storage/falcon/MemMgr.cpp 2008-11-03 00:34:05 +0000
@@ -349,8 +349,7 @@ MemMgr::~MemMgr(void)
MemBlock* MemMgr::alloc(size_t s)
{
if (s > INT_MAX)
- throw SQLError (RUNTIME_ERROR, "illegal memory allocate for " I64FORMAT " bytes",
- (int64)s);
+ throw SQLError (RUNTIME_ERROR, "illegal memory allocate for " I64FORMAT " bytes", (int64)s);
int length = (int) s;
=== modified file 'storage/falcon/SerialLogFile.cpp'
--- a/storage/falcon/SerialLogFile.cpp 2008-10-31 15:42:42 +0000
+++ b/storage/falcon/SerialLogFile.cpp 2008-11-03 00:34:05 +0000
@@ -367,7 +367,7 @@ void SerialLogFile::zap()
// The error is supposedly related to the file size being less than
// page size, so initial size is made 8K just in case we'll ever run on IA64
size_t initialSize = MAX(sectorSize, 8192);
- UCHAR *junk = new UCHAR[initialSize +sectorSize];
+ UCHAR *junk = new UCHAR[initialSize + sectorSize];
UCHAR *buffer = ALIGN(junk, sectorSize);
memset(buffer, 0, initialSize);
write(0, (uint32) initialSize, (SerialLogBlock*) buffer);
=== modified file 'storage/falcon/Transaction.cpp'
--- a/storage/falcon/Transaction.cpp 2008-10-24 05:06:52 +0000
+++ b/storage/falcon/Transaction.cpp 2008-11-03 00:33:04 +0000
@@ -250,7 +250,8 @@ void Transaction::commit()
TransactionManager *transactionManager = database->transactionManager;
addRef();
- Log::log(LogXARecovery, "%d: Commit transaction %d\n", database->deltaTime, transactionId);
+ Log::log(LogXARecovery, "%d: Commit %sTransaction %d\n",
+ database->deltaTime, (systemTransaction ? "System " : ""), transactionId);
if (state == Active)
{
@@ -340,6 +341,7 @@ void Transaction::commitNoUpdates(void)
TransactionManager *transactionManager = database->transactionManager;
addRef();
ASSERT(!deferredIndexes);
+ Log::log(LogXARecovery, "%d: CommitNoUpdates transaction %d\n", database->deltaTime, transactionId);
++transactionManager->committed;
if (deferredIndexes)
@@ -384,6 +386,8 @@ void Transaction::rollback()
if (!isActive())
throw SQLEXCEPTION (RUNTIME_ERROR, "transaction is not active");
+ Log::log(LogXARecovery, "%d: Rollback transaction %d\n", database->deltaTime, transactionId);
+
if (deferredIndexes)
releaseDeferredIndexes();
@@ -951,6 +955,9 @@ void Transaction::writeComplete(void)
if (dependencies == 0)
commitRecords();
+// Log::log(LogXARecovery, "%d: WriteComplete %sTransaction %d\n",
+// database->deltaTime, (systemTransaction ? "System " : ""), transactionId);
+
writePending = false;
}
| Thread |
|---|
| • bzr push into mysql-6.0-falcon-team branch (klewis:2897 to 2898) Bug#40112 | Kevin Lewis | 3 Nov |