[MDEV-22465] DROP COLUMN, DROP INDEX is wrongly claimed to be ALGORITHM=INSTANT Created: 2020-05-05  Updated: 2020-05-05  Resolved: 2020-05-05

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.4.1, 10.5.0
Fix Version/s: 10.4.13, 10.5.3

Type: Bug Priority: Blocker
Reporter: Marko Mäkelä Assignee: Marko Mäkelä
Resolution: Fixed Votes: 0
Labels: regression

Issue Links:
Problem/Incident
is caused by MDEV-15563 Instant failure-free data type conver... Closed
Relates
relates to MDEV-21832 FORCE all partition to rebuild if any... Closed

 Description   

The following SQL test case works on 10.3 but fails to return an error on 10.4:

--source include/have_innodb.inc
CREATE TABLE t1(a INT PRIMARY KEY, b INT UNIQUE) ENGINE=InnoDB;
--error ER_ALTER_OPERATION_NOT_SUPPORTED
ALTER TABLE t1 DROP b, ALGORITHM=INSTANT;
DROP TABLE t1;

The reason appears to be a code change that was part of MDEV-15563:

@@ -2003,9 +2040,7 @@ ha_innobase::check_if_supported_inplace_alter(
 		af++;
 	}
 
-	if (supports_instant
-	    || !(ha_alter_info->handler_flags
-		 & ~(INNOBASE_ALTER_INSTANT | INNOBASE_INPLACE_IGNORE))) {
+	if (supports_instant) {
 		DBUG_RETURN(HA_ALTER_INPLACE_INSTANT);
 	}
 

We should not return HA_ALTER_INPLACE_INSTANT if any flags in INNOBASE_ALTER_NOREBUILD (dropping or creating secondary indexes) are set, because those are not instantaneous operations.



 Comments   
Comment by Marko Mäkelä [ 2020-05-05 ]

The following fix seems to work:

diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index 64607293ed9..ae1b6073b3a 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -2474,7 +2474,8 @@ ha_innobase::check_if_supported_inplace_alter(
 		}
 	}
 
-	if (supports_instant) {
+	if (supports_instant && !(ha_alter_info->handler_flags
+				  & INNOBASE_ALTER_NOREBUILD)) {
 		DBUG_RETURN(HA_ALTER_INPLACE_INSTANT);
 	}
 
@@ -2585,7 +2586,9 @@ ha_innobase::check_if_supported_inplace_alter(
 	}
 
 	if (need_rebuild || fts_need_rebuild) {
-		ha_alter_info->handler_flags |= ALTER_RECREATE_TABLE;
+		if (!supports_instant) {
+			ha_alter_info->handler_flags |= ALTER_RECREATE_TABLE;
+		}
 		DBUG_RETURN(online
 			    ? HA_ALTER_INPLACE_COPY_NO_LOCK
 			    : HA_ALTER_INPLACE_COPY_LOCK);

The second part is refining MDEV-21832. Without that change, we would unnecessarily force a table to be rebuilt when dropping an indexed column.

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