2904 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
2903 Hakan Kuecuekyilmaz 2008-11-05 [merge]
Merged:
mysql-6.0 --> mysql-6.0-falcon --> mysql-6.0-falcon-team.
removed:
mysql-test/suite/falcon/r/falcon_bug_28095_II.result
mysql-test/suite/falcon/t/falcon_bug_28095_II-master.opt
mysql-test/suite/falcon/t/falcon_bug_28095_II.test
added:
mysql-test/include/restart_mysqld.inc
mysql-test/include/wait_until_disconnected.inc
renamed:
mysql-test/suite/falcon/r/falcon_bug_28095_I.result =>
mysql-test/suite/falcon/r/falcon_bug_28095.result
mysql-test/suite/falcon/t/falcon_bug_28095_I.test =>
mysql-test/suite/falcon/t/falcon_bug_28095.test
modified:
.bzrignore
BUILD/compile-dist
client/mysqltest.c
configure.in
mysql-test/include/wait_until_connected_again.inc
mysql-test/r/group_by.result
mysql-test/r/innodb_mrr.result
mysql-test/r/myisam_mrr.result
mysql-test/r/ps_ddl.result
mysql-test/r/subselect3.result
mysql-test/r/sum_distinct.result
mysql-test/suite/falcon/t/disabled.def
mysql-test/t/group_by.test
mysql-test/t/innodb_mrr.test
mysql-test/t/myisam_mrr.test
mysql-test/t/ps_ddl.test
mysql-test/t/subselect3.test
mysql-test/t/sum_distinct.test
sql/hostname.cc
sql/item_sum.cc
sql/item_sum.h
sql/mysql_priv.h
sql/mysqld.cc
sql/net_serv.cc
sql/sql_select.cc
sql/sql_select.h
storage/falcon/StorageVersion.h
storage/myisam/ha_myisam.cc
zlib/gzio.c
mysql-test/suite/falcon/r/falcon_bug_28095.result
mysql-test/suite/falcon/t/falcon_bug_28095.test
=== 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 17:58:43 +0000
@@ -155,7 +155,7 @@ TableSpace* TableSpaceManager::getTableS
TableSpace* TableSpaceManager::createTableSpace(const char *name, const char *fileName,
bool repository, TableSpaceInit *tsInit)
{
Sync syncDDL(&database->syncSysDDL, "TableSpaceManager::createTableSpace");
- syncDDL.lock(Shared);
+ syncDDL.lock(Exclusive);
Sequence *sequence =
database->sequenceManager->getSequence(database->getSymbol("SYSTEM"),
database->getSymbol("TABLESPACE_IDS"));
int type = (repository) ? TABLESPACE_TYPE_REPOSITORY : TABLESPACE_TYPE_TABLESPACE;
int id = (int) sequence->update(1, database->getSystemTransaction());
@@ -168,26 +168,26 @@ 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();
-
- syncDDL.unlock();
- database->commitSystemTransaction();
+ createdFile = true;
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;
}
| Thread |
|---|
| • bzr push into mysql-6.0-falcon-team branch (vvaintroub:2903 to 2904)Bug#40302 | Vladislav Vaintroub | 5 Nov |