[MDEV-24558] Assertion `!(index)->is_spatial()' failed | Assertion `!index->is_spatial()' failed. | Assertion `!dict_index_is_spatial(index)' failed | All in btr_estimate_number_of_different_key_vals Created: 2021-01-11  Updated: 2023-12-08

Status: Confirmed
Project: MariaDB Server
Component/s: GIS, Storage Engine - InnoDB
Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9
Fix Version/s: 10.4, 10.5, 10.6, 10.11, 11.0, 11.1

Type: Bug Priority: Major
Reporter: Roel Van de Paar Assignee: Vladislav Lesin
Resolution: Unresolved Votes: 0
Labels: None


 Description   

CREATE TABLE t(c POINT NOT NULL) ENGINE=InnoDB;
DROP TABLE mysql.innodb_table_stats;
CREATE SPATIAL INDEX i ON t(c);

Leads to:

10.6.0 9118fd360a3da0bba521caf2a35c424968235ac4 (Debug)

mysqld: /test/10.6_dbg/storage/innobase/btr/btr0cur.cc:6575: std::vector<index_field_stats_t> btr_estimate_number_of_different_key_vals(dict_index_t*): Assertion `!(index)->is_spatial()' failed.

10.6.0 9118fd360a3da0bba521caf2a35c424968235ac4 (Debug)

Core was generated by `/test/MD010121-mariadb-10.6.0-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:56
[Current thread is 1 (Thread 0x145a54097700 (LWP 2837029))]
(gdb) bt
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
#1  0x000055c2735c00d7 in my_write_core (sig=sig@entry=6) at /test/10.6_dbg/mysys/stacktrace.c:424
#2  0x000055c272d54ab1 in handle_fatal_signal (sig=6) at /test/10.6_dbg/sql/signal_handler.cc:330
#3  <signal handler called>
#4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#5  0x0000145a57c55859 in __GI_abort () at abort.c:79
#6  0x0000145a57c55729 in __assert_fail_base (fmt=0x145a57deb588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55c273960a4c "!(index)->is_spatial()", file=0x55c2739d5230 "/test/10.6_dbg/storage/innobase/btr/btr0cur.cc", line=6575, function=<optimized out>) at assert.c:92
#7  0x0000145a57c66f36 in __GI___assert_fail (assertion=assertion@entry=0x55c273960a4c "!(index)->is_spatial()", file=file@entry=0x55c2739d5230 "/test/10.6_dbg/storage/innobase/btr/btr0cur.cc", line=line@entry=6575, function=function@entry=0x55c2739d86c8 "std::vector<index_field_stats_t> btr_estimate_number_of_different_key_vals(dict_index_t*)") at assert.c:101
#8  0x000055c2733e9420 in btr_estimate_number_of_different_key_vals (index=index@entry=0x145a0001f088) at /test/10.6_dbg/storage/innobase/include/dict0mem.h:1171
#9  0x000055c27349c2a4 in dict_stats_update_transient_for_index (index=index@entry=0x145a0001f088) at /test/10.6_dbg/storage/innobase/dict/dict0stats.cc:881
#10 0x000055c27349fb0f in dict_stats_update_for_index (index=index@entry=0x145a0001f088) at /test/10.6_dbg/storage/innobase/dict/dict0stats.cc:3167
#11 0x000055c273198473 in alter_stats_norebuild (thd=0x145a00000db8, ctx=0x145a00013d40, ha_alter_info=0x145a540941b0) at /test/10.6_dbg/storage/innobase/handler/handler0alter.cc:10609
#12 ha_innobase::commit_inplace_alter_table (this=0x145a0006b3b0, altered_table=<optimized out>, ha_alter_info=<optimized out>, commit=<optimized out>) at /test/10.6_dbg/storage/innobase/handler/handler0alter.cc:11378
#13 0x000055c272d632c5 in handler::ha_commit_inplace_alter_table (this=0x145a0006b3b0, altered_table=altered_table@entry=0x145a54094250, ha_alter_info=ha_alter_info@entry=0x145a540941b0, commit=commit@entry=true) at /test/10.6_dbg/sql/handler.cc:4848
#14 0x000055c272b5843e in mysql_inplace_alter_table (thd=thd@entry=0x145a00000db8, table_list=0x145a000127b0, table=table@entry=0x145a0006aab8, altered_table=altered_table@entry=0x145a54094250, ha_alter_info=ha_alter_info@entry=0x145a540941b0, target_mdl_request=target_mdl_request@entry=0x145a540947a0, alter_ctx=0x145a540952f0) at /test/10.6_dbg/sql/sql_table.cc:8107
#15 0x000055c272b6bb1f in mysql_alter_table (thd=thd@entry=0x145a00000db8, new_db=new_db@entry=0x145a000127c8, new_name=new_name@entry=0x145a000127d8, create_info=create_info@entry=0x145a54095f60, table_list=<optimized out>, table_list@entry=0x145a000127b0, alter_info=alter_info@entry=0x145a54095e90, order_num=0, order=0x0, ignore=false, if_exists=false) at /test/10.6_dbg/sql/sql_table.cc:10651
#16 0x000055c272a9083c in mysql_execute_command (thd=thd@entry=0x145a00000db8) at /test/10.6_dbg/sql/structs.h:559
#17 0x000055c272a7c072 in mysql_parse (thd=thd@entry=0x145a00000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x145a540963d0) at /test/10.6_dbg/sql/sql_parse.cc:7881
#18 0x000055c272a8a1ec in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x145a00000db8, packet=packet@entry=0x145a00008d39 "CREATE SPATIAL INDEX i ON t(c)", packet_length=packet_length@entry=30) at /test/10.6_dbg/sql/sql_class.h:1293
#19 0x000055c272a8d52d in do_command (thd=0x145a00000db8) at /test/10.6_dbg/sql/sql_parse.cc:1348
#20 0x000055c272be97fc in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55c27584bb68, put_in_cache=put_in_cache@entry=true) at /test/10.6_dbg/sql/sql_connect.cc:1410
#21 0x000055c272be9f03 in handle_one_connection (arg=arg@entry=0x55c27584bb68) at /test/10.6_dbg/sql/sql_connect.cc:1312
#22 0x000055c27309f88f in pfs_spawn_thread (arg=0x55c275752898) at /test/10.6_dbg/storage/perfschema/pfs.cc:2201
#23 0x0000145a58163609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#24 0x0000145a57d52293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

10.3 And 10.2 give a slightly different assert:

10.3.28 e59c1cef3bc4016f9fa9d7a0f6935463b7283a58 (Debug)

mysqld: /test/10.3_dbg/storage/innobase/btr/btr0cur.cc:6597: std::vector<index_field_stats_t> btr_estimate_number_of_different_key_vals(dict_index_t*): Assertion `!dict_index_is_spatial(index)' failed.

10.3.28 e59c1cef3bc4016f9fa9d7a0f6935463b7283a58 (Debug)

Core was generated by `/test/MD010121-mariadb-10.3.28-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:56
[Current thread is 1 (Thread 0x146e7c0eb700 (LWP 2862199))]
(gdb) bt
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
#1  0x000055deaeef6b50 in my_write_core (sig=sig@entry=6) at /test/10.3_dbg/mysys/stacktrace.c:386
#2  0x000055deae6aeb6a in handle_fatal_signal (sig=6) at /test/10.3_dbg/sql/signal_handler.cc:343
#3  <signal handler called>
#4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#5  0x0000146e91bb7859 in __GI_abort () at abort.c:79
#6  0x0000146e91bb7729 in __assert_fail_base (fmt=0x146e91d4d588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55deaf1371d7 "!dict_index_is_spatial(index)", file=0x55deaf1ad738 "/test/10.3_dbg/storage/innobase/btr/btr0cur.cc", line=6597, function=<optimized out>) at assert.c:92
#7  0x0000146e91bc8f36 in __GI___assert_fail (assertion=assertion@entry=0x55deaf1371d7 "!dict_index_is_spatial(index)", file=file@entry=0x55deaf1ad738 "/test/10.3_dbg/storage/innobase/btr/btr0cur.cc", line=line@entry=6597, function=function@entry=0x55deaf1af838 "std::vector<index_field_stats_t> btr_estimate_number_of_different_key_vals(dict_index_t*)") at assert.c:101
#8  0x000055deaeb9d330 in btr_estimate_number_of_different_key_vals (index=index@entry=0x146e3001ecd0) at /test/10.3_dbg/storage/innobase/btr/btr0cur.cc:6597
#9  0x000055deaec77a4a in dict_stats_update_transient_for_index (index=index@entry=0x146e3001ecd0) at /test/10.3_dbg/storage/innobase/dict/dict0stats.cc:883
#10 0x000055deaec7faab in dict_stats_update_for_index (index=index@entry=0x146e3001ecd0) at /test/10.3_dbg/storage/innobase/dict/dict0stats.cc:3182
#11 0x000055deae925ee2 in alter_stats_norebuild (thd=<optimized out>, ctx=0x146e30012a78, ha_alter_info=0x146e7c0e7820) at /test/10.3_dbg/storage/innobase/handler/handler0alter.cc:9169
#12 ha_innobase::commit_inplace_alter_table (this=0x146e3004e888, altered_table=<optimized out>, ha_alter_info=<optimized out>, commit=<optimized out>) at /test/10.3_dbg/storage/innobase/handler/handler0alter.cc:10055
#13 0x000055deae6bc1cf in handler::ha_commit_inplace_alter_table (this=0x146e3004e888, altered_table=altered_table@entry=0x146e30052730, ha_alter_info=ha_alter_info@entry=0x146e7c0e7820, commit=commit@entry=true) at /test/10.3_dbg/sql/handler.cc:4602
#14 0x000055deae4db054 in mysql_inplace_alter_table (thd=thd@entry=0x146e30000d90, table_list=0x146e30011640, table=table@entry=0x146e3004d7e0, altered_table=altered_table@entry=0x146e30052730, ha_alter_info=ha_alter_info@entry=0x146e7c0e7820, inplace_supported=inplace_supported@entry=HA_ALTER_INPLACE_NOCOPY_LOCK, target_mdl_request=0x146e7c0e7a40, alter_ctx=0x146e7c0e8210) at /test/10.3_dbg/sql/sql_table.cc:7735
#15 0x000055deae4e71f1 in mysql_alter_table (thd=thd@entry=0x146e30000d90, new_db=new_db@entry=0x146e30011658, new_name=new_name@entry=0x146e30011668, create_info=create_info@entry=0x146e7c0e8e70, table_list=<optimized out>, table_list@entry=0x146e30011640, alter_info=alter_info@entry=0x146e7c0e8db0, order_num=0, order=0x0, ignore=false) at /test/10.3_dbg/sql/sql_table.cc:9980
#16 0x000055deae420fcb in mysql_execute_command (thd=thd@entry=0x146e30000d90) at /test/10.3_dbg/sql/sql_parse.cc:4124
#17 0x000055deae42a641 in mysql_parse (thd=thd@entry=0x146e30000d90, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x146e7c0ea540, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.3_dbg/sql/sql_parse.cc:7840
#18 0x000055deae42cdee in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x146e30000d90, packet=packet@entry=0x146e300198d1 "CREATE SPATIAL INDEX i ON t(c)", packet_length=packet_length@entry=30, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.3_dbg/sql/sql_class.h:1139
#19 0x000055deae42ff94 in do_command (thd=0x146e30000d90) at /test/10.3_dbg/sql/sql_parse.cc:1398
#20 0x000055deae55743c in do_handle_one_connection (connect=connect@entry=0x55deb0eb7c60) at /test/10.3_dbg/sql/sql_connect.cc:1403
#21 0x000055deae557673 in handle_one_connection (arg=0x55deb0eb7c60) at /test/10.3_dbg/sql/sql_connect.cc:1308
#22 0x0000146e920bd609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#23 0x0000146e91cb4293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.2.37 (dbg), 10.3.28 (dbg), 10.4.18 (dbg), 10.5.9 (dbg), 10.6.0 (dbg)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.2.37 (opt), 10.3.28 (opt), 10.4.18 (opt), 10.5.9 (opt), 10.6.0 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.50 (dbg), 5.6.50 (opt), 5.7.32 (dbg), 5.7.32 (opt), 8.0.22 (dbg), 8.0.22 (opt)



 Comments   
Comment by Marko Mäkelä [ 2021-01-11 ]

This looks like an InnoDB bug. I do not think that spatial indexes should have statistics at all. But, I seem to remember that handler::records_in_range() may be called on them.

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

CREATE TABLE t (c POINT PRIMARY KEY);
DROP TABLE mysql.innodb_index_stats;
ALTER TABLE t ADD SPATIAL INDEX i (c ASC);

Leads to:

10.8.0 e222e44d1bfc995870430bb90d8ac97e91f66cb4 (Debug)

mysqld: /test/10.8_dbg/storage/innobase/dict/dict0stats.cc:1126: std::vector<index_field_stats_t> btr_estimate_number_of_different_key_vals(dict_index_t*, trx_id_t): Assertion `!index->is_spatial()' failed.

10.8.0 e222e44d1bfc995870430bb90d8ac97e91f66cb4 (Debug)

Core was generated by `/test/MD190122-mariadb-10.8.0-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
Program terminated with signal SIGABRT, Aborted.
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
[Current thread is 1 (Thread 0x145de8163700 (LWP 4174624))]
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x0000145dfcde7859 in __GI_abort () at abort.c:79
#2  0x0000145dfcde7729 in __assert_fail_base (fmt=0x145dfcf7d588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x563ee34a4c3d "!index->is_spatial()", file=0x563ee34fea88 "/test/10.8_dbg/storage/innobase/dict/dict0stats.cc", line=1126, function=<optimized out>) at assert.c:92
#3  0x0000145dfcdf8f36 in __GI___assert_fail (assertion=assertion@entry=0x563ee34a4c3d "!index->is_spatial()", file=file@entry=0x563ee34fea88 "/test/10.8_dbg/storage/innobase/dict/dict0stats.cc", line=line@entry=1126, function=function@entry=0x563ee3500078 "std::vector<index_field_stats_t> btr_estimate_number_of_different_key_vals(dict_index_t*, trx_id_t)") at assert.c:101
#4  0x0000563ee2f6472f in btr_estimate_number_of_different_key_vals (bulk_trx_id=0, index=0x145d500200f8) at /test/10.8_dbg/storage/innobase/include/dict0mem.h:1182
#5  dict_stats_update_transient_for_index (index=index@entry=0x145d500200f8) at /test/10.8_dbg/storage/innobase/dict/dict0stats.cc:1461
#6  0x0000563ee2f65e9f in dict_stats_update_for_index (index=index@entry=0x145d500200f8) at /test/10.8_dbg/storage/innobase/dict/dict0stats.cc:3801
#7  0x0000563ee2c5afa8 in alter_stats_norebuild (thd=<optimized out>, ctx=0x145d50015630, ha_alter_info=<optimized out>) at /test/10.8_dbg/storage/innobase/handler/handler0alter.cc:10647
#8  ha_innobase::commit_inplace_alter_table (this=0x145d50070910, altered_table=<optimized out>, ha_alter_info=<optimized out>, commit=<optimized out>) at /test/10.8_dbg/storage/innobase/handler/handler0alter.cc:11320
#9  0x0000563ee286ded5 in handler::ha_commit_inplace_alter_table (this=0x145d50070910, altered_table=altered_table@entry=0x145de815f0a0, ha_alter_info=ha_alter_info@entry=0x145de815efe0, commit=commit@entry=true) at /test/10.8_dbg/sql/handler.cc:5191
#10 0x0000563ee263fc2f in mysql_inplace_alter_table (thd=thd@entry=0x145d50000db8, table_list=0x145d50013ec8, table=table@entry=0x145d50070038, altered_table=altered_table@entry=0x145de815f0a0, ha_alter_info=ha_alter_info@entry=0x145de815efe0, target_mdl_request=target_mdl_request@entry=0x145de815f830, ddl_log_state=0x145de815ef30, trigger_param=0x145de815f440, alter_ctx=0x145de81606d0) at /test/10.8_dbg/sql/sql_table.cc:7561
#11 0x0000563ee2653473 in mysql_alter_table (thd=thd@entry=0x145d50000db8, new_db=new_db@entry=0x145d50005a58, new_name=new_name@entry=0x145d50005e70, create_info=create_info@entry=0x145de81614e0, table_list=<optimized out>, table_list@entry=0x145d50013ec8, alter_info=alter_info@entry=0x145de81613f0, order_num=<optimized out>, order=<optimized out>, ignore=<optimized out>, if_exists=<optimized out>) at /test/10.8_dbg/sql/sql_table.cc:10346
#12 0x0000563ee26e2bc7 in Sql_cmd_alter_table::execute (this=<optimized out>, thd=0x145d50000db8) at /test/10.8_dbg/sql/structs.h:568
#13 0x0000563ee25683fe in mysql_execute_command (thd=thd@entry=0x145d50000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.8_dbg/sql/sql_parse.cc:5988
#14 0x0000563ee254ef05 in mysql_parse (thd=thd@entry=0x145d50000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x145de8162400) at /test/10.8_dbg/sql/sql_parse.cc:8027
#15 0x0000563ee255dba1 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x145d50000db8, packet=packet@entry=0x145d5000b879 "ALTER TABLE t ADD SPATIAL INDEX i (c ASC)", packet_length=packet_length@entry=41, blocking=blocking@entry=true) at /test/10.8_dbg/sql/sql_class.h:1360
#16 0x0000563ee2560fe8 in do_command (thd=0x145d50000db8, blocking=blocking@entry=true) at /test/10.8_dbg/sql/sql_parse.cc:1402
#17 0x0000563ee26da9cc in do_handle_one_connection (connect=<optimized out>, connect@entry=0x563ee65cb958, put_in_cache=put_in_cache@entry=true) at /test/10.8_dbg/sql/sql_connect.cc:1418
#18 0x0000563ee26dafd1 in handle_one_connection (arg=arg@entry=0x563ee65cb958) at /test/10.8_dbg/sql/sql_connect.cc:1312
#19 0x0000563ee2b5c9a2 in pfs_spawn_thread (arg=0x563ee64dd858) at /test/10.8_dbg/storage/perfschema/pfs.cc:2201
#20 0x0000145dfd2f6609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#21 0x0000145dfcee4293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.2.42 (dbg), 10.3.33 (dbg), 10.4.23 (dbg), 10.5.14 (dbg), 10.6.6 (dbg), 10.7.2 (dbg), 10.8.0 (dbg)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.2.42 (opt), 10.3.33 (opt), 10.4.23 (opt), 10.5.14 (opt), 10.6.6 (opt), 10.7.2 (opt), 10.8.0 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.36 (dbg), 5.7.36 (opt), 8.0.27 (dbg), 8.0.27 (opt)

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

New stack on 10.9

CREATE TABLE t(c POINT NOT NULL) ENGINE=InnoDB;
DROP TABLE mysql.innodb_table_stats;
CREATE SPATIAL INDEX i ON t(c);

Leads to:

10.9.0 b5852ffbeebc3000982988383daeefb0549e058a (Debug)

mysqld: /test/10.9_dbg/storage/innobase/dict/dict0stats.cc:1126: std::vector<index_field_stats_t> btr_estimate_number_of_different_key_vals(dict_index_t*, trx_id_t): Assertion `index->is_btree()' failed.

10.9.0 b5852ffbeebc3000982988383daeefb0549e058a (Debug)

Core was generated by `/test/MD140222-mariadb-10.9.0-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
Program terminated with signal SIGABRT, Aborted.
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
[Current thread is 1 (Thread 0x1484980ac700 (LWP 2005095))]
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00001484a1910859 in __GI_abort () at abort.c:79
#2  0x00001484a1910729 in __assert_fail_base (fmt=0x1484a1aa6588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55f8d2970cf3 "index->is_btree()", file=0x55f8d29ca438 "/test/10.9_dbg/storage/innobase/dict/dict0stats.cc", line=1126, function=<optimized out>) at assert.c:92
#3  0x00001484a1921f36 in __GI___assert_fail (assertion=assertion@entry=0x55f8d2970cf3 "index->is_btree()", file=file@entry=0x55f8d29ca438 "/test/10.9_dbg/storage/innobase/dict/dict0stats.cc", line=line@entry=1126, function=function@entry=0x55f8d29cba28 "std::vector<index_field_stats_t> btr_estimate_number_of_different_key_vals(dict_index_t*, trx_id_t)") at assert.c:101
#4  0x000055f8d2425c24 in btr_estimate_number_of_different_key_vals (bulk_trx_id=0, index=0x14842401fe68) at /test/10.9_dbg/storage/innobase/include/dict0mem.h:1181
#5  dict_stats_update_transient_for_index (index=index@entry=0x14842401fe68) at /test/10.9_dbg/storage/innobase/dict/dict0stats.cc:1461
#6  0x000055f8d2427355 in dict_stats_update_for_index (index=index@entry=0x14842401fe68) at /test/10.9_dbg/storage/innobase/dict/dict0stats.cc:3798
#7  0x000055f8d211d9f4 in alter_stats_norebuild (thd=<optimized out>, ctx=0x148424015460, ha_alter_info=<optimized out>) at /test/10.9_dbg/storage/innobase/handler/handler0alter.cc:10674
#8  ha_innobase::commit_inplace_alter_table (this=0x148424070a20, altered_table=<optimized out>, ha_alter_info=<optimized out>, commit=<optimized out>) at /test/10.9_dbg/storage/innobase/handler/handler0alter.cc:11347
#9  0x000055f8d1d39819 in handler::ha_commit_inplace_alter_table (this=0x148424070a20, altered_table=altered_table@entry=0x1484980a8b60, ha_alter_info=ha_alter_info@entry=0x1484980a8aa0, commit=commit@entry=true) at /test/10.9_dbg/sql/handler.cc:5197
#10 0x000055f8d1b02ffc in mysql_inplace_alter_table (thd=thd@entry=0x148424000db8, table_list=0x148424013ec8, table=table@entry=0x148424070148, altered_table=altered_table@entry=0x1484980a8b60, ha_alter_info=ha_alter_info@entry=0x1484980a8aa0, target_mdl_request=target_mdl_request@entry=0x1484980a92f0, ddl_log_state=0x1484980a89f0, trigger_param=0x1484980a8f00, alter_ctx=0x1484980aa190, partial_alter=@0x1484980a895f: false, start_alter_id=@0x1484980a8968: 0, if_exists=false) at /test/10.9_dbg/sql/sql_table.cc:7735
#11 0x000055f8d1b16a4f in mysql_alter_table (thd=thd@entry=0x148424000db8, new_db=new_db@entry=0x148424013ee0, new_name=new_name@entry=0x148424013ef0, create_info=create_info@entry=0x1484980aafc0, table_list=<optimized out>, table_list@entry=0x148424013ec8, alter_info=alter_info@entry=0x1484980aaed0, order_num=<optimized out>, order=<optimized out>, ignore=<optimized out>, if_exists=<optimized out>) at /test/10.9_dbg/sql/sql_table.cc:10691
#12 0x000055f8d1a26b8f in mysql_execute_command (thd=thd@entry=0x148424000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.9_dbg/sql/structs.h:568
#13 0x000055f8d1a12315 in mysql_parse (thd=thd@entry=0x148424000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x1484980ab400) at /test/10.9_dbg/sql/sql_parse.cc:8027
#14 0x000055f8d1a20fb1 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x148424000db8, packet=packet@entry=0x14842400b889 "CREATE SPATIAL INDEX i ON t(c)", packet_length=packet_length@entry=30, blocking=blocking@entry=true) at /test/10.9_dbg/sql/sql_class.h:1362
#15 0x000055f8d1a243f8 in do_command (thd=0x148424000db8, blocking=blocking@entry=true) at /test/10.9_dbg/sql/sql_parse.cc:1402
#16 0x000055f8d1b9efc4 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55f8d5085d88, put_in_cache=put_in_cache@entry=true) at /test/10.9_dbg/sql/sql_connect.cc:1418
#17 0x000055f8d1b9f5c9 in handle_one_connection (arg=arg@entry=0x55f8d5085d88) at /test/10.9_dbg/sql/sql_connect.cc:1312
#18 0x000055f8d2025d67 in pfs_spawn_thread (arg=0x55f8d4fc8458) at /test/10.9_dbg/storage/perfschema/pfs.cc:2201
#19 0x00001484a1e1f609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#20 0x00001484a1a0d293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.2.42 (dbg), 10.3.33 (dbg), 10.4.23 (dbg), 10.5.14 (dbg), 10.6.6 (dbg), 10.7.2 (dbg), 10.8.1 (dbg), 10.9.0 (dbg)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.2.42 (opt), 10.3.33 (opt), 10.4.23 (opt), 10.5.14 (opt), 10.6.6 (opt), 10.7.2 (opt), 10.8.1 (opt), 10.9.0 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.36 (dbg), 5.7.36 (opt), 8.0.27 (dbg), 8.0.27 (opt)

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

UniqueID's seen thus far

!(index)->is_spatial()|SIGABRT|btr_estimate_number_of_different_key_vals|dict_stats_update_transient_for_index|dict_stats_update_for_index|alter_stats_norebuild
!dict_index_is_spatial(index)|SIGABRT|btr_estimate_number_of_different_key_vals|dict_stats_update_transient_for_index|dict_stats_update_for_index|alter_stats_norebuild
!index->is_spatial()|SIGABRT|btr_estimate_number_of_different_key_vals|dict_stats_update_transient_for_index|dict_stats_update_for_index|alter_stats_norebuild
index->is_btree()|SIGABRT|btr_estimate_number_of_different_key_vals|dict_stats_update_transient_for_index|dict_stats_update_for_index|alter_stats_norebuild

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

Please also test any fixes with

CREATE TABLE tab (c INT,c2 POINT,c3 LINESTRING,c4 POLYGON NOT NULL,c5 GEOMETRY NOT NULL) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=16;                                                                                                               
RENAME TABLE mysql.innodb_index_stats TO mysql.innodb_index_stats_;                                                     
CREATE SPATIAL INDEX i3 ON tab (c4 ASC) KEY_BLOCK_SIZE=2; 

Comment by Marko Mäkelä [ 2022-02-21 ]

A few observations that may or may not be useful:

  • All spatial data types are derived from Field_blob
  • It is possible to create B-tree indexes on geometry columns, but in the Description that is not the case.
  • Example: a POINT PRIMARY KEY is internally converted to PRIMARY KEY(a(25)), corresponding to the length of the well-formed binary representation.
  • I don’t think that any SPATIAL INDEX should have any index cardinality statistics.
  • This seems unrelated to other SPATIAL INDEX bugs that highlight bigger design issues, such as MDEV-15284.
Comment by Alice Sherepa [ 2022-12-19 ]

innodb_gis.create_spatial_index test fails on 10.6-10.11:

./mtr --mysqld=--default-storage-engine=innodb --mysqld=--innodb  innodb_gis.create_spatial_index

10.6 0a67daad060459c27a1fb77

CURRENT_TEST: innodb_gis.create_spatial_index
mysqltest: At line 1172: query 'CREATE SPATIAL INDEX idx2 ON t1(c1)' failed: <Unknown> (2013): Lost connection to server during query
 
The result from queries just before the failure was:
< snip >
);
insert into `t1` values
(
polygon(
linestring(point(1,1),point(1,1)),
linestring(point(1,1),point(11,1))
),
linestring(point(1,1),point(1,1))
);
ERROR 23000: Column 'a' cannot be null
select 1 from t1 where st_intersects(
geometrycollection(point(1,-1)),b
);
1
drop table t1;
CREATE TABLE t1(c1 POINT NOT NULL);
DROP TABLE mysql.innodb_table_stats;
CALL mtr.add_suppression("InnoDB: Table `mysql`.`innodb_table_stats` not found.");
CALL mtr.add_suppression("InnoDB: Fetch of persistent statistics requested for table `test`.`t1` but the required system tables mysql.innodb_table_stats and mysql.innodb_index_stats are not present or have unexpected structure. Using transient stats instead.");
CREATE SPATIAL INDEX idx2 ON t1(c1);
 
 
2022-12-19 14:12:20 4 [Note] InnoDB: Recalculation of persistent statistics requested for table `test`.`t1` index `idx2` but the required persistent statistics storage is not present or is corrupted. Using transient stats instead.
mariadbd: /10.6/src/storage/innobase/dict/dict0stats.cc:1183: std::vector<index_field_stats_t> btr_estimate_number_of_different_key_vals(dict_index_t*, trx_id_t): Assertion `!index->is_spatial()' failed.
221219 14:12:20 [ERROR] mysqld got signal 6 ;
 
Server version: 10.6.12-MariaDB-debug-log
 
??:0(abort)[0x7f1ce2db8859]
/lib/x86_64-linux-gnu/libc.so.6(+0x22729)[0x7f1ce2db8729]
??:0(__assert_fail)[0x7f1ce2dc9fd6]
dict/dict0stats.cc:1185(btr_estimate_number_of_different_key_vals(dict_index_t*, unsigned long))[0x562825aa9b5a]
dict/dict0stats.cc:1517(dict_stats_update_transient_for_index(dict_index_t*))[0x562825aab3ea]
dict/dict0stats.cc:4003(dict_stats_update_for_index(dict_index_t*))[0x562825ab890e]
handler/handler0alter.cc:10842(alter_stats_norebuild(Alter_inplace_info*, ha_innobase_inplace_ctx*, THD*))[0x56282548f6af]
handler/handler0alter.cc:11580(ha_innobase::commit_inplace_alter_table(TABLE*, Alter_inplace_info*, bool))[0x562825496b7e]
sql/handler.cc:5237(handler::ha_commit_inplace_alter_table(TABLE*, Alter_inplace_info*, bool))[0x562824996e3a]
sql/sql_table.cc:7486(mysql_inplace_alter_table(THD*, TABLE_LIST*, TABLE*, TABLE*, Alter_inplace_info*, MDL_request*, st_ddl_log_state*, TRIGGER_RENAME_PARAM*, Alter_table_ctx*))[0x562824398845]
sql/sql_table.cc:10354(mysql_alter_table(THD*, st_mysql_const_lex_string const*, st_mysql_const_lex_string const*, HA_CREATE_INFO*, TABLE_LIST*, Alter_info*, unsigned int, st_order*, bool, bool))[0x5628243ae3b8]
sql/sql_parse.cc:4213(mysql_execute_command(THD*, bool))[0x5628240f7b5d]
sql/sql_parse.cc:8018(mysql_parse(THD*, char*, unsigned int, Parser_state*))[0x562824112acb]
sql/sql_parse.cc:1898(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool))[0x5628240e8c3c]
sql/sql_parse.cc:1409(do_command(THD*, bool))[0x5628240e5993]
sql/sql_connect.cc:1416(do_handle_one_connection(CONNECT*, bool))[0x562824554bbd]
sql/sql_connect.cc:1320(handle_one_connection)[0x56282455451a]
perfschema/pfs.cc:2203(pfs_spawn_thread)[0x5628251d16ce]
nptl/pthread_create.c:478(start_thread)[0x7f1ce32e4609]
??:0(clone)[0x7f1ce2eb5133]
 
Query (0x62b0000c42a8): CREATE SPATIAL INDEX idx2 ON t1(c1)

Comment by Roel Van de Paar [ 2023-12-08 ]

Please also test any fixes with:

CREATE TABLE t (c INT KEY,c2 POINT NOT NULL,c3 LINESTRING NOT NULL,c4 POLYGON NOT NULL,c5 GEOMETRY NOT NULL);
SET GLOBAL innodb_stats_persistent=ON;
ALTER TABLE mysql.innodb_index_stats RENAME TO mysql.innodb_index_stats_;
ALTER TABLE t ADD SPATIAL INDEX idx2 (c2);

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