Bug #120949 Sql_cmd_secondary_load_unload::mysql_secondary_load_or_unload(THD*, Table_ref*): Assertion `m_alter_info->requested_algo
Submitted: 17 Jul 5:24
Reporter: xingwang Verdant Email Updates:
Status: Open Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:8.4.10 OS:Ubuntu (ubuntu22.04 docker in the fedora host)
Assigned to: CPU Architecture:x86 (x64)
Tags: assertion failure, crash, input-validation, MySQL 8.4.10, Secondary Engine, SECONDARY_LOAD/UNLOAD

[17 Jul 5:24] xingwang Verdant
Description:
 On a debug build of MySQL 8.4.10, executing an ALTER TABLE that combines an explicit ALGORITHM= clause with SECONDARY_UNLOAD aborts the server (SIGABRT) via a
  failed assertion:

  mysqld: /build/mysql-src/sql/sql_table.cc:11689:
    bool Sql_cmd_secondary_load_unload::mysql_secondary_load_or_unload(THD*, Table_ref*):
    Assertion `m_alter_info->requested_algorithm == Alter_info::ALTER_TABLE_ALGORITHM_DEFAULT' failed.
  mysqld got signal 6 ;
  Query: ALTER TABLE v0 ALGORITHM = INPLACE , SECONDARY_UNLOAD

How to repeat:
create table v1099(c1100 INT);
CREATE TABLE IF NOT EXISTS v0 ( CONSTRAINT FOREIGN KEY ( c1100 ( 100 ) ) REFERENCES v1099 MATCH PARTIAL ON DELETE CASCADE ON UPDATE CASCADE , c1 LONGBLOB COLLATE BINARY AS ( TRUE ) ) STORAGE MEMORY , STORAGE MEMORY PARTITION BY RANGE ( c1100 ) AS TABLE test_sqlright1 . v1099 LIMIT 100 , c1100 ; 
INSERT DELAYED INTO test_sqlright1 . v0 PARTITION ( v0 ) ( ) SELECT * ON DUPLICATE KEY UPDATE c1 = DEFAULT ; 
INSERT HIGH_PRIORITY INTO v1099 PARTITION ( v0 ) SET test_sqlright1 . v1099 . c1 = DEFAULT AS v0 ( v0 ) ON DUPLICATE KEY UPDATE v0 . c1100 = DEFAULT ; 
INSERT LOW_PRIORITY test_sqlright1 . v1099 ( ) VALUE ( ) ON DUPLICATE KEY UPDATE v0 . c1100 = DEFAULT ; 
INSERT LOW_PRIORITY IGNORE v1099 PARTITION ( v0 ) SET c1100 = DEFAULT , c1 = DEFAULT AS v0 ON DUPLICATE KEY UPDATE v0 . c1100 = DEFAULT ; 
ALTER TABLE v0 ALGORITHM = INPLACE , SECONDARY_UNLOAD ; 

Suggested fix:
Reject the clause combination during ALTER TABLE preparation, before dispatching to the secondary-engine handler, returning a proper error (e.g.
  ER_WRONG_USAGE, "SECONDARY_UNLOAD cannot be used with ALGORITHM") instead of relying on the downstream assertion. Concretely, in the SECONDARY_LOAD/UNLOAD
  prepare path validate requested_algorithm == ALTER_TABLE_ALGORITHM_DEFAULT and raise an error if not — mirroring the assertion as a user-facing check. (The
  assertion at sql_table.cc:11689 should then become unreachable from SQL.)