From d8ce8d084500d5b1790bf4026934d9190920592c Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 9 Oct 2012 16:02:58 +0300 Subject: [PATCH 1/3] Fix Bug#14708715 CREATE TABLE MEMORY LEAK ON DB_OUT_OF_FILE_SPACE The problem is in the error handling in row_create_table_for_mysql(). In the 'disk full' case we may forget to call dict_mem_table_free() on the table object. Approved by: Marko (rb:1377 and rb:1386) --- storage/innodb_plugin/os/os0file.c | 16 ++++++++++++++++ storage/innodb_plugin/row/row0mysql.c | 5 ++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/storage/innodb_plugin/os/os0file.c b/storage/innodb_plugin/os/os0file.c index ff80f7ed1b4..7f8c7c637a1 100644 --- a/storage/innodb_plugin/os/os0file.c +++ b/storage/innodb_plugin/os/os0file.c @@ -1249,6 +1249,22 @@ os_file_create( ulint type, /*!< in: OS_DATA_FILE or OS_LOG_FILE */ ibool* success)/*!< out: TRUE if succeed, FALSE if error */ { +#ifdef __WIN__ + DBUG_EXECUTE_IF( + "ib_create_table_fail_disk_full", + *success = FALSE; + SetLastError(ERROR_DISK_FULL); + return((os_file_t) -1); + ); +#else /* __WIN__ */ + DBUG_EXECUTE_IF( + "ib_create_table_fail_disk_full", + *success = FALSE; + errno = ENOSPC; + return((os_file_t) -1); + ); +#endif /* __WIN__ */ + #ifdef __WIN__ os_file_t file; DWORD share_mode = FILE_SHARE_READ; diff --git a/storage/innodb_plugin/row/row0mysql.c b/storage/innodb_plugin/row/row0mysql.c index 974d67893a3..137a164c4cd 100644 --- a/storage/innodb_plugin/row/row0mysql.c +++ b/storage/innodb_plugin/row/row0mysql.c @@ -1768,7 +1768,8 @@ Creates a table for MySQL. If the name of the table ends in one of "innodb_monitor", "innodb_lock_monitor", "innodb_tablespace_monitor", "innodb_table_monitor", then this will also start the printing of monitor output by the master thread. If the table name ends in "innodb_mem_validate", -InnoDB will try to invoke mem_validate(). +InnoDB will try to invoke mem_validate(). On failure the transaction will +be rolled back and the 'table' object will be freed. @return error code or DB_SUCCESS */ UNIV_INTERN int @@ -1907,6 +1908,8 @@ err_exit: row_drop_table_for_mysql(table->name, trx, FALSE); trx_commit_for_mysql(trx); + } else { + dict_mem_table_free(table); } break; From d38df265ea719c8a4f5f8a3f39cbd0f97d952e97 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 9 Oct 2012 16:08:06 +0300 Subject: [PATCH 2/3] Update the ChangeLog with the fix of Bug#14708715 --- storage/innodb_plugin/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/storage/innodb_plugin/ChangeLog b/storage/innodb_plugin/ChangeLog index 1e5b388643d..cc4962bd125 100644 --- a/storage/innodb_plugin/ChangeLog +++ b/storage/innodb_plugin/ChangeLog @@ -1,3 +1,8 @@ +2012-10-09 The InnoDB Team + + * row/row0mysql.c: + Fix Bug#14708715 CREATE TABLE MEMORY LEAK ON DB_OUT_OF_FILE_SPACE + 2012-09-28 The InnoDB Team * include/row0undo.h, row/row0umod.c, row/row0undo.c: From f4c0571679215e3687ab97f9192e944659b251b3 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 9 Oct 2012 16:29:00 +0300 Subject: [PATCH 3/3] Port the test for Bug#14708715 from 5.1/innodb_plugin into 5.1/innodb although the bug does not exist in 5.1/innodb. --- storage/innobase/os/os0file.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/storage/innobase/os/os0file.c b/storage/innobase/os/os0file.c index 566c50381e7..9f68f93fd99 100644 --- a/storage/innobase/os/os0file.c +++ b/storage/innobase/os/os0file.c @@ -1209,6 +1209,22 @@ os_file_create( ulint type, /* in: OS_DATA_FILE or OS_LOG_FILE */ ibool* success)/* out: TRUE if succeed, FALSE if error */ { +#ifdef __WIN__ + DBUG_EXECUTE_IF( + "ib_create_table_fail_disk_full", + *success = FALSE; + SetLastError(ERROR_DISK_FULL); + return((os_file_t) -1); + ); +#else /* __WIN__ */ + DBUG_EXECUTE_IF( + "ib_create_table_fail_disk_full", + *success = FALSE; + errno = ENOSPC; + return((os_file_t) -1); + ); +#endif /* __WIN__ */ + #ifdef __WIN__ os_file_t file; DWORD share_mode = FILE_SHARE_READ;