From: Date: November 5 2008 5:31pm Subject: bzr commit into mysql-6.0-falcon-team branch (vvaintroub:2899) Bug#40302 List-Archive: http://lists.mysql.com/commits/57916 X-Bug: 40302 Message-Id: <0K9V00FRWCKMTNC0@fe-emea-10.sun.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7BIT #At file:///G:/bzr/mysql-6.0-falcon-team/ 2899 Vladislav Vaintroub 2008-11-05 Bug #40302 error on tablespace creation is not handled cleanly Problem: If tablespace.create() fails, system transaction that updates tablespace info is not rolled back. It can be possibly commited with the next system transaction, that will add a tablespace to system tables even if datafile does not exist. Additionally, createTableSpace log record (indicating creation of datafile) that logically belongs to the same transaction as system tables and has the same transaction id was wrongly written after "commit". With this patch, - there is a rollback in case of error and appropriate cleanup in the filesystem - createTableSpace now belongs to the same transaction that changes system tables. modified: storage/falcon/TableSpaceManager.cpp === modified file 'storage/falcon/TableSpaceManager.cpp' --- a/storage/falcon/TableSpaceManager.cpp 2008-10-31 00:29:13 +0000 +++ b/storage/falcon/TableSpaceManager.cpp 2008-11-05 16:30:52 +0000 @@ -168,26 +168,27 @@ TableSpace* TableSpaceManager::createTab throw SQLError(TABLESPACE_DATAFILE_EXIST_ERROR, "table space file name \"%s\" already exists\n", fileName); } + bool createdFile = false; try { tableSpace->save(); if (!repository) tableSpace->create(); - + createdFile = true; syncDDL.unlock(); - database->commitSystemTransaction(); add(tableSpace); + database->serialLog->logControl->createTableSpace.append(tableSpace); } catch (...) { + if (createdFile) + IO::deleteFile(fileName); + database->rollbackSystemTransaction(); delete tableSpace; - throw; } - - database->serialLog->logControl->createTableSpace.append(tableSpace); - + database->commitSystemTransaction(); return tableSpace; } @@ -248,7 +249,7 @@ TableSpace* TableSpaceManager::getTableS TableSpace *tableSpace = findTableSpace(id); if (!tableSpace) - throw SQLError(COMPILE_ERROR, "can't find table space %d", id); + throw SQLError(TABLESPACE_NOT_EXIST_ERROR, "can't find table space %d", id); if (!tableSpace->active) //throw SQLError(RUNTIME_ERROR, "table space \"%s\" is not active", (const char*) tableSpace->name);