Utf8mb4 / ERROR 1709 (HY000): Index column size too large. The maximum column size is 767 bytes

Hi there

I am now already struggling for hours with the known ERROR 1709 (HY000): Index column size too large. The maximum column size is 767 bytes.problem on a utf8mb4 table that cannot be changed in any ways.

I tried:

DROP INDEX `url` ON `wp_4_mailpoet_newsletter_links`;
ALTER TABLE `wp_4_mailpoet_newsletter_links` ROW_FORMAT=DYNAMIC;
REPAIR TABLE `wp_4_mailpoet_newsletter_links`;

all get rejected by the same error message. I am not even able to create a dump of the table structure:

mysqldump --no-data dbname wp_4_mailpoet_newsletter_links

a similar table which is still working (without data) looks like this:

CREATE TABLE `wp_3_mailpoet_newsletter_links` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `newsletter_id` int unsigned NOT NULL,
  `queue_id` int unsigned NOT NULL,
  `url` varchar(2083) COLLATE utf8mb4_unicode_520_ci NOT NULL,
  `hash` varchar(20) COLLATE utf8mb4_unicode_520_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `newsletter_id` (`newsletter_id`),
  KEY `queue_id` (`queue_id`),
  KEY `url` (`url`(100))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;

All tutorials and forum posts about this problem pointed me to the following:

set global innodb_default_row_format = dynamic;
set global innodb_large_prefix = ON;
set global innodb_file_format = Barracuda;

But both innodb_large_prefix and innodb_file_format won’t exist in 8.0.21-12 Percona Server for MySQL.
Here’s an extract (cannot post all due to forum limitations) of my current InnoDB settings:

mysql> SHOW GLOBAL VARIABLES LIKE 'innodb_%';
+---------------------------------------------+------------------------+
| Variable_name                               | Value                  |
+---------------------------------------------+------------------------+
| innodb_default_row_format                   | dynamic                |
| innodb_file_per_table                       | ON                     |
| innodb_strict_mode                          | ON                     |
| innodb_version                              | 8.0.21-12              |
+---------------------------------------------+------------------------+

Any help greatly appreciated!! Cheers, Philip

1 Like

Hi, what is the exact operation that you are trying to accomplish?

you can check that the table is using the newer table format that allows bigger keys with select * FROM INFORMATION_SCHEMA.INNODB_TABLES where name LIKE ‘%your_table%’;

In 8.0 the variables you mention are removed as it behaves like they are enabled all the time.

1 Like

Same here (8.0.21-12 Percona Server for MySQL), executing this query from @igroene (fixed by info from here: https://bugs.mysql.com/bug.php?id=96238):

select * FROM INFORMATION_SCHEMA.INNODB_TABLES where name LIKE ‘%TABLE_NAME%’;

results same error:

ERROR 1709 (HY000): Index column size too large. The maximum column size is 767 bytes.

In my case I’ve added a custom INDEX to Wordpress postmeta table filled with data, ROW FORMAT was COMPAT, INDEX was created, today I’ve noticed that errors are occuring when executing:

ALTER TABLE karty_postmeta CHANGE COLUMN meta_id meta_id bigint(20) unsigned NOT NULL auto_increment

error:

Index column size too large. The maximum column size is 767 bytes.

Drop index, alter table to ROW_FORMAT=DYNAMIC result same error as above, drop table and drop database too.

1 Like

I think you might be hitting the following bug https://bugs.mysql.com/bug.php?id=99791

Looks like it is fixed in upcoming 8.0.22

1 Like

full innodb variables output:

mysql> SHOW GLOBAL VARIABLES LIKE 'innodb_%';

+---------------------------------------------+------------------------+

| Variable_name                               | Value                  |

+---------------------------------------------+------------------------+

| innodb_adaptive_flushing                    | ON                     |

| innodb_adaptive_flushing_lwm                | 10                     |

| innodb_adaptive_hash_index                  | ON                     |

| innodb_adaptive_hash_index_parts            | 8                      |

| innodb_adaptive_max_sleep_delay             | 150000                 |

| innodb_api_bk_commit_interval               | 5                      |

| innodb_api_disable_rowlock                  | OFF                    |

| innodb_api_enable_binlog                    | OFF                    |

| innodb_api_enable_mdl                       | OFF                    |

| innodb_api_trx_level                        | 0                      |

| innodb_autoextend_increment                 | 64                     |

| innodb_autoinc_lock_mode                    | 2                      |

| innodb_background_scrub_data_check_interval | 3600                   |

| innodb_background_scrub_data_compressed     | OFF                    |

| innodb_background_scrub_data_interval       | 604800                 |

| innodb_background_scrub_data_uncompressed   | OFF                    |

| innodb_buffer_pool_chunk_size               | 134217728              |

| innodb_buffer_pool_dump_at_shutdown         | ON                     |

| innodb_buffer_pool_dump_now                 | OFF                    |

| innodb_buffer_pool_dump_pct                 | 25                     |

| innodb_buffer_pool_filename                 | ib_buffer_pool         |

| innodb_buffer_pool_in_core_file             | ON                     |

| innodb_buffer_pool_instances                | 12                     |

| innodb_buffer_pool_load_abort               | OFF                    |

| innodb_buffer_pool_load_at_startup          | ON                     |

| innodb_buffer_pool_load_now                 | OFF                    |

| innodb_buffer_pool_size                     | 22548578304            |

| innodb_change_buffer_max_size               | 25                     |

| innodb_change_buffering                     | all                    |

| innodb_checksum_algorithm                   | crc32                  |

| innodb_cleaner_lsn_age_factor               | high_checkpoint        |

| innodb_cmp_per_index_enabled                | OFF                    |

| innodb_commit_concurrency                   | 0                      |

| innodb_compressed_columns_threshold         | 96                     |

| innodb_compressed_columns_zip_level         | 6                      |

| innodb_compression_failure_threshold_pct    | 5                      |

| innodb_compression_level                    | 6                      |

| innodb_compression_pad_pct_max              | 50                     |

| innodb_concurrency_tickets                  | 5000                   |

| innodb_corrupt_table_action                 | assert                 |

| innodb_data_file_path                       | ibdata1:12M:autoextend |

| innodb_data_home_dir                        |                        |

| innodb_deadlock_detect                      | ON                     |

| innodb_dedicated_server                     | OFF                    |

| innodb_default_encryption_key_id            | 0                      |

| innodb_default_row_format                   | dynamic                |

| innodb_directories                          |                        |

| innodb_disable_sort_file_cache              | OFF                    |

| innodb_doublewrite                          | ON                     |

| innodb_doublewrite_batch_size               | 0                      |

| innodb_doublewrite_dir                      |                        |

| innodb_doublewrite_files                    | 24                     |

| innodb_doublewrite_pages                    | 4                      |

| innodb_empty_free_list_algorithm            | legacy                 |

| innodb_encrypt_online_alter_logs            | OFF                    |

| innodb_encryption_rotate_key_age            | 1                      |

| innodb_encryption_rotation_iops             | 100                    |

| innodb_encryption_threads                   | 0                      |

| innodb_fast_shutdown                        | 1                      |

| innodb_file_per_table                       | ON                     |

| innodb_fill_factor                          | 100                    |

| innodb_flush_log_at_timeout                 | 1                      |

| innodb_flush_log_at_trx_commit              | 1                      |

| innodb_flush_method                         | fsync                  |

| innodb_flush_neighbors                      | 0                      |

| innodb_flush_sync                           | ON                     |

| innodb_flushing_avg_loops                   | 30                     |

| innodb_force_index_records_in_range         | 0                      |

| innodb_force_load_corrupted                 | OFF                    |

| innodb_force_recovery                       | 0                      |

| innodb_fsync_threshold                      | 0                      |

| innodb_ft_aux_table                         |                        |

| innodb_ft_cache_size                        | 8000000                |

| innodb_ft_enable_diag_print                 | OFF                    |

| innodb_ft_enable_stopword                   | ON                     |

| innodb_ft_ignore_stopwords                  | OFF                    |

| innodb_ft_max_token_size                    | 84                     |

| innodb_ft_min_token_size                    | 3                      |

| innodb_ft_num_word_optimize                 | 2000                   |

| innodb_ft_result_cache_limit                | 2000000000             |

| innodb_ft_server_stopword_table             |                        |

| innodb_ft_sort_pll_degree                   | 2                      |

| innodb_ft_total_cache_size                  | 640000000              |

| innodb_ft_user_stopword_table               |                        |

| innodb_idle_flush_pct                       | 100                    |

| innodb_immediate_scrub_data_uncompressed    | OFF                    |

| innodb_io_capacity                          | 10000                  |

| innodb_io_capacity_max                      | 20000                  |

| innodb_lock_wait_timeout                    | 50                     |

| innodb_log_buffer_size                      | 16777216               |

| innodb_log_checksums                        | ON                     |

| innodb_log_compressed_pages                 | ON                     |

| innodb_log_file_size                        | 134217728              |

| innodb_log_files_in_group                   | 2                      |

| innodb_log_group_home_dir                   | ./                     |

| innodb_log_spin_cpu_abs_lwm                 | 80                     |

| innodb_log_spin_cpu_pct_hwm                 | 50                     |

| innodb_log_wait_for_flush_spin_hwm          | 400                    |

| innodb_log_write_ahead_size                 | 8192                   |

| innodb_lru_scan_depth                       | 1024                   |

| innodb_max_bitmap_file_size                 | 104857600              |

| innodb_max_changed_pages                    | 1000000                |

| innodb_max_dirty_pages_pct                  | 90.000000              |

| innodb_max_dirty_pages_pct_lwm              | 10.000000              |

| innodb_max_purge_lag                        | 0                      |

| innodb_max_purge_lag_delay                  | 0                      |

| innodb_max_undo_log_size                    | 1073741824             |

| innodb_monitor_disable                      |                        |

| innodb_monitor_enable                       |                        |

| innodb_monitor_reset                        |                        |

| innodb_monitor_reset_all                    |                        |

| innodb_numa_interleave                      | OFF                    |

| innodb_old_blocks_pct                       | 37                     |

| innodb_old_blocks_time                      | 1000                   |

| innodb_online_alter_log_max_size            | 134217728              |

| innodb_open_files                           | 1024                   |

| innodb_optimize_fulltext_only               | OFF                    |

| innodb_page_cleaners                        | 4                      |

| innodb_page_size                            | 16384                  |

| innodb_parallel_dblwr_encrypt               | OFF                    |

| innodb_parallel_doublewrite_path            | xb_doublewrite         |

| innodb_parallel_read_threads                | 4                      |

| innodb_print_all_deadlocks                  | OFF                    |

| innodb_print_ddl_logs                       | OFF                    |

| innodb_print_lock_wait_timeout_info         | OFF                    |

| innodb_purge_batch_size                     | 300                    |

| innodb_purge_rseg_truncate_frequency        | 128                    |

| innodb_purge_threads                        | 4                      |

| innodb_random_read_ahead                    | OFF                    |

| innodb_read_ahead_threshold                 | 56                     |

| innodb_read_io_threads                      | 4                      |

| innodb_read_only                            | OFF                    |

| innodb_records_in_range                     | 0                      |

| innodb_redo_log_archive_dirs                |                        |

| innodb_redo_log_encrypt                     | OFF                    |

| innodb_replication_delay                    | 0                      |

| innodb_rollback_on_timeout                  | OFF                    |

| innodb_rollback_segments                    | 128                    |

| innodb_scrub_log                            | OFF                    |

| innodb_scrub_log_speed                      | 256                    |

| innodb_show_locks_held                      | 10                     |

| innodb_sort_buffer_size                     | 1048576                |

| innodb_spin_wait_delay                      | 6                      |

| innodb_spin_wait_pause_multiplier           | 50                     |

| innodb_stats_auto_recalc                    | ON                     |

| innodb_stats_include_delete_marked          | OFF                    |

| innodb_stats_method                         | nulls_equal            |

| innodb_stats_on_metadata                    | OFF                    |

| innodb_stats_persistent                     | ON                     |

| innodb_stats_persistent_sample_pages        | 20                     |

| innodb_stats_transient_sample_pages         | 8                      |

| innodb_status_output                        | OFF                    |

| innodb_status_output_locks                  | OFF                    |

| innodb_strict_mode                          | ON                     |

| innodb_sync_array_size                      | 1                      |

| innodb_sync_spin_loops                      | 30                     |

| innodb_sys_tablespace_encrypt               | OFF                    |

| innodb_table_locks                          | ON                     |

| innodb_temp_data_file_path                  | ibtmp1:12M:autoextend  |

| innodb_temp_tablespace_encrypt              | OFF                    |

| innodb_temp_tablespaces_dir                 | ./#innodb_temp/        |

| innodb_thread_concurrency                   | 0                      |

| innodb_thread_sleep_delay                   | 10000                  |

| innodb_tmpdir                               |                        |

| innodb_track_changed_pages                  | OFF                    |

| innodb_undo_directory                       | ./                     |

| innodb_undo_log_encrypt                     | OFF                    |

| innodb_undo_log_truncate                    | ON                     |

| innodb_undo_tablespaces                     | 2                      |

| innodb_use_native_aio                       | ON                     |

| innodb_validate_tablespace_paths            | ON                     |

| innodb_version                              | 8.0.21-12              |

| innodb_write_io_threads                     | 4                      |

+---------------------------------------------+------------------------+

1 Like

Right, @igroene that https://bugs.mysql.com/bug.php?id=99791 really seems the bug we’re hitting here!

I am still worried if this could affect other tables as well, as we’re in the middle of migrating thousands of tables from MyISAM to InnoDB with most of them dating back to pre-2018 when we were still running MySQL 5.6. Could you tell if there is any risk migrating a table with ALTER TABLE … ENGINE=InnoDB?

I am still struggling with getting rid of that broken table, even tried dropping the whole database:

mysql> DROP TABLE `wp_4_mailpoet_newsletter_links`;
ERROR 1709 (HY000): Index column size too large. The maximum column size is 767 bytes.
mysql> DROP DATABASE `mydb`;
ERROR 1709 (HY000): Index column size too large. The maximum column size is 767 bytes.

Also tried removing the table’s *.ibd file from /var/lib/mysql/dbname/ , restarting MySQL afterwards, which also didn’t help.

My workaround then was to migrate the whole database with mysqldump --ignore-table=mydb.wp_4_mailpoet_newsletter_links to another database, and then restoring this single table from an old backup (before MySQL 8.0 migration).

But we still need to get rid of that table and as far as I understood https://bugs.mysql.com/bug.php?id=99791 this would only prevent it from happening in MySQL 8.0.22, but not fixing such already broken tables/indexes, right?

1 Like

You are right. Maybe if you have a replica where the table is still accessible you could pull it from there as well.

1 Like

@igroene on one webserver we have several thousands of InnoDB tables with ROW_FORMAT=COMPACT. Do you think it makes sense to change those already today on Percona/MySQL 8.0.21 (prior to MySQL 8.0.22 bugfix release) to ROW_FORMAT=DYNAMIC to avoid this problem from happening again with another table? Or is there also a risk if I do so?

Aside that, I still don’t know how to get rid of that broken table. The only remaining option I can think of would be to do a full reset of the whole MySQL server and load a full dump of all customer databases (+ pt-show-grants dump), excluding only this single broken table. But that would only be possible in a night shift with a pretty long downtime, as we’re talking about 35G data in /var/lib/mysql and a full system mysqldump of 1G compressed (gzip).

What is your recommendation for me to lower the risk of this happening again on other tables? Will Percona release 8.0.22 anytime soon?

1 Like

We should do a more thorough analysis of the current situation and some testing before recommending you a strategy. I suggest you consider a small consulting engagement for this. https://learn.percona.com/contact-me in case you are interested.

1 Like

Hi @igroene - Happy New Year and thanks for your offer. I managed to fix the problem by a massive restore of all databases using a full mysqldump with --ignore-table option to exclude the broken table. The whole thing caused a 1.5h downtime for my customers, but it was worth it, as anyway I wanted to get ready for XtraBackup with a clean state of all InnoDB tables.

I have upgraded to Percona Server for MySQL 8.0.22 on Dec 14th, which supposedly fixes MySQL Bugs: #99791: MySQL 8 orphaned table due to unchecked non-existent row format check.
This issue did not pop up on any other table.

Thanks for your support. I guess you can close this thread.

1 Like