mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 23:52:03 +00:00
Merge pull request #10442 from zhang2014/fix/create_database_failure
Not remove metadata directory when attach database fails
This commit is contained in:
commit
77969d11a5
@ -36,16 +36,18 @@ namespace ErrorCodes
|
|||||||
DatabasePtr DatabaseFactory::get(
|
DatabasePtr DatabaseFactory::get(
|
||||||
const String & database_name, const String & metadata_path, const ASTStorage * engine_define, Context & context)
|
const String & database_name, const String & metadata_path, const ASTStorage * engine_define, Context & context)
|
||||||
{
|
{
|
||||||
|
bool created = false;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Poco::File(metadata_path).createDirectory();
|
created = Poco::File(metadata_path).createDirectory();
|
||||||
return getImpl(database_name, metadata_path, engine_define, context);
|
return getImpl(database_name, metadata_path, engine_define, context);
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
Poco::File metadata_dir(metadata_path);
|
Poco::File metadata_dir(metadata_path);
|
||||||
|
|
||||||
if (metadata_dir.exists())
|
if (created && metadata_dir.exists())
|
||||||
metadata_dir.remove(true);
|
metadata_dir.remove(true);
|
||||||
|
|
||||||
throw;
|
throw;
|
||||||
|
Loading…
Reference in New Issue
Block a user