[MDEV-25743] Unnecessary copying of table names in InnoDB dictionary operations Created: 2021-05-20  Updated: 2022-04-08  Resolved: 2021-05-21

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 5.5, 10.0, 10.1, 10.2, 10.3, 10.4, 10.5, 10.6
Fix Version/s: 10.6.2

Type: Bug Priority: Major
Reporter: Marko Mäkelä Assignee: Marko Mäkelä
Resolution: Fixed Votes: 0
Labels: performance

Issue Links:
Blocks
blocks MDEV-25506 Atomic DDL: .frm file is removed and ... Closed
Problem/Incident
causes MDEV-25996 sux_lock::s_lock(): Assertion !have_s... Closed
causes MDEV-27219 Some error messages might report tabl... Closed
causes MDEV-28264 Heap-use-after-free error while loadi... Open

 Description   

Many InnoDB data dictionary cache operations require that the table name be copied so that it will be NUL terminated. The table name that would be read from SYS_TABLES.NAME is not guaranteed to be NUL-terminated.

Let us refactor the code so that such unnecessary copying can be avoided and the table name can be passed as const span<const char>& to those functions that need it.

This will also change some error reporting, like this:

@@ -2314,8 +2317,10 @@ fil_ibd_open(
 	First, bail out if no tablespace files were found. */
 	if (valid_tablespaces_found == 0) {
 		os_file_get_last_error(true);
-		ib::error() << "Could not find a valid tablespace file for `"
-			<< tablename << "`. " << TROUBLESHOOT_DATADICT_MSG;
+		sql_print_error("InnoDB: Could not find a valid tablespace"
+				" file for %.*s. %s",
+				static_cast<int>(name.size()), name.data(),
+				TROUBLESHOOT_DATADICT_MSG);
 		goto corrupted;
 	}
 	if (!validate) {

The user-visible change is that instead of a string like `test`.`t1` the internal name `test/t1` will be reported.


Generated at Thu Feb 08 09:40:01 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.