[MDEV-22334] Assertion `col->len == len' failed in innobase_rename_or_enlarge_column_try on ALTER Created: 2020-04-22  Updated: 2022-01-19  Resolved: 2022-01-19

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Alter Table, Storage Engine - InnoDB
Affects Version/s: 10.5.2, 10.5.3, 10.4
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Roel Van de Paar Assignee: Eugene Kosov (Inactive)
Resolution: Fixed Votes: 0
Labels: not-10.1, not-10.2, not-10.3, regression

Issue Links:
Duplicate
is duplicated by MDEV-22528 Assertion `col->len == len' failed in... Closed
Problem/Incident
is caused by MDEV-15564 Avoid table rebuild in ALTER TABLE on... Closed
Relates
relates to MDEV-22365 Assertion `!col->mbmaxlen || len >= c... Closed

 Description   

USE test;
CREATE TABLE t(a CHAR BINARY) ENGINE=InnoDB;
ALTER TABLE t CHANGE COLUMN a a CHAR(20);

Leads to:

10.5.3 98003440c2f8d20164a191ced1b7d92b283bb68f

mysqld: /test/10.5_dbg/storage/innobase/handler/handler0alter.cc:9106: bool innobase_rename_or_enlarge_column_try(ha_innobase_inplace_ctx*, trx_t*, const char*, ulint, const Field&, bool): Assertion `col->len == len' failed.

10.5.3 98003440c2f8d20164a191ced1b7d92b283bb68f

Core was generated by `/test/MD210420-mariadb-10.5.3-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
Program terminated with signal SIGABRT, Aborted.
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6)
    at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
[Current thread is 1 (Thread 0x7faddd88c700 (LWP 955978))]
(gdb) bt
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
#1  0x000055555bdaf03d in my_write_core (sig=sig@entry=6) at /test/10.5_dbg/mysys/stacktrace.c:518
#2  0x000055555b554d7b in handle_fatal_signal (sig=6) at /test/10.5_dbg/sql/signal_handler.cc:329
#3  <signal handler called>
#4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#5  0x00007faddbfd0801 in __GI_abort () at abort.c:79
#6  0x00007faddbfc039a in __assert_fail_base (fmt=0x7faddc1477d8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x55555c1a4094 "col->len == len", file=file@entry=0x55555c1994e8 "/test/10.5_dbg/storage/innobase/handler/handler0alter.cc", line=line@entry=9106, function=function@entry=0x55555c19eb00 <innobase_rename_or_enlarge_column_try(ha_innobase_inplace_ctx*, trx_t*, char const*, unsigned long, Field const&, bool)::__PRETTY_FUNCTION__> "bool innobase_rename_or_enlarge_column_try(ha_innobase_inplace_ctx*, trx_t*, const char*, ulint, const Field&, bool)") at assert.c:92
#7  0x00007faddbfc0412 in __GI___assert_fail (assertion=assertion@entry=0x55555c1a4094 "col->len == len", file=file@entry=0x55555c1994e8 "/test/10.5_dbg/storage/innobase/handler/handler0alter.cc", line=line@entry=9106, function=function@entry=0x55555c19eb00 <innobase_rename_or_enlarge_column_try(ha_innobase_inplace_ctx*, trx_t*, char const*, unsigned long, Field const&, bool)::__PRETTY_FUNCTION__> "bool innobase_rename_or_enlarge_column_try(ha_innobase_inplace_ctx*, trx_t*, const char*, ulint, const Field&, bool)") at assert.c:101
#8  0x000055555b96066a in innobase_rename_or_enlarge_column_try (is_v=<optimized out>, f=..., pos=0, table_name=0x7fadb00dfc2d "t", trx=0x7fadc7c033b0, ctx=0x7fadb00755b8) at /test/10.5_dbg/storage/innobase/handler/handler0alter.cc:9106
#9  innobase_rename_or_enlarge_columns_try (table_name=0x7fadb00dfc2d "t", trx=0x7fadc7c033b0, table=0x7fadb00f0088, altered_table=0x7faddd887a70, ctx=0x7fadb00755b8, ha_alter_info=0x7faddd8879d0) at /test/10.5_dbg/storage/innobase/handler/handler0alter.cc:9181
#10 commit_try_norebuild (ha_alter_info=ha_alter_info@entry=0x7faddd8879d0, ctx=ctx@entry=0x7fadb00755b8, altered_table=altered_table@entry=0x7faddd887a70, old_table=0x7fadb00f0088, trx=0x7fadc7c033b0, table_name=0x7fadb00dfc2d "t") at /test/10.5_dbg/storage/innobase/handler/handler0alter.cc:10095
#11 0x000055555b94d0fe in ha_innobase::commit_inplace_alter_table (this=0x7fadb0036ca0, altered_table=0x7faddd887a70, ha_alter_info=0x7faddd8879d0, commit=true) at /test/10.5_dbg/storage/innobase/handler/handler0alter.cc:10827
#12 0x000055555b563449 in handler::ha_commit_inplace_alter_table (this=0x7fadb0036ca0, altered_table=altered_table@entry=0x7faddd887a70, ha_alter_info=ha_alter_info@entry=0x7faddd8879d0, commit=commit@entry=true) at /test/10.5_dbg/sql/handler.cc:4725
#13 0x000055555b37559b in mysql_inplace_alter_table (thd=thd@entry=0x7fadb0015088, table_list=0x7fadb00741a0, table=table@entry=0x7fadb00f0088, altered_table=altered_table@entry=0x7faddd887a70, ha_alter_info=ha_alter_info@entry=0x7faddd8879d0, inplace_supported=inplace_supported@entry=HA_ALTER_INPLACE_INSTANT, target_mdl_request=0x7faddd888830, alter_ctx=0x7faddd8896c0) at /test/10.5_dbg/sql/sql_table.cc:7923
#14 0x000055555b3819e0 in mysql_alter_table (thd=thd@entry=0x7fadb0015088, new_db=new_db@entry=0x7fadb0019940, new_name=new_name@entry=0x7fadb0019d48, create_info=create_info@entry=0x7faddd88a2b0, table_list=<optimized out>, table_list@entry=0x7fadb00741a0, alter_info=alter_info@entry=0x7faddd88a1e0, order_num=0, order=0x0, ignore=false, if_exists=false) at /test/10.5_dbg/sql/sql_table.cc:10444
#15 0x000055555b404f31 in Sql_cmd_alter_table::execute (this=<optimized out>, thd=0x7fadb0015088) at /test/10.5_dbg/sql/sql_alter.cc:520
#16 0x000055555b2b0422 in mysql_execute_command (thd=thd@entry=0x7fadb0015088) at /test/10.5_dbg/sql/sql_parse.cc:5912
#17 0x000055555b2b7f2b in mysql_parse (thd=thd@entry=0x7fadb0015088, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x7faddd88b450, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_dbg/sql/sql_parse.cc:7957
#18 0x000055555b2a3c45 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x7fadb0015088, packet=packet@entry=0x7fadb0067089 "ALTER TABLE t CHANGE COLUMN a a CHAR(20)", packet_length=packet_length@entry=40, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_dbg/sql/sql_parse.cc:1839
#19 0x000055555b2a249b in do_command (thd=0x7fadb0015088) at /test/10.5_dbg/sql/sql_parse.cc:1358
#20 0x000055555b3fd415 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x7fadbbbc53a8, put_in_cache=put_in_cache@entry=true) at /test/10.5_dbg/sql/sql_connect.cc:1422
#21 0x000055555b3fd744 in handle_one_connection (arg=arg@entry=0x7fadbbbc53a8) at /test/10.5_dbg/sql/sql_connect.cc:1319
#22 0x000055555b85dfb0 in pfs_spawn_thread (arg=0x7faddb445b08) at /test/10.5_dbg/storage/perfschema/pfs.cc:2201
#23 0x00007faddccb36db in start_thread (arg=0x7faddd88c700) at pthread_create.c:463
#24 0x00007faddc0b188f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.4.13 (dbg), 10.5.2 (dbg), 10.5.3 (dbg)

Bug confirmed not present in:
MariaDB: 10.1.45 (dbg), 10.1.45 (opt), 10.2.32 (dbg), 10.2.32 (opt), 10.3.23 (dbg), 10.3.23 (opt), 10.4.13 (opt), 10.5.2 (opt), 10.5.3 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.47 (dbg), 5.6.47 (opt), 5.7.29 (dbg), 5.7.29 (opt), 8.0.19 (dbg), 8.0.19 (opt)



 Comments   
Comment by Marko Mäkelä [ 2020-04-22 ]

This ought to be a regression caused by MDEV-15564. Earlier, this type of operation would cause the table to be rebuilt by ALGORITHM=COPY.

Comment by Roel Van de Paar [ 2020-05-12 ]

MDEV-22528 marked as duplicate

USE test;
CREATE TABLE t (c CHAR(10) BINARY) ENGINE=InnoDB;
ALTER TABLE t CHANGE COLUMN c a CHAR(11);

Comment by Alice Sherepa [ 2022-01-18 ]

not reproducible on the current 10.4-10.5

Comment by Marko Mäkelä [ 2022-01-18 ]

I tested two candidates that could have fixed this:

MDEV-23805 could have changed what happens when the table is empty. So, I changed the test to the following:

--source include/have_innodb.inc
CREATE TABLE t(a CHAR BINARY) ENGINE=InnoDB;
INSERT INTO t SET a='';
ALTER TABLE t CHANGE COLUMN a a CHAR(20), ALGORITHM=INSTANT;
SELECT * FROM t;
SHOW CREATE TABLE t;
DROP TABLE t;

I did not test this on 10.4 or 10.5. On 10.8, ALGORITHM=INSTANT would be refused because the column type would change in a way that requires ALGORITHM=COPY (the traditional way).

My second suspect is MDEV-23245. Even after reverting that fix, the test will still refuse the ALTER TABLE operation.

Comment by Roel Van de Paar [ 2022-01-19 ]

Issue confirmed no longer reproducible in any current branch.

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