[MDEV-17227] Server crash in TABLE_SHARE::init_from_sql_statement_string upon table discovery with non-existent database Created: 2018-09-18  Updated: 2021-01-12  Resolved: 2021-01-12

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Create Table, Server, Storage Engine - Connect, Storage Engine - Federated
Affects Version/s: 10.3, 10.4
Fix Version/s: 10.3.28, 10.4.18, 10.5.9

Type: Bug Priority: Major
Reporter: Juan Telleria Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: None
Environment:

Windows


Attachments: Text File Error Log.txt     File my.ini    
Issue Links:
Relates
relates to MDEV-22435 Assisted discovery of table with appl... Confirmed

 Description   

If you create a ENGINE=Connect Table_Type=ODBC Table, and try to save it to a Non-Existant Database, the Server Crashes.

For example, the following query causes the Server to Crash, whenever the Database ("db_name_non_existant") in which the created Connect ODBC Table to be saved does not exists:

CREATE OR REPLACE TABLE db_name_non_existant.tb_name_new
     ENGINE=CONNECT
     TABLE_TYPE=ODBC 
     CONNECTION='dsn_name'
     OPTION_LIST='UseDSN=Yes,User=user_name,Password=*******************'
     TABNAME='db_name.schema_name.tb_name';      

The Error Log Backtrace is the following:

180918 15:30:56 [ERROR] mysqld got exception 0xc0000005 ;
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.3.9-MariaDB
key_buffer_size=65536
read_buffer_size=262144
max_used_connections=12
max_threads=65537
thread_count=4
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 1560 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.
 
Thread pointer: 0x4f324d018
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...
mysqld.exe!TABLE_SHARE::init_from_sql_statement_string()[table.cc:2810]
ha_connect.dll!?Val@FILTER@@QEAAAEAPEAVVALUE@@H@Z()
ha_connect.dll!?Val@FILTER@@QEAAAEAPEAVVALUE@@H@Z()
mysqld.exe!create_table_impl()[sql_table.cc:4942]
mysqld.exe!mysql_create_table_no_lock()[sql_table.cc:5096]
mysqld.exe!mysql_create_table()[sql_table.cc:5188]
mysqld.exe!mysql_execute_command()[sql_parse.cc:4282]
mysqld.exe!mysql_parse()[sql_parse.cc:8093]
mysqld.exe!dispatch_command()[sql_parse.cc:1852]
mysqld.exe!do_command()[sql_parse.cc:1394]
mysqld.exe!threadpool_process_request()[threadpool_common.cc:358]
mysqld.exe!tp_callback()[threadpool_common.cc:186]
ntdll.dll!RtlDllShutdownInProgress()
ntdll.dll!DbgUiRemoteBreakin()
kernel32.dll!BaseThreadInitThunk()
ntdll.dll!RtlUserThreadStart()
 
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0x3915a46a0): CREATE OR REPLACE TABLE MasterDataTurbine.vCountry_CONNECT        ENGINE = CONNECT        TABLE_TYPE = ODBC        CONNECTION = 'SQLServerParallelDataWarehouse'        OPTION_LIST='UseDSN=Yes,User=TableauAPS_Prod,Password=*********************'        TABNAME = "MasterDataTurbine.General.vCountry"
Connection ID (thread ID): 490
Status: NOT_KILLED
 
Optimizer switch: index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on
 
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.



 Comments   
Comment by Olivier Bertrand [ 2018-09-18 ]

Are you sure there are no other errors in your create statement? I tried:

CREATE OR REPLACE TABLE db_name_non_existant.tb_name_new
     ENGINE=CONNECT
     TABLE_TYPE=ODBC 
     CONNECTION='PostgreSQL30'
     OPTION_LIST='UseDSN=Yes'
     TABNAME='td';

The discovery process was ok for CONNECT (the created table name is not used) but the final call to init_from_sql_statement_string returned HA_ERR_GENERIC and I got the normal error message saying that discovery failed.

The Error log.txt file shows that the crash occured in TABLE_SHARE::init_from_sql_statement_string() in table.cc line 2810 but not for me. Which version of MariaDB are you using? Anyhow it seems that the crash is not caused by CONNECT.

Comment by Juan Telleria [ 2018-09-19 ]

The database is the one that must not exist when creating the CONNECT Table:

MariaDB 10.3.9 + RocksDB Engine Configured. I attach my.ini

Comment by Juan Telleria [ 2018-09-19 ]

@Olivier Bertrand By the way: I created a new Issue MDEV-17240, to propose that, if you consider it appropriate , the ha_connect Code (Non-Compiled) is maintained on the MariaDB Foundation Github GIT Version Control, in order that we could contribute in the code development ourselves (by proposing patches and Pull Requests), and not only asking for support.

Thank you!

Comment by Elena Stepanova [ 2019-09-19 ]

Not limited to CONNECT, same happens with FederatedX:

create database db1;
create table db1.t (a int);
install soname 'ha_federatedx';
eval create table non_existing_db.tf engine=federated connection='mysql://root@127.0.0.1:$MASTER_MYPORT/db1/t';

10.3 90a9c4ca

#3  <signal handler called>
#4  0x000055887c0a96f2 in TABLE_SHARE::init_from_sql_statement_string (this=0x7fe6a2b97fc0, thd=0x7fe690000b00, write=true, sql=0x7fe6a2b96820 "CREATE TABLE `t` (\n  `a` int(11) DEFAULT NULL\n) CONNECTION='mysql://root@127.0.0.1:16020/db1/t'", sql_length=95) at /data/src/10.3/sql/table.cc:2837
#5  0x00007fe6a2940eed in ha_federatedx::discover_assisted (hton=0x7fe69009b200, thd=0x7fe690000b00, table_s=0x7fe6a2b97fc0, info=0x7fe6a2b98b30) at /data/src/10.3/storage/federatedx/ha_federatedx.cc:3660
#6  0x000055887c066d18 in create_table_impl (thd=0x7fe690000b00, orig_db=0x7fe6900129c8, orig_table_name=0x7fe6900129d8, db=0x7fe6900129c8, table_name=0x7fe6900129d8, path=0x7fe6a2b986f0 "./non_existing_db/tf", options=..., create_info=0x7fe6a2b98b30, alter_info=0x7fe6a2b98a70, create_table_mode=-3, is_trans=0x7fe6a2b9894e, key_info=0x7fe6a2b986d0, key_count=0x7fe6a2b986c4, frm=0x7fe6a2b986e0) at /data/src/10.3/sql/sql_table.cc:4939
#7  0x000055887c067474 in mysql_create_table_no_lock (thd=0x7fe690000b00, db=0x7fe6900129c8, table_name=0x7fe6900129d8, create_info=0x7fe6a2b98b30, alter_info=0x7fe6a2b98a70, is_trans=0x7fe6a2b9894e, create_table_mode=-3, table_list=0x7fe6900129b0) at /data/src/10.3/sql/sql_table.cc:5092
#8  0x000055887c067878 in mysql_create_table (thd=0x7fe690000b00, create_table=0x7fe6900129b0, create_info=0x7fe6a2b98b30, alter_info=0x7fe6a2b98a70) at /data/src/10.3/sql/sql_table.cc:5181
#9  0x000055887c079082 in Sql_cmd_create_table_like::execute (this=0x7fe690012990, thd=0x7fe690000b00) at /data/src/10.3/sql/sql_table.cc:11191
#10 0x000055887bf95598 in mysql_execute_command (thd=0x7fe690000b00) at /data/src/10.3/sql/sql_parse.cc:6024
#11 0x000055887bf9ad0b in mysql_parse (thd=0x7fe690000b00, rawbuf=0x7fe690012818 "create table non_existing_db.tf engine=federated connection='mysql://root@127.0.0.1:16020/db1/t'", length=96, parser_state=0x7fe6a2b995e0, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:7830
#12 0x000055887bf87945 in dispatch_command (command=COM_QUERY, thd=0x7fe690000b00, packet=0x7fe69011de01 "create table non_existing_db.tf engine=federated connection='mysql://root@127.0.0.1:16020/db1/t'", packet_length=96, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:1856
#13 0x000055887bf8628d in do_command (thd=0x7fe690000b00) at /data/src/10.3/sql/sql_parse.cc:1401
#14 0x000055887c0fc75a in do_handle_one_connection (connect=0x55887e72aff0) at /data/src/10.3/sql/sql_connect.cc:1403
#15 0x000055887c0fc4bc in handle_one_connection (arg=0x55887e72aff0) at /data/src/10.3/sql/sql_connect.cc:1308
#16 0x000055887caa77c2 in pfs_spawn_thread (arg=0x55887e746070) at /data/src/10.3/storage/perfschema/pfs.cc:1862
#17 0x00007fe6aa50f4a4 in start_thread (arg=0x7fe6a2b9a700) at pthread_create.c:456
#18 0x00007fe6a8a57d0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97

Reproducible on 10.3+, debug-and non-debug alike.

10.2 returns an error instead:

mysqltest: At line 4: query 'create table non_existing_db.tf engine=federated connection='mysql://root@127.0.0.1:$MASTER_MYPORT/db1/t'' failed: 1939: Engine FEDERATED failed to discover table `non_existing_db`.`tf` with 'CREATE TABLE `t` (
  `a` int(11) DEFAULT NULL
) CONNECTION='mysql://root@127.0.0.1:16020/db1/t''

Comment by Elena Stepanova [ 2020-05-02 ]

MDEV-22435 was linked to this issue as possibly having the same root cause.

Generated at Thu Feb 08 08:34:52 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.