[MDEV-29532] Connect engine crash with MySQL 8 Created: 2022-09-14  Updated: 2023-04-27

Status: Open
Project: MariaDB Server
Component/s: Storage Engine - Connect
Affects Version/s: 10.6.9, 10.7.5
Fix Version/s: 10.6

Type: Bug Priority: Major
Reporter: MG Assignee: Anel Husakovic
Resolution: Unresolved Votes: 0
Labels: connect-engine
Environment:

pkg_name: MariaDB-server
pkg_release: 1.el7.centos
pkg_vendor: MariaDB Foundation
pkg_version: 10.7.5


Issue Links:
Relates
relates to MDEV-29533 Crash when MariaDB is replica of MySQ... Confirmed

 Description   

If a MySQL 8 server allows a remote connection, attempts to use CONNECT engine causes a crash:

MariaDB [(none)]> CREATE OR REPLACE TABLE test.t1 ENGINE = CONNECT TABLE_TYPE = MYSQL CONNECTION= 'mysql://foo:bar@mysql8:3306/foo/bar';
ERROR 1105 (HY000): (1130) Host '192.168.100.100' is not allowed to connect to this MySQL server
 
mysql> create user 'random'@'%' identified by 'SDfkhskj53!';
Query OK, 0 rows affected (0.00 sec)
 
mysql> drop database if exists foo;
Query OK, 0 rows affected, 1 warning (0.00 sec)
 
MariaDB [(none)]> CREATE OR REPLACE TABLE test.t1 ENGINE = CONNECT TABLE_TYPE = MYSQL CONNECTION= 'mysql://foo:bar@mysql8:3306/foo/bar';
ERROR 2013 (HY000): Lost connection to server during query

220914  4:38:43 [ERROR] mysqld got signal 11 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
 
To report this bug, see https://mariadb.com/kb/en/reporting-bugs
 
We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed,
something is definitely wrong and this may fail.
 
Server version: 10.7.5-MariaDB-log
key_buffer_size=134217728
read_buffer_size=131072
max_used_connections=1
max_threads=153
thread_count=1
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 467995 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.
 
Thread pointer: 0x7fcb180009b8
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0x7fcb24beecc0 thread_stack 0x49000
/usr/sbin/mariadbd(my_print_stacktrace+0x2e)[0x5625a1bd347e]
/usr/sbin/mariadbd(handle_fatal_signal+0x307)[0x5625a1641df7]
sigaction.c:0(__restore_rt)[0x7fcb4fe7f630]
/usr/sbin/mariadbd(+0x9ea8f7)[0x5625a16148f7]
/usr/sbin/mariadbd(mysql_close+0x22)[0x5625a1617eb2]
connect/myconn.cpp:541(MYSQLC::Open(_global*, char const*, char const*, char const*, char const*, int, char const*))[0x7fcb4c20e3e9]
connect/myconn.cpp:156(MyColumns(_global*, THD*, char const*, char const*, char const*, char const*, char const*, char const*, int, bool))[0x7fcb4c20fc98]
connect/ha_connect.cc:6087(CheckSelf(_global*, TABLE_SHARE*, char const*, char const*, char const*, char const*, int))[0x7fcb4c1d556d]
/usr/sbin/mariadbd(_Z17create_table_implP3THDP16st_ddl_log_stateS2_RK25st_mysql_const_lex_stringS5_S5_S5_S5_14DDL_options_stP14HA_CREATE_INFOP10Alter_infoiPbPP6st_keyPjP34st_mysql_const_unsigned_lex_string+0x658)[0x5625a14b2628]
/usr/sbin/mariadbd(_Z26mysql_create_table_no_lockP3THDP16st_ddl_log_stateS2_PK25st_mysql_const_lex_stringS5_P22Table_specification_stP10Alter_infoPbiP10TABLE_LIST+0x15f)[0x5625a14b2c8f]
/usr/sbin/mariadbd(_Z18mysql_create_tableP3THDP10TABLE_LISTP22Table_specification_stP10Alter_info+0x1d6)[0x5625a14b2fa6]
/usr/sbin/mariadbd(_ZN25Sql_cmd_create_table_like7executeEP3THD+0x7e4)[0x5625a14b48a4]
/usr/sbin/mariadbd(_Z21mysql_execute_commandP3THDb+0x1ecc)[0x5625a140e7cc]
/usr/sbin/mariadbd(_Z11mysql_parseP3THDPcjP12Parser_state+0x20b)[0x5625a141215b]
/usr/sbin/mariadbd(_Z16dispatch_command19enum_server_commandP3THDPcjb+0x1217)[0x5625a1414317]
/usr/sbin/mariadbd(_Z10do_commandP3THDb+0x123)[0x5625a14159b3]
sql/sql_table.cc:4531(create_table_impl(THD*, st_ddl_log_state*, st_ddl_log_state*, st_mysql_const_lex_string const&, st_mysql_const_lex_string const&, st_mysql_const_lex_string const&, st_mysql_const_lex_string const&, st_mysql_const_lex_string const&, DDL_options_st, HA_CREATE_INFO*, Alter_info*, int, bool*, st_key**, unsigned int*, st_mysql_const_unsigned_lex_string*))[0x5625a1519477]
sql/sql_table.cc:4677(mysql_create_table_no_lock(THD*, st_ddl_log_state*, st_ddl_log_state*, st_mysql_const_lex_string const*, st_mysql_const_lex_string const*, Table_specification_st*, Alter_info*, bool*, int, TABLE_LIST*))[0x5625a1519714]
sql/sql_table.cc:4784(mysql_create_table(THD*, TABLE_LIST*, Table_specification_st*, Alter_info*))[0x5625a18658ac]
nptl/pthread_create.c:307(start_thread)[0x7fcb4fe77ea5]
x86_64/clone.S:113(__clone)[0x7fcb4f392b0d]
 
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0x7fcb180106a0): CREATE OR REPLACE TABLE test.t1 ENGINE = CONNECT TABLE_TYPE = MYSQL CONNECTION= 'mysql://foo:bar@mysql8:3306/foo/bar'

{   "frames":
              [ {   "address": 94176680802551
                ,   "build_id": "ad4952ebe4515fa6114eeabfca86f0ea821f1fbd"
                ,   "build_id_offset": 10397943
                ,   "function_name": "mysql_close_free_options"
                ,   "file_name": "/usr/sbin/mariadbd"
                }
              , {   "address": 94176680816306
                ,   "build_id": "ad4952ebe4515fa6114eeabfca86f0ea821f1fbd"
                ,   "build_id_offset": 10411698
                ,   "function_name": "mysql_close"
                ,   "file_name": "/usr/sbin/mariadbd"
                }
              , {   "address": 140345776632809
                ,   "build_id": "02e7e47d60e44fbc104573c33d439bfea32bad86"
                ,   "build_id_offset": 926697
                ,   "function_name": "MYSQLC::Open(_global*, char const*, char const*, char const*, char const*, int, char const*)"
                ,   "file_name": "/usr/lib64/mysql/plugin/ha_connect.so"
                }
              , {   "address": 140345776639128
                ,   "build_id": "02e7e47d60e44fbc104573c33d439bfea32bad86"
                ,   "build_id_offset": 933016
                ,   "function_name": "MyColumns(_global*, THD*, char const*, char const*, char const*, char const*, char const*, char const*, int, bool)"
                ,   "file_name": "/usr/lib64/mysql/plugin/ha_connect.so"
                }
              , {   "address": 140345776399725
                ,   "build_id": "02e7e47d60e44fbc104573c33d439bfea32bad86"
                ,   "build_id_offset": 693613
                ,   "function_name": "connect_assisted_discovery(handlerton*, THD*, TABLE_SHARE*, HA_CREATE_INFO*)"
                ,   "file_name": "/usr/lib64/mysql/plugin/ha_connect.so"
                }
              , {   "address": 94176679351848
                ,   "build_id": "ad4952ebe4515fa6114eeabfca86f0ea821f1fbd"
                ,   "build_id_offset": 8947240
                ,   "function_name": "create_table_impl(THD*, st_ddl_log_state*, st_ddl_log_state*, st_mysql_const_lex_string const&, st_mysql_const_lex_string const&, st_mysql_const_lex_string const&, st_mysql_const_lex_string const&, st_mysql_const_lex_string const&, DDL_options_st, HA_CREATE_INFO*, Alter_info*, int, bool*, st_key**, unsigned int*, st_mysql_const_unsigned_lex_string*)"
                ,   "file_name": "/usr/sbin/mariadbd"
                }
              , {   "address": 94176679353487
                ,   "build_id": "ad4952ebe4515fa6114eeabfca86f0ea821f1fbd"
                ,   "build_id_offset": 8948879
                ,   "function_name": "mysql_create_table_no_lock(THD*, st_ddl_log_state*, st_ddl_log_state*, st_mysql_const_lex_string const*, st_mysql_const_lex_string const*, Table_specification_st*, Alter_info*, bool*, int, TABLE_LIST*)"
                ,   "file_name": "/usr/sbin/mariadbd"
                }
              , {   "address": 94176679354278
                ,   "build_id": "ad4952ebe4515fa6114eeabfca86f0ea821f1fbd"
                ,   "build_id_offset": 8949670
                ,   "function_name": "mysql_create_table(THD*, TABLE_LIST*, Table_specification_st*, Alter_info*)"
                ,   "file_name": "/usr/sbin/mariadbd"
                }
              , {   "address": 94176679360676
                ,   "build_id": "ad4952ebe4515fa6114eeabfca86f0ea821f1fbd"
                ,   "build_id_offset": 8956068
                ,   "function_name": "Sql_cmd_create_table_like::execute(THD*)"
                ,   "file_name": "/usr/sbin/mariadbd"
                }
              , {   "address": 94176678680524
                ,   "build_id": "ad4952ebe4515fa6114eeabfca86f0ea821f1fbd"
                ,   "build_id_offset": 8275916
                ,   "function_name": "mysql_execute_command(THD*, bool)"
                ,   "file_name": "/usr/sbin/mariadbd"
                }
              , {   "address": 94176678695259
                ,   "build_id": "ad4952ebe4515fa6114eeabfca86f0ea821f1fbd"
                ,   "build_id_offset": 8290651
                ,   "function_name": "mysql_parse(THD*, char*, unsigned int, Parser_state*)"
                ,   "file_name": "/usr/sbin/mariadbd"
                }
              , {   "address": 94176678703895
                ,   "build_id": "ad4952ebe4515fa6114eeabfca86f0ea821f1fbd"
                ,   "build_id_offset": 8299287
                ,   "function_name": "dispatch_command(enum_server_command, THD*, char*, unsigned int, bool)"
                ,   "file_name": "/usr/sbin/mariadbd"
                }
              , {   "address": 94176678709683
                ,   "build_id": "ad4952ebe4515fa6114eeabfca86f0ea821f1fbd"
                ,   "build_id_offset": 8305075
                ,   "function_name": "do_command(THD*, bool)"
                ,   "file_name": "/usr/sbin/mariadbd"
                }
              , {   "address": 94176679773303
                ,   "build_id": "ad4952ebe4515fa6114eeabfca86f0ea821f1fbd"
                ,   "build_id_offset": 9368695
                ,   "function_name": "do_handle_one_connection(CONNECT*, bool)"
                ,   "file_name": "/usr/sbin/mariadbd"
                }
              , {   "address": 94176679773972
                ,   "build_id": "ad4952ebe4515fa6114eeabfca86f0ea821f1fbd"
                ,   "build_id_offset": 9369364
                ,   "function_name": "handle_one_connection"
                ,   "file_name": "/usr/sbin/mariadbd"
                }
              , {   "address": 94176683231404
                ,   "build_id": "ad4952ebe4515fa6114eeabfca86f0ea821f1fbd"
                ,   "build_id_offset": 12826796
                ,   "function_name": "pfs_spawn_thread"
                ,   "file_name": "/usr/sbin/mariadbd"
                }
              , {   "address": 140345864466085
                ,   "build_id": "e10cc8f2b932fc3daeda22f8dac5ebb969524e5b"
                ,   "build_id_offset": 32421
                ,   "function_name": "start_thread"
                ,   "file_name": "/lib64/libpthread.so.0"
                }
              , {   "address": 140345853041421
                ,   "build_id": "9470e279388f7f9cb2ed3b2872d0c2095b191ff4"
                ,   "build_id_offset": 1043213
                ,   "function_name": "__clone"
                ,   "file_name": "/lib64/libc.so.6"
                } ]



 Comments   
Comment by Anel Husakovic [ 2022-09-14 ]

Not sure what triggers this?
I tried to create the test case to reproduce (thinking that it may happen because of dropping the database)

let $PORT= `select @@port`;
CREATE DATABASE db_test;
use db_test;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (10),(20),(30);
 
--replace_result $PORT PORT
--eval CREATE OR REPLACE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL CONNECTION='mysql://root@localhost:$PORT/db_test/t1'
 
DROP DATABASE db_test;
--replace_result $PORT PORT
--error 1046
--eval CREATE OR REPLACE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL CONNECTION='mysql://root@localhost:$PORT/db_test/t1'

but this works

CREATE DATABASE db_test;
use db_test;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (10),(20),(30);
CREATE OR REPLACE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL CONNECTION='mysql://root@localhost:PORT/db_test/t1';
DROP DATABASE db_test;
CREATE OR REPLACE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL CONNECTION='mysql://root@localhost:PORT/db_test/t1';
ERROR 3D000: No database selected
connect.anel                             [ pass ]     53

Comment by MG [ 2022-09-14 ]

I think test case might have better success if you specify the db name in REPLACE TABLE db_test.t2 and also ensure that the CONNECTION lands on a MySQL 8 server (perhaps this is already true but I can't tell given it is root@localhost and PORT doesn't have a $ character.

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