#At file:///home/hakan/work/mysql/mysql-6.0-falcon-team-bug39692/
2833 Hakan Kuecuekyilmaz 2008-09-27 [merge]
Merge.
removed:
mysql-test/suite/falcon_team/r/falcon_bug_23692.result
mysql-test/suite/falcon_team/t/falcon_bug_23692.test
added:
mysql-test/suite/falcon_team/t/test2bug.def
renamed:
mysql-test/suite/falcon_team/r/falcon_bug_30282.result =>
mysql-test/suite/falcon/r/falcon_bug_30282.result
mysql-test/suite/falcon_team/t/falcon_bug_30282.test =>
mysql-test/suite/falcon/t/falcon_bug_30282.test
modified:
mysql-test/suite/falcon/t/falcon_bug_39692.test
mysys/stacktrace.c
storage/falcon/Cache.cpp
=== renamed file 'mysql-test/suite/falcon_team/r/falcon_bug_30282.result' =>
'mysql-test/suite/falcon/r/falcon_bug_30282.result'
=== renamed file 'mysql-test/suite/falcon_team/t/falcon_bug_30282.test' =>
'mysql-test/suite/falcon/t/falcon_bug_30282.test'
=== modified file 'mysql-test/suite/falcon/t/falcon_bug_39692.test'
--- a/mysql-test/suite/falcon/t/falcon_bug_39692.test 2008-09-27 06:35:07 +0000
+++ b/mysql-test/suite/falcon/t/falcon_bug_39692.test 2008-09-27 18:04:19 +0000
@@ -1,4 +1,5 @@
--source include/have_falcon.inc
+--source include/have_debug.inc
#
# Bug #39692: Falcon allocates SectorCache even if falcon_use_sectorcache is OFF
=== removed file 'mysql-test/suite/falcon_team/r/falcon_bug_23692.result'
--- a/mysql-test/suite/falcon_team/r/falcon_bug_23692.result 2008-04-28 21:07:04 +0000
+++ b/mysql-test/suite/falcon_team/r/falcon_bug_23692.result 1970-01-01 00:00:00 +0000
@@ -1,78 +0,0 @@
-SET @@storage_engine = Falcon;
-*** Bug #23692 ***
-DROP TABLE IF EXISTS t1;
-DROP TABLE IF EXISTS t2;
-DROP TABLE IF EXISTS t3;
-DROP TABLE IF EXISTS t4;
-CREATE TABLE t1 (a char(1), key (a));
-INSERT INTO t1 VALUES (0x00);
-SELECT count(*) FROM t1 WHERE a < '';
-count(*)
-1
-SELECT count(*) FROM t1 WHERE a = '';
-count(*)
-0
-SELECT count(*) FROM t1 WHERE a > '';
-count(*)
-0
-CREATE TABLE t2 (a varbinary(5));
-CREATE INDEX i ON t2 (a);
-INSERT INTO t2 VALUES (0x02), (0x0202);
-SELECT count(*) FROM t2 WHERE a >= 0x02 OR a = 0x0202;
-count(*)
-2
-SELECT hex(a) FROM t2 WHERE a < 0x02;
-hex(a)
-SELECT hex(a) FROM t2 WHERE a = 0x02;
-hex(a)
-02
-SELECT hex(a) FROM t2 WHERE a > 0x02;
-hex(a)
-0202
-CREATE TABLE t3 (a char(5));
-CREATE INDEX i ON t3 (a);
-INSERT INTO t3 VALUES (0x4200), (0x4209), (0x42), (0x4220), (0x4242);
-SELECT hex(a) FROM t3 WHERE a < 0x42;
-hex(a)
-4200
-4209
-SELECT hex(a) FROM t3 WHERE a = 0x42;
-hex(a)
-42
-4220
-SELECT hex(a) FROM t3 WHERE a > 0x42;
-hex(a)
-4242
-SELECT hex(a) FROM t3 WHERE a LIKE 'a%';
-hex(a)
-4200
-4209
-42
-4220
-4242
-CREATE TABLE t4 (a varchar(5) character set ucs2, key(a)) engine=falcon;
-INSERT INTO t4 VALUES (0x00420000), (0x00420009), (0x0041001f), (0x0042), (0x00420020),
(0x00420042);
-SELECT hex(a) FROM t4 WHERE a < 'a';
-hex(a)
-00420000
-00420009
-0042001f
-SELECT hex(a) FROM t4 WHERE a = 'a';
-hex(a)
-0042
-00400220
-SELECT hex(a) FROM t4 WHERE a > 'a';
-hex(a)
-00420042
-SELECT hex(a) FROM t4 WHERE a LIKE 'a%';
-hex(a)
-00420000
-00420009
-0042001f
-0042
-00420020
-00420042
-DROP TABLE t1;
-DROP TABLE t2;
-DROP TABLE t3;
-DROP TABLE t4;
=== removed file 'mysql-test/suite/falcon_team/t/falcon_bug_23692.test'
--- a/mysql-test/suite/falcon_team/t/falcon_bug_23692.test 2008-04-28 21:07:04 +0000
+++ b/mysql-test/suite/falcon_team/t/falcon_bug_23692.test 1970-01-01 00:00:00 +0000
@@ -1,47 +0,0 @@
---source include/have_falcon.inc
-SET @@storage_engine = Falcon;
-#
-# Bug #23692: Falcon: searches fail if data is 0x00
-#
---echo *** Bug #23692 ***
---disable_warnings
-DROP TABLE IF EXISTS t1;
-DROP TABLE IF EXISTS t2;
-DROP TABLE IF EXISTS t3;
-DROP TABLE IF EXISTS t4;
---enable_warnings
-
-CREATE TABLE t1 (a char(1), key (a));
-INSERT INTO t1 VALUES (0x00);
-SELECT count(*) FROM t1 WHERE a < '';
-SELECT count(*) FROM t1 WHERE a = '';
-SELECT count(*) FROM t1 WHERE a > '';
-
-CREATE TABLE t2 (a varbinary(5));
-CREATE INDEX i ON t2 (a);
-INSERT INTO t2 VALUES (0x02), (0x0202);
-SELECT count(*) FROM t2 WHERE a >= 0x02 OR a = 0x0202;
-SELECT hex(a) FROM t2 WHERE a < 0x02;
-SELECT hex(a) FROM t2 WHERE a = 0x02;
-SELECT hex(a) FROM t2 WHERE a > 0x02;
-
-CREATE TABLE t3 (a char(5));
-CREATE INDEX i ON t3 (a);
-INSERT INTO t3 VALUES (0x4200), (0x4209), (0x42), (0x4220), (0x4242);
-SELECT hex(a) FROM t3 WHERE a < 0x42;
-SELECT hex(a) FROM t3 WHERE a = 0x42;
-SELECT hex(a) FROM t3 WHERE a > 0x42;
-SELECT hex(a) FROM t3 WHERE a LIKE 'a%';
-
-CREATE TABLE t4 (a varchar(5) character set ucs2, key(a)) engine=falcon;
-INSERT INTO t4 VALUES (0x00420000), (0x00420009), (0x0041001f), (0x0042), (0x00420020),
(0x00420042);
-SELECT hex(a) FROM t4 WHERE a < 'a';
-SELECT hex(a) FROM t4 WHERE a = 'a';
-SELECT hex(a) FROM t4 WHERE a > 'a';
-SELECT hex(a) FROM t4 WHERE a LIKE 'a%';
-
-# Final cleanup.
-DROP TABLE t1;
-DROP TABLE t2;
-DROP TABLE t3;
-DROP TABLE t4;
=== added file 'mysql-test/suite/falcon_team/t/test2bug.def'
--- a/mysql-test/suite/falcon_team/t/test2bug.def 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/falcon_team/t/test2bug.def 2008-09-27 07:52:18 +0000
@@ -0,0 +1,23 @@
+#
+# The falcon_team test suite is intended for unstable or otherwise
+# intermittently failing Falcon-related tests.
+# Stable Falcon tests are located in the falcon test suite.
+#
+# All tests in the falcon_team test suite should be associated with
+# a bug report describing the test failure or issue related to the test.
+#
+# Note that a separate bug report is usually needed for this, it is
+# not sufficient to list the ID of the bug whose fix this test is
+# supposed to verify.
+#
+# Format:
+# Test case: BugId - BugDescription
+#
+# Do not use TAB characters for whitespace.
+# Keep the list sorted by test name.
+#
+
+falcon_bug_23945: Bug#34892 - Transaction handling in select_create::abort let's Falcon
fail
+falcon_bug_26433: Bug#39314 - falcon_bug_26433 fails with an offset of 1 in row numbers
in expected warnings
+falcon_bug_28048: Bug#36700 - Running falcon_bug_28048 shows increasing memory usage and
run time
+falcon_bug_34892: Bug#34892 - Transaction handling in select_create::abort let's Falcon
fail
=== modified file 'mysys/stacktrace.c'
--- a/mysys/stacktrace.c 2008-09-05 00:35:12 +0000
+++ b/mysys/stacktrace.c 2008-09-26 11:24:20 +0000
@@ -314,6 +314,7 @@ void my_write_core(int sig)
#else /* __WIN__*/
#include <dbghelp.h>
+#include <tlhelp32.h>
/*
Stack tracing on Windows is implemented using Debug Helper library(dbghelp.dll)
@@ -406,6 +407,68 @@ void my_set_exception_pointers(EXCEPTION
exception_ptrs = ep;
}
+
+/*
+ Get symbol path - semicolon-separated list of directories to search for debug
+ symbols. We expect PDB in the same directory as corresponding exe or dll,
+ so the path is build from directories of the loaded modules. If environment
+ variable _NT_SYMBOL_PATH is set, it's value appended to the symbol search path
+*/
+static void get_symbol_path(char *path, size_t size)
+{
+ HANDLE hSnap;
+ char *envvar;
+
+ path[0]= '\0';
+ /*
+ Enumerate all modules, and add their directories to the path.
+ Avoid duplicate entries.
+ */
+ hSnap= CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, GetCurrentProcessId());
+ if (hSnap != INVALID_HANDLE_VALUE)
+ {
+ BOOL ret;
+ MODULEENTRY32 mod;
+ mod.dwSize= sizeof(MODULEENTRY32);
+ for (ret= Module32First(hSnap, &mod); ret; ret= Module32Next(hSnap, &mod))
+ {
+ char *module_dir= mod.szExePath;
+ char *p= strrchr(module_dir,'\\');
+ if (!p)
+ {
+ /*
+ Path separator was not found. Not known to happen, if ever happens,
+ will indicate current directory.
+ */
+ module_dir[0]= '.';
+ p= module_dir + 1;
+ }
+ *p++= ';';
+ *p= '\0';
+
+ if (!strstr(path, module_dir))
+ {
+ size_t dir_len = strlen(module_dir);
+ if (size > dir_len)
+ {
+ strncat(path, module_dir, size-1);
+ size -= dir_len;
+ }
+ }
+ }
+ CloseHandle(hSnap);
+ }
+
+ /* Add _NT_SYMBOL_PATH, if present. */
+ envvar= getenv("_NT_SYMBOL_PATH");
+ if(envvar && size)
+ {
+ strncat(path, envvar, size-1);
+ }
+}
+
+#define MAX_SYMBOL_PATH 32768
+
/* Platform SDK in VS2003 does not have definition for SYMOPT_NO_PROMPTS*/
#ifndef SYMOPT_NO_PROMPTS
#define SYMOPT_NO_PROMPTS 0
@@ -422,6 +485,7 @@ void my_print_stacktrace(uchar* unused1,
int i;
CONTEXT context;
STACKFRAME64 frame={0};
+ static char symbol_path[MAX_SYMBOL_PATH];
if(!exception_ptrs || !init_dbghelp_functions())
return;
@@ -430,7 +494,8 @@ void my_print_stacktrace(uchar* unused1,
context = *(exception_ptrs->ContextRecord);
/*Initialize symbols.*/
pSymSetOptions(SYMOPT_LOAD_LINES|SYMOPT_NO_PROMPTS|SYMOPT_DEFERRED_LOADS|SYMOPT_DEBUG);
- pSymInitialize(hProcess,NULL,TRUE);
+ get_symbol_path(symbol_path, sizeof(symbol_path));
+ pSymInitialize(hProcess, symbol_path, TRUE);
/*Prepare stackframe for the first StackWalk64 call*/
frame.AddrFrame.Mode= frame.AddrPC.Mode= frame.AddrStack.Mode= AddrModeFlat;
=== modified file 'storage/falcon/Cache.cpp'
--- a/storage/falcon/Cache.cpp 2008-09-27 06:35:07 +0000
+++ b/storage/falcon/Cache.cpp 2008-09-27 18:04:19 +0000
@@ -80,13 +80,16 @@ Cache::Cache(Database *db, int pageSz, i
// if there are more than 4096 buckets then lets round down
// else lets round up
- if (highBit >= 0x00001000) {
+ if (highBit >= 0x00001000)
+ {
// use power of two rounded down
hashSize = highBit << 1;
- } else {
+ }
+ else
+ {
// use power of two rounded up
hashSize = highBit;
- }
+ }
hashMask = hashSize - 1;
numberBuffers = numBuffers;
@@ -101,6 +104,7 @@ Cache::Cache(Database *db, int pageSz, i
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];
for (int loop = 0; loop < hashSize; loop ++)
@@ -129,7 +133,7 @@ Cache::Cache(Database *db, int pageSz, i
ioThreads = new Thread*[numberIoThreads];
memset(ioThreads, 0, numberIoThreads * sizeof(ioThreads[0]));
flushing = false;
-
+
try
{
// non-protected access to bdbs,endBdbs is OK during initialization
@@ -187,7 +191,7 @@ Cache::~Cache()
delete flushBitmap;
if (falcon_use_sectorcache)
delete sectorCache;
-
+
if (bufferHunks)
{
for (int n = 0; n < numberHunks; ++n)
@@ -201,7 +205,7 @@ Bdb* Cache::probePage(Dbb *dbb, int32 pa
{
ASSERT (pageNumber >= 0);
Bdb *bdb;
-
+
/* If we already have a buffer for this, we're done */
bdb = lockFindBdbIncrementUseCount(dbb, pageNumber);
if (bdb)
@@ -209,7 +213,7 @@ Bdb* Cache::probePage(Dbb *dbb, int32 pa
if (bdb->buffer->pageType == PAGE_free)
{
bdb->decrementUseCount(REL_HISTORY);
-
+
return NULL;
}
@@ -225,7 +229,7 @@ Bdb* Cache::probePage(Dbb *dbb, int32 pa
Bdb* Cache::findBdb(Dbb* dbb, int32 pageNumber, int slot)
{
for (Bdb *bdb = hashTable [slot]; bdb; bdb = bdb->hash)
-{
+ {
if (bdb->pageNumber == pageNumber && bdb->dbb == dbb)
{
return bdb;
@@ -274,12 +278,12 @@ Bdb* Cache::fetchPage(Dbb *dbb, int32 pa
if (panicShutdown)
{
Thread *thread = Thread::getThread("Cache::fetchPage");
-
+
if (thread->pageMarks == 0)
throw SQLError(RUNTIME_ERROR, "Emergency shut is underway");
}
-#ifdef STOP_PAGE
+#ifdef STOP_PAGE
if (pageNumber == STOP_PAGE)
Log::debug("fetching page %d/%d\n", pageNumber, dbb->tableSpaceId);
#endif
@@ -318,25 +322,27 @@ Bdb* Cache::fetchPage(Dbb *dbb, int32 pa
lockHash.unlock();
bdb = bdbAvailable;
-#ifdef STOP_PAGE
+#ifdef STOP_PAGE
if (bdb->pageNumber == STOP_PAGE)
Log::debug("reading page %d/%d\n", bdb->pageNumber, dbb->tableSpaceId);
#endif
-
+
Priority priority(database->ioScheduler);
- priority.schedule(PRIORITY_MEDIUM);
+ priority.schedule(PRIORITY_MEDIUM);
if (falcon_use_sectorcache)
sectorCache->readPage(bdb);
else
dbb->readPage(bdb);
+
priority.finished();
#ifdef HAVE_PAGE_NUMBER
ASSERT(bdb->buffer->pageNumber == pageNumber);
-#endif
+#endif
if (Exclusive != lockType)
bdb->downGrade(lockType);
+
}
- else
+ else
{
//syncObject.validateExclusive("Cache::fetchPage (retry)");
bdb->incrementUseCount(ADD_HISTORY);
@@ -353,7 +359,7 @@ Bdb* Cache::fetchPage(Dbb *dbb, int32 pa
bdbAvailable->release(REL_HISTORY);
}
}
- else
+ else
{
bdb->addRef(lockType COMMA_ADD_HISTORY);
bdb->decrementUseCount(REL_HISTORY);
@@ -361,13 +367,13 @@ Bdb* Cache::fetchPage(Dbb *dbb, int32 pa
}
Page *page = bdb->buffer;
-
+
/***
if (page->checksum != (short) pageNumber)
FATAL ("page %d wrong page number, got %d\n",
bdb->pageNumber, page->checksum);
***/
-
+
if (pageType && page->pageType != pageType)
{
/*** future code
@@ -390,7 +396,7 @@ Bdb* Cache::fakePage(Dbb *dbb, int32 pag
{
Bdb *bdb;
-#ifdef STOP_PAGE
+#ifdef STOP_PAGE
if (pageNumber == STOP_PAGE)
Log::debug("faking page %d/%d\n",pageNumber, dbb->tableSpaceId);
#endif
@@ -427,7 +433,7 @@ Bdb* Cache::fakePage(Dbb *dbb, int32 pag
bdb = bdbAvailable;
}
- else
+ else
{
//syncObject.validateExclusive("Cache::fetchPage (retry)");
bdb->incrementUseCount(ADD_HISTORY);
@@ -444,7 +450,7 @@ Bdb* Cache::fakePage(Dbb *dbb, int32 pag
bdbAvailable->release(REL_HISTORY);
}
}
- else
+ else
{
bdb->addRef(Exclusive COMMA_ADD_HISTORY);
bdb->decrementUseCount(REL_HISTORY);
@@ -453,7 +459,7 @@ Bdb* Cache::fakePage(Dbb *dbb, int32 pag
if (!dbb->isReadOnly)
bdb->mark(transId);
-
+
memset(bdb->buffer, 0, pageSize);
bdb->setPageHeader(type);
@@ -465,7 +471,7 @@ void Cache::flush(int64 arg)
Sync flushLock(&syncFlush, "Cache::flush(1)");
Sync dirtyLock(&syncDirty, "Cache::flush(2)");
flushLock.lock(Exclusive);
-
+
if (flushing)
return;
@@ -474,7 +480,7 @@ void Cache::flush(int64 arg)
flushArg = arg;
flushPages = 0;
physicalWrites = 0;
-
+
dirtyLock.lock(Shared);
for (Bdb *bdb = firstDirty; bdb; bdb = bdb->nextDirty)
{
@@ -482,6 +488,7 @@ void Cache::flush(int64 arg)
flushBitmap->set(bdb->pageNumber);
++flushPages;
}
+
dirtyLock.unlock();
analyzeFlush();
@@ -489,7 +496,7 @@ void Cache::flush(int64 arg)
flushStart = database->timestamp;
flushing = true;
flushLock.unlock();
-
+
for (int n = 0; n < numberIoThreads; ++n)
if (ioThreads[n])
ioThreads[n]->wake();
@@ -537,6 +544,7 @@ Bdb* Cache::getFreeBuffer(void)
bdb = NULL;
break;
}
+
if (bdb->useCount == 0)
{
if (!bdb->isDirty)
@@ -546,15 +554,16 @@ Bdb* Cache::getFreeBuffer(void)
break;
}
}
- else
+ else
{
- // get this one out of the way so we don't search it every time
- moveToHeadAlreadyLocked(bdb);
+ // get this one out of the way so we don't search it every time
+ moveToHeadAlreadyLocked(bdb);
#ifdef CHECK_STALLED_BDB
- bdb->stallCount++;
- if ((bdb->stallCount & 0x03) == 0x03) {
- Log::debug("Page %d is in use and aged %d times\n",
- bdb->pageNumber, bdb->stallCount);
+ bdb->stallCount++;
+ if ((bdb->stallCount & 0x03) == 0x03)
+ {
+ Log::debug("Page %d is in use and aged %d times\n",
+ bdb->pageNumber, bdb->stallCount);
}
#endif // CHECK_STALLED_BDB
}
@@ -568,13 +577,14 @@ Bdb* Cache::getFreeBuffer(void)
moveToHeadAlreadyLocked(bdb);
break;
}
+
bufferQueueLock.unlock();
if (!bdb)
throw SQLError(RUNTIME_ERROR, "buffer pool is exhausted\n");
-
+
if (bdb->pageNumber >= 0)
- {
+ {
int slotRemove = PAGENUM_2_SLOT(bdb->pageNumber);
Sync lockHashRemove (&syncHashTable[PAGENUM_2_LOCK_INDEX(bdb->pageNumber,
slotRemove)], "Cache::getFreeBuffer");
lockHashRemove.lock(Exclusive);
@@ -599,7 +609,8 @@ Bdb* Cache::getFreeBuffer(void)
}
else
ASSERT (*ptr);
- }
+
+ }
break;
}
@@ -654,9 +665,9 @@ void Cache::markClean(Bdb *bdb)
if (bdb->flushIt)
Log::debug(" Cleaning page %d in %s marked for flush\n", bdb->pageNumber, (const
char*) bdb->dbb->fileName);
***/
-
+
bdb->flushIt = false;
-
+
if (bdb == lastDirty)
lastDirty = bdb->priorDirty;
@@ -698,6 +709,7 @@ void Cache::writePage(Bdb *bdb, int type
{
if (falcon_use_sectorcache)
sectorCache->writePage(bdb);
+
dbb->writePage(bdb, type);
}
catch (SQLException& exception)
@@ -750,7 +762,7 @@ void Cache::writePage(Bdb *bdb, int type
#endif
bdb->isDirty = false;
-
+
if (pageWriter && bdb->isRegistered)
{
bdb->isRegistered = false;
@@ -780,10 +792,10 @@ void Cache::analyze(Stream *stream)
for (bdb = bdbs; bdb < endBdbs; ++bdb)
{
++total;
-
+
if (bdb->isDirty)
++dirty;
-
+
if (bdb->useCount)
++inUse;
}
@@ -791,6 +803,7 @@ void Cache::analyze(Stream *stream)
dirtyLock.lock (Shared);
for (bdb = firstDirty; bdb; bdb = bdb->nextDirty)
++dirtyList;
+
dirtyLock.unlock();
stream->format ("Cache: %d pages, %d in use, %d dirty, %d in dirty chain\n",
@@ -821,7 +834,7 @@ void Cache::freePage(Dbb *dbb, int32 pag
{
markClean (bdb);
}
-
+
bdb->isDirty = false;
break;
}
@@ -874,7 +887,7 @@ Bdb* Cache::trialFetch(Dbb* dbb, int32 p
if (panicShutdown)
{
Thread *thread = Thread::getThread("Cache::trialFetch");
-
+
if (thread->pageMarks == 0)
throw SQLError(RUNTIME_ERROR, "Emergency shut is underway");
}
@@ -889,7 +902,7 @@ Bdb* Cache::trialFetch(Dbb* dbb, int32 p
bdb->addRef(lockType COMMA_ADD_HISTORY);
bdb->decrementUseCount(REL_HISTORY);
moveToHead(bdb);
- }
+ }
return bdb;
}
@@ -900,13 +913,14 @@ void Cache::syncFile(Dbb *dbb, const cha
int writes = dbb->writesSinceSync;
time_t start = database->timestamp;
dbb->sync();
-
+
if (Log::isActive(LogInfo))
{
time_t delta = database->timestamp - start;
-
+
if (delta > 1)
- Log::log(LogInfo, "%d: %s %s sync: %d pages in %d seconds\n", database->deltaTime,
fileName, text, writes, delta);
+ Log::log(LogInfo, "%d: %s %s sync: %d pages in %d seconds\n",
+ database->deltaTime, fileName, text, writes, delta);
}
}
@@ -926,14 +940,14 @@ void Cache::ioThread(void)
UCHAR *buffer = (UCHAR*) (((UIPTR) rawBuffer + pageSize - 1) / pageSize * pageSize);
UCHAR *end = (UCHAR*) ((UIPTR) (rawBuffer + ASYNC_BUFFER_SIZE) / pageSize * pageSize);
flushLock.lock(Exclusive);
-
+
// This is the main loop. Write blocks until there's nothing to do, then sleep
-
+
for (;;)
{
int32 pageNumber = flushBitmap->nextSet(0);
int count;
-
+
if (pageNumber >= 0)
{
Bdb *bdb;
@@ -942,7 +956,7 @@ void Cache::ioThread(void)
bool hit = false;
Bdb *bdbList = NULL;
UCHAR *p = buffer;
-
+
// Look for the page to flush.
bdb = lockFindBdbIncrementUseCount(pageNumber, slot);
if (bdb && bdb->flushIt && bdb->isDirty)
@@ -950,19 +964,19 @@ void Cache::ioThread(void)
hit = true;
count = 0;
dbb = bdb->dbb;
-
+
flushBitmap->clear(pageNumber);
-
+
// get all his friends
while (p < end)
{
++count;
bdb->addRef(Shared COMMA_ADD_HISTORY);
-
+
bdb->syncWrite.lock(NULL, Exclusive);
bdb->ioThreadNext = bdbList;
bdbList = bdb;
-
+
//ASSERT(!(bdb->flags & BDB_write_pending));
//bdb->flags |= BDB_write_pending;
memcpy(p, bdb->buffer, pageSize);
@@ -971,23 +985,23 @@ void Cache::ioThread(void)
markClean(bdb);
bdb->isDirty = false;
bdb->release(REL_HISTORY);
-
+
bdb = lockFindBdbIncrementUseCount(dbb, bdb->pageNumber + 1);
if (!bdb)
break;
-
+
if (!bdb->isDirty && !continueWrite(bdb))
{
bdb->decrementUseCount(REL_HISTORY);
break;
}
}
-
+
flushLock.unlock();
//Log::debug(" %d Writing %s %d pages: %d - %d\n", thread->threadId, (const char*)
dbb->fileName, count, pageNumber, pageNumber + count - 1);
int length = p - buffer;
priority.schedule(PRIORITY_LOW);
-
+
try
{
priority.schedule(PRIORITY_LOW);
@@ -996,12 +1010,12 @@ void Cache::ioThread(void)
catch (SQLException& exception)
{
priority.finished();
-
+
if (exception.getSqlcode() != DEVICE_FULL)
throw;
-
+
database->setIOError(&exception);
-
+
for (bool error = true; error;)
{
if (thread->shutdownInProgress)
@@ -1015,12 +1029,12 @@ void Cache::ioThread(void)
bdb->syncWrite.unlock();
bdb->decrementUseCount(REL_HISTORY);
}
-
+
return;
}
-
+
thread->sleep(1000);
-
+
try
{
priority.schedule(PRIORITY_LOW);
@@ -1031,7 +1045,7 @@ void Cache::ioThread(void)
catch (SQLException& exception2)
{
priority.finished();
-
+
if (exception2.getSqlcode() != DEVICE_FULL)
throw;
}
@@ -1049,23 +1063,23 @@ void Cache::ioThread(void)
bdb->syncWrite.unlock();
bdb->decrementUseCount(REL_HISTORY);
}
-
+
flushLock.lock(Exclusive);
++physicalWrites;
-
+
}
else
{
- if (bdb)
- bdb->decrementUseCount(REL_HISTORY);
+ if (bdb)
+ bdb->decrementUseCount(REL_HISTORY);
}
-
- if (!hit)
+
+ if (!hit)
{
flushBitmap->clear(pageNumber);
}
}
- else
+ else
{
if (flushing)
{
@@ -1077,26 +1091,26 @@ void Cache::ioThread(void)
flushArg = 0;
flushLock.unlock();
syncWait.unlock();
-
+
if (writes > 0 && Log::isActive(LogInfo))
Log::log(LogInfo, "%d: Cache flush: %d pages, %d writes in %d seconds (%d pps)\n",
- database->deltaTime, pages, writes, delta, pages / MAX(delta, 1));
+ database->deltaTime, pages, writes, delta, pages / MAX(delta, 1));
if (callbackArg != 0)
database->pageCacheFlushed(callbackArg);
}
else
flushLock.unlock();
-
+
if (thread->shutdownInProgress)
break;
thread->sleep();
flushLock.lock(Exclusive);
- }
+ }
} // for ever
-
- delete [] rawBuffer;
+
+ delete [] rawBuffer;
}
bool Cache::continueWrite(Bdb* startingBdb)
@@ -1104,25 +1118,26 @@ bool Cache::continueWrite(Bdb* startingB
Dbb *dbb = startingBdb->dbb;
int clean = 1;
int dirty = 0;
-
+
for (int32 pageNumber = startingBdb->pageNumber + 1, end = pageNumber+ 5; pageNumber
< end; ++pageNumber)
{
Bdb *bdb;
-
+
if (dirty > clean)
return true;
bdb = lockFindBdbIncrementUseCount(dbb, pageNumber);
if (!bdb)
return dirty >= clean;
-
+
if (bdb->isDirty)
++dirty;
else
++clean;
+
bdb->decrementUseCount(REL_HISTORY);
}
-
+
return (dirty >= clean);
}
@@ -1149,7 +1164,7 @@ void Cache::shutdownThreads(void)
ioThreads[n]->shutdown();
ioThreads[n] = 0;
}
-
+
Sync lockThreads(&syncThreads, "Cache::shutdownThreads");
lockThreads.lock(Exclusive);
}
@@ -1160,20 +1175,20 @@ void Cache::analyzeFlush(void)
Dbb *dbb = NULL;
Bdb *bdb;
Sync dirtyLock (&syncDirty, "Cache::hasDirtyPages");
-
+
dirtyLock.lock (Shared);
for (bdb = firstDirty; bdb; bdb = bdb->nextDirty)
if (bdb->dbb->tableSpaceId == 1)
{
dbb = bdb->dbb;
-
+
break;
}
dirtyLock.unlock();
-
+
if (!dbb)
return;
-
+
fprintf(traceFile, "-------- time %d -------\n", database->deltaTime);
for (int pageNumber = 0; (pageNumber = flushBitmap->nextSet(pageNumber)) >= 0;)
@@ -1182,33 +1197,33 @@ void Cache::analyzeFlush(void)
{
int start = pageNumber;
int type = bdb->buffer->pageType;
-
+
// non-protected access to hash table via findBdb()!
for (; (bdb = findBdb(dbb, ++pageNumber)) && bdb->flushIt;)
;
-
+
fprintf(traceFile, " %d flushed: %d to %d, first type %d\n", pageNumber - start,
start, pageNumber - 1, type);
-
+
// non-protected access to hash table via findBdb()!
for (int max = pageNumber + 5; pageNumber < max && (bdb = findBdb(dbb,
pageNumber)) && !bdb->flushIt; ++pageNumber)
{
if (bdb->isDirty)
fprintf(traceFile, " %d dirty not flushed, type %d \n", pageNumber,
bdb->buffer->pageType);
else
- fprintf(traceFile," %d not dirty, type %d\n", pageNumber,
bdb->buffer->pageType);
+ fprintf(traceFile, " %d not dirty, type %d\n", pageNumber,
bdb->buffer->pageType);
}
}
else
++pageNumber;
-
- fflush(traceFile);
+
+ fflush(traceFile);
}
void Cache::openTraceFile(void)
{
if (traceFile)
closeTraceFile();
-
+
traceFile = fopen(TRACE_FILE, "a+");
fprintf(traceFile, "Starting\n");
//KEL
@@ -1228,9 +1243,11 @@ void Cache::closeTraceFile(void)
void Cache::analyzeFlush(void)
{
}
+
void Cache::openTraceFile(void)
{
}
+
void Cache::closeTraceFile(void)
{
}
@@ -1241,4 +1258,3 @@ void Cache::flushWait(void)
Sync waitLock(&syncWait, "Cache::flushWait");
waitLock.lock(Exclusive);
}
-
| Thread |
|---|
| • bzr commit into mysql-6.0-falcon-team branch (hky:2833) | Hakan Kuecuekyilmaz | 27 Sep |