summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2021-12-15 14:17:55 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2021-12-15 14:17:55 +0200
commitef9517eb81cf6c278e88622b3fa4a668a8bcb13f (patch)
tree2ba85fd2a39dda8b8fe773c6faffbeac773f5b89
parent8bb55633699612279744c055e22eeca8d4058273 (diff)
downloadmariadb-git-ef9517eb81cf6c278e88622b3fa4a668a8bcb13f.tar.gz
MDEV-27268 Failed InnoDB initialization leaves garbage files behind
create_log_files(): Check log_set_capacity() before modifying or creating any log files. innobase_start_or_create_for_mysql(): If create_log_files() fails and we were initializing a new database, delete the system tablespace files before exiting.
-rw-r--r--mysql-test/suite/innodb/r/log_file.result1
-rw-r--r--mysql-test/suite/innodb/t/log_file.test3
-rw-r--r--storage/innobase/srv/srv0start.cc15
3 files changed, 11 insertions, 8 deletions
diff --git a/mysql-test/suite/innodb/r/log_file.result b/mysql-test/suite/innodb/r/log_file.result
index b93bfc0d02b..952b9f3a3af 100644
--- a/mysql-test/suite/innodb/r/log_file.result
+++ b/mysql-test/suite/innodb/r/log_file.result
@@ -14,7 +14,6 @@ WHERE engine = 'innodb'
AND support IN ('YES', 'DEFAULT', 'ENABLED');
ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS
FOUND 1 /File .path.to.non-existent.*ib_logfile101: 'create' returned OS error \d+/ in mysqld.1.err
-# Remove ibdata1 & ibdata2
# Successfully let InnoDB create tablespaces
SELECT COUNT(*) `1` FROM INFORMATION_SCHEMA.ENGINES
WHERE engine='innodb'
diff --git a/mysql-test/suite/innodb/t/log_file.test b/mysql-test/suite/innodb/t/log_file.test
index 8a82ab7f29f..7aca2336de6 100644
--- a/mysql-test/suite/innodb/t/log_file.test
+++ b/mysql-test/suite/innodb/t/log_file.test
@@ -67,9 +67,6 @@ eval $check_no_innodb;
let SEARCH_PATTERN=File .path.to.non-existent.*ib_logfile101: 'create' returned OS error \d+;
--source include/search_pattern_in_file.inc
---echo # Remove ibdata1 & ibdata2
---remove_file $bugdir/ibdata1
---remove_file $bugdir/ibdata2
--list_files $bugdir
--echo # Successfully let InnoDB create tablespaces
diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc
index 9548730b359..9fc18272a2a 100644
--- a/storage/innobase/srv/srv0start.cc
+++ b/storage/innobase/srv/srv0start.cc
@@ -3,7 +3,7 @@
Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2008, Google Inc.
Copyright (c) 2009, Percona Inc.
-Copyright (c) 2013, 2020, MariaDB Corporation.
+Copyright (c) 2013, 2021, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -426,6 +426,10 @@ create_log_files(
return(DB_READ_ONLY);
}
+ if (!log_set_capacity(srv_log_file_size_requested)) {
+ return(DB_ERROR);
+ }
+
/* Crashing after deleting the first file should be
recoverable. The buffer pool was clean, and we can simply
create all log files from the scratch. */
@@ -482,9 +486,6 @@ create_log_files(
}
log_init(srv_n_log_files);
- if (!log_set_capacity(srv_log_file_size_requested)) {
- return(DB_ERROR);
- }
fil_open_log_and_system_tablespace_files();
@@ -1936,6 +1937,12 @@ innobase_start_or_create_for_mysql()
logfilename, dirnamelen, flushed_lsn, logfile0);
if (err != DB_SUCCESS) {
+ for (Tablespace::const_iterator
+ i = srv_sys_space.begin();
+ i != srv_sys_space.end(); i++) {
+ os_file_delete(innodb_data_file_key,
+ i->filepath());
+ }
return(srv_init_abort(err));
}
} else {