Bug #75667 On import tablespace, there is missing dictionary unlock call on OOM
Submitted: 28 Jan 2015 12:31 Modified: 5 Feb 2015 17:48
Reporter: Naga Satyanarayana Bodapati Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: CPU Architecture:Any

[28 Jan 2015 12:31] Naga Satyanarayana Bodapati
Description:
3571         row_mysql_lock_data_dictionary(trx);
3572 
3573         /* If the table is stored in a remote tablespace, we need to
3574         determine that filepath from the link file and system tables.
3575         Find the space ID in SYS_TABLES since this is an ALTER TABLE. */
3576         dict_get_and_save_data_dir_path(table, true);
3577 
3578         if (DICT_TF_HAS_DATA_DIR(table->flags)) {
3579                 ut_a(table->data_dir_path);
3580 
3581                 filepath = fil_make_filepath(
3582                         table->data_dir_path, table->name.m_name, IBD, true);
3583         } else {
3584                 filepath = fil_make_filepath(
3585                         NULL, table->name.m_name, IBD, false);
3586         }
3587         if (filepath == NULL) {
3588                 return(DB_OUT_OF_MEMORY);
3589         }
3590 

If filepath is NULL, there is no row_mysql_unlock_data_dictionary(trx);

How to repeat:
See code

Suggested fix:
diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc
index a142462..844551f 100644
--- a/storage/innobase/row/row0import.cc
+++ b/storage/innobase/row/row0import.cc
@@ -3584,8 +3584,15 @@ row_import_for_mysql(
 		filepath = fil_make_filepath(
 			NULL, table->name.m_name, IBD, false);
 	}
+
+	DBUG_EXECUTE_IF(
+		"ib_import_OOM_15",
+		filepath = NULL;
+	);
+
 	if (filepath == NULL) {
-		return(DB_OUT_OF_MEMORY);
+		row_mysql_unlock_data_dictionary(trx);
+		return(row_import_cleanup(prebuilt, trx, DB_OUT_OF_MEMORY));
 	}
[5 Feb 2015 17:48] Daniel Price
Posted by developer:
 
Fixed as of the upcoming 5.7.6 release, and here's the changelog entry:

On "ALTER TABLE ... IMPORT TABLESPACE", there was a missing dictionary
unlock call on Out-Of-Memory(OOM) that could result in a failure when
allocating memory for a ".ibd" file path string.