[MDEV-31896] Connect tables ignore PK, fail upon select or statistics collection Created: 2023-08-10  Updated: 2023-11-28

Status: Open
Project: MariaDB Server
Component/s: Storage Engine - Connect
Affects Version/s: 10.4, 10.5, 10.6, 10.9, 10.10, 10.11, 11.0, 11.1
Fix Version/s: 10.4, 10.5, 10.6, 10.11, 11.0, 11.1

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Andrew Hutchings
Resolution: Unresolved Votes: 0
Labels: None


 Description   

First variation: INSERT succeeds, SELECT fails

install soname 'ha_connect';
 
create table t (a int, primary key(a)) ENGINE=Connect table_type=bin;
insert into t values (1),(1);
select * from t;
 
drop table t;
uninstall soname 'ha_connect';

10.4 b54e4bf0

insert into t values (1),(1);
Warnings:
Warning	1105	Index is not unique
select * from t;
bug.connect1                             [ fail ]
        Test ended at 2023-08-10 20:34:26
 
CURRENT_TEST: bug.connect1
mysqltest: At line 5: query 'select * from t' failed: 1296: Got error 122 'Open error 2 in mode rb on /dev/shm/var/mysqld.1/data/./test/t.bnx: No such file or directory' from CONNECT

Second variation: INSERT and SELECT succeed

install soname 'ha_connect';
 
create table t (a int, primary key(a), b int) ENGINE=Connect table_type=bin;
insert into t values (1,10),(1,20);
select * from t;
 
drop table t;
uninstall soname 'ha_connect';

insert into t values (1,10),(1,20);
Warnings:
Warning	1105	Index is not unique
select * from t;
a	b
1	10
1	20

Third variation: INSERT succeeds, ANALYZE fails on assertion

install soname 'ha_connect';
 
create table t (a int, primary key(a), b int not null, key(b)) ENGINE=Connect table_type=bin;
insert into t values (1,10),(1,20);
analyze table t persistent for all;
 
drop table t;
uninstall soname 'ha_connect';

insert into t values (1,10),(1,20);
Warnings:
Warning	1105	Index is not unique
analyze table t persistent for all;
bug.connect1                             [ fail ]
        Test ended at 2023-08-10 20:36:00
 
CURRENT_TEST: bug.connect1
mysqltest: At line 5: query 'analyze table t persistent for all' failed: 2013: Lost connection to MySQL server during query

index_init CONNECT: Open error 2 in mode rb on /dev/shm/var_auto_i9Lv/mysqld.1/data/./test/t.bnx: No such file or directory
mysqld: /data/src/10.4/sql/handler.cc:3051: int handler::ha_index_first(uchar*): Assertion `inited==INDEX' failed.
230810 20:35:59 [ERROR] mysqld got signal 6 ;
 
#9  0x00007ffa23a53df2 in __GI___assert_fail (assertion=0x55a2daa04100 "inited==INDEX", file=0x55a2daa08380 "/data/src/10.4/sql/handler.cc", line=3051, function=0x55a2daa0c1c0 "int handler::ha_index_first(uchar*)") at ./assert/assert.c:101
#10 0x000055a2d8dca2fd in handler::ha_index_first (this=0x61d0002012a8, buf=0x6190000866b8 "") at /data/src/10.4/sql/handler.cc:3051
#11 0x000055a2d882bb3a in collect_statistics_for_index (thd=0x62b00005b208, table=0x62000003c088, index=1) at /data/src/10.4/sql/sql_statistics.cc:2554
#12 0x000055a2d882ce0c in collect_statistics_for_table (thd=0x62b00005b208, table=0x62000003c088) at /data/src/10.4/sql/sql_statistics.cc:2738
#13 0x000055a2d8a36868 in mysql_admin_table (thd=0x62b00005b208, tables=0x62b000062330, check_opt=0x62b000060478, operator_name=0x55a2da7c7f00 "analyze", lock_type=TL_READ_NO_INSERT, org_open_for_modify=true, repair_table_use_frm=false, extra_open_options=0, prepare_func=0x0, operator_func=(int (handler::*)(handler * const, THD *, HA_CHECK_OPT *)) 0x55a2d8dd4f24 <handler::ha_analyze(THD*, st_ha_check_opt*)>, view_operator_func=0x0, is_cmd_replicated=true) at /data/src/10.4/sql/sql_admin.cc:926
#14 0x000055a2d8a3b08c in Sql_cmd_analyze_table::execute (this=0x62b000062a38, thd=0x62b00005b208) at /data/src/10.4/sql/sql_admin.cc:1390
#15 0x000055a2d8624e35 in mysql_execute_command (thd=0x62b00005b208) at /data/src/10.4/sql/sql_parse.cc:6216
#16 0x000055a2d86306af in mysql_parse (thd=0x62b00005b208, rawbuf=0x62b000062228 "analyze table t persistent for all", length=34, parser_state=0x7ffa1bd5b860, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:8010
#17 0x000055a2d860697a in dispatch_command (command=COM_QUERY, thd=0x62b00005b208, packet=0x629000230209 "", packet_length=34, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:1857
#18 0x000055a2d86034e9 in do_command (thd=0x62b00005b208) at /data/src/10.4/sql/sql_parse.cc:1378
#19 0x000055a2d8a02a48 in do_handle_one_connection (connect=0x6080000009a8) at /data/src/10.4/sql/sql_connect.cc:1420
#20 0x000055a2d8a0235f in handle_one_connection (arg=0x6080000009a8) at /data/src/10.4/sql/sql_connect.cc:1324
#21 0x000055a2d9671dd4 in pfs_spawn_thread (arg=0x615000003508) at /data/src/10.4/storage/perfschema/pfs.cc:1869
#22 0x00007ffa23aa7fd4 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#23 0x00007ffa23b285bc in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81


Generated at Thu Feb 08 10:27:17 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.