#At file:///home/olav/mysql/develop/falcon-elog/ based on revid:john.embretsen@stripped
2748 Olav.Sandstaa@stripped 2009-06-26
Bug#43490 Falcon internal thread terminate after throwing an instance of 'SQLError'
The thrown exception contains the error string "can't continue after
fatal error ". This exception is only thrown by the Falcon IO
system. It is thrown after a fatal IO error has
occurred. Unfortunately it gives very little information about what
the actual error was.
This patch improves the logging of "fatal" IO errors by writing to the
error log file information about the error when it occurs. With this
patch a message similar to this example will be written when
IO::declareFatalError() is called:
Falcon: Fatal IO error occurred in "IO::writePages": file
"/home/olav/mysql/develop/falcon-elog/mysql-test/var/mysqld.1/data/falcon_user.fts", page 21: No space left on device (28)
Note that this patch does not fix the problem but only improves the logging
when the actually error occurs, hopefully making it easier to find the
real error.
modified:
storage/falcon/IO.cpp
storage/falcon/IOx.h
=== modified file 'storage/falcon/IO.cpp'
--- a/storage/falcon/IO.cpp 2009-04-07 20:16:05 +0000
+++ b/storage/falcon/IO.cpp 2009-06-26 11:13:44 +0000
@@ -109,6 +109,8 @@ static const int TRACE_SYNC_END = -2;
static const uint16 NON_ZERO_CHECKSUM_MAGIC = 0xAFFE;
+static const int NO_VALID_PAGE_NUMBER = -2;
+
#ifdef SIMULATE_DISK_FULL
static int simulateDiskFull = SIMULATE_DISK_FULL;
#endif
@@ -289,7 +291,7 @@ void IO::readPage(Bdb * bdb)
if (length != pageSize)
{
- declareFatalError();
+ declareFatalError("IO::readPage", bdb->pageNumber, errno);
if (length == -1)
{
throw SQLError(IO_ERROR, "read error on page %d of \"%s\": %s (%d)",
@@ -390,7 +392,7 @@ void IO::writePages(int32 pageNumber, in
if (errno == ENOSPC)
throw SQLError(DEVICE_FULL, "device full error on %s, page %d\n", (const char*) fileName, pageNumber);
- declareFatalError();
+ declareFatalError("IO::writePages", pageNumber, errno);
throw SQLError(IO_ERROR, "write error on page %d (%d/%d/%d) of \"%s\": %s (%d)",
pageNumber, length, pageSize, fileId,
@@ -452,9 +454,27 @@ void IO::longSeek(int64 offset)
Error::error ("long seek failed on \"%s\"", (const char*) fileName);
}
-void IO::declareFatalError()
+void IO::declareFatalError(const char *methodName, int pageNumber, int errorNumber)
{
+ // Update status about that a fatal IO error has occured
+
fatalError = true;
+
+ // Convert the page number to a string. Note that we use
+ // NO_VALID_PAGE_NUMBER to indicate that this error is not related
+ // to a specific page.
+
+ char pageNumberStr[40];
+ pageNumberStr[0] = 0;
+
+ if (pageNumber != NO_VALID_PAGE_NUMBER)
+ {
+ sprintf(pageNumberStr, ", page %d", pageNumber);
+ }
+
+ Log::fatal("Falcon: Fatal IO error occurred in \"%s\": file \"%s\"%s: %s (%d)\n",
+ methodName, (const char*) fileName, pageNumberStr,
+ strerror(errorNumber), errorNumber);
}
@@ -705,7 +725,7 @@ void IO::sync(void)
#ifdef _WIN32
if (_commit(fileId))
{
- declareFatalError();
+ declareFatalError("IO::sync", NO_VALID_PAGE_NUMBER, errno);
throw SQLError(IO_ERROR, "_commit failed on \"%s\": %s (%d)",
(const char*) fileName, strerror (errno), errno);
}
=== modified file 'storage/falcon/IOx.h'
--- a/storage/falcon/IOx.h 2008-09-11 10:56:00 +0000
+++ b/storage/falcon/IOx.h 2009-06-26 11:13:44 +0000
@@ -56,7 +56,6 @@ public:
void write(uint32 length, const UCHAR *data);
static bool doesFileExist(const char *fileName);
static int fileStat(const char *fileName, struct stat *stats = NULL, int *errnum = NULL);
- void declareFatalError();
void seek (int pageNumber);
void closeFile();
void readHeader (Hdr *header);
@@ -88,6 +87,10 @@ public:
static void deleteFile(const char* fileName);
static int getWriteMode(int attempt);
+private:
+ void declareFatalError(const char *methodName, int PageNumber, int errorNumber);
+
+public:
JString fileName;
SyncObject syncObject;
int fileId;
Attachment: [text/bzr-bundle] bzr/olav.sandstaa@sun.com-20090626111344-vh7ue5autyugf0h8.bundle