|
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.
|
|
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)
|
|
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)
|
|
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
|
|
|
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;
|
|
|
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.
|
|
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)
|
|
|
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);
|
|