[MDEV-20201] Connecting to remote MySQL via ODBC crashes server Created: 2019-07-29  Updated: 2019-09-02  Resolved: 2019-09-02

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - Connect
Affects Version/s: 10.3.15, 10.4.6
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Hans Assignee: Olivier Bertrand
Resolution: Cannot Reproduce Votes: 0
Labels: None
Environment:

Linux 4.19.0-5-amd64 #1 SMP Debian 4.19.37-5+deb10u1 (2019-07-19) x86_64 GNU/Linux
unixODBC 2.3.6-0.1
MySQL ODBC Connector 5.3.13
MySQL ODBC Connector 8.0.17


Issue Links:
Relates
relates to MDEV-20145 CONNECT engine - ERROR 2013 (HY000): ... Closed

 Description   

Today, I've setup a fresh Debian 10.0 headless server with MariaDB 10.3.15 and wanted to connect to a remote Percona MySQL 5.7.25. As ENGINE=CONNECT TABLE_TYPE=MySQL does not allow SSL secured connections, I have to use ODBC.
The setup is:

# /etc/odbcinst.ini
[MySQL ODBC 8.0 Driver]
Driver=/usr/local/lib/libmyodbc8w.so
UsageCount=1

# /etc/odbc.ini
[fashion]
Driver=MySQL ODBC 8.0 Driver
SERVER=192.168.56.2
USER=test
PASSWORD=test
DATABASE=fashion
PORT=3306

With isql -v fashion I can connect without any problem and query remote server. But when trying to use this DSN in MariaDB with

CREATE OR REPLACE TABLE my_tables ENGINE=CONNECT TABLE_TYPE=ODBC CATFUNC=TABLES CONNECTION='DSN=fashion';

I get an error ERROR 2013 (HY000): Lost connection to MySQL server during query when trying to run SELECT * FROM my_tables.
I want to mention, that a remote SQL Server Express connected via FreeTDS has no problems. Also when using another ODBC driver (i.e. https://www.devart.com/odbc/mysql). Only the original MySQL driver causes this issues, regardless if using version 5.3 or 8.0 and regardless if using MariaDB 10.3 or 10.4.
The only log entries I can find are in /var/log/mysql/error.log:

190729 16:38:44 [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.4.6-MariaDB-1:10.4.6+maria~buster
key_buffer_size=134217728
read_buffer_size=131072
max_used_connections=1
max_threads=153
thread_count=7
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 467732 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.
 
Thread pointer: 0x7f9874000f38
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 = 0x7f9878120dd8 thread_stack 0x49000
/usr/sbin/mysqld(my_print_stacktrace+0x2e)[0x564b83d53eee]
/usr/sbin/mysqld(handle_fatal_signal+0x54d)[0x564b8385302d]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x12730)[0x7f9885f95730]
charset.cc.o:0(map_coll_name_to_number(char const*, int))[0x7f98481a539a]
/usr/local/lib/libmyodbc8w.so(_Z22add_compiled_collationP12CHARSET_INFO+0x25)[0x7f98481a5d35]
/usr/local/lib/libmyodbc8w.so(_Z22init_compiled_charsetsi+0x15)[0x7f98481a5d75]
charset.cc.o:0(init_available_charsets())[0x7f98481a47ff]
/lib/x86_64-linux-gnu/libpthread.so.0(+0xf997)[0x7f9885f92997]
/usr/local/lib/libmyodbc8w.so(_ZSt9call_onceIRFvvEJEEvRSt9once_flagOT_DpOT0_+0x5a)[0x7f98481a434a]
/usr/local/lib/libmyodbc8w.so(_Z22my_charset_get_by_nameP17MY_CHARSET_LOADERPKcji+0x31)[0x7f98481a4ed1]
/usr/local/lib/libmyodbc8w.so(_Z21get_charset_by_csnamePKcji+0x3b)[0x7f98481a4fab]
driver/dll.cc:100(myodbc_init)[0x7f984816474b]
driver/handle.cc:87(my_SQLAllocEnv)[0x7f9848167fe1]
driver/handle.cc:853(SQLAllocHandle)[0x7f9848169077]
/lib/x86_64-linux-gnu/libodbc.so.2(+0xe12e)[0x7f987b45212e]
/lib/x86_64-linux-gnu/libodbc.so.2(SQLDriverConnect+0x5e6)[0x7f987b457fb6]
/usr/lib/mysql/plugin/ha_connect.so(_ZN7ODBConn13DriverConnectEj+0x53)[0x7f987b990c03]
/usr/lib/mysql/plugin/ha_connect.so(_ZN7ODBConn4OpenEPKcP10odbc_parmsj+0x5c)[0x7f987b990ccc]
/usr/lib/mysql/plugin/ha_connect.so(_ZN7TDBODBC6OpenDBEP7_global+0x6b)[0x7f987b98cb1b]
/usr/lib/mysql/plugin/ha_connect.so(_Z12CntOpenTableP7_globalP3TDB4MODEPcS4_bP10ha_connect+0x25d)[0x7f987b8ffddd]
/usr/lib/mysql/plugin/ha_connect.so(_ZN10ha_connect9OpenTableEP7_globalb+0x192)[0x7f987b8f38a2]
/usr/lib/mysql/plugin/ha_connect.so(_ZN10ha_connect8rnd_initEb+0xf6)[0x7f987b8f3fe6]
/usr/sbin/mysqld(_ZN7handler22ha_rnd_init_with_errorEb+0x19)[0x564b8385af09]
/usr/sbin/mysqld(_Z16init_read_recordP11READ_RECORDP3THDP5TABLEP10SQL_SELECTP9SORT_INFOibb+0x602)[0x564b83974c82]
/usr/sbin/mysqld(_Z21join_init_read_recordP13st_join_table+0x96)[0x564b83694816]
/usr/sbin/mysqld(_Z10sub_selectP4JOINP13st_join_tableb+0x17a)[0x564b83682ada]
/usr/sbin/mysqld(_ZN4JOIN10exec_innerEv+0xc32)[0x564b836a7f22]
/usr/sbin/mysqld(_ZN4JOIN4execEv+0x33)[0x564b836a8173]
/usr/sbin/mysqld(_Z12mysql_selectP3THDP10TABLE_LISTjR4ListI4ItemEPS4_jP8st_orderS9_S7_S9_yP13select_resultP18st_select_lex_unitP13st_select_lex+0x131)[0x564b836a6531]
/usr/sbin/mysqld(_Z13handle_selectP3THDP3LEXP13select_resultm+0x151)[0x564b836a6e91]
/usr/sbin/mysqld(+0x68092c)[0x564b8364092c]
/usr/sbin/mysqld(_Z21mysql_execute_commandP3THD+0x17f1)[0x564b83648cf1]
/usr/sbin/mysqld(_Z11mysql_parseP3THDPcjP12Parser_statebb+0x270)[0x564b83650230]
/usr/sbin/mysqld(_Z16dispatch_command19enum_server_commandP3THDPcjbb+0x1c23)[0x564b83652f93]
/usr/sbin/mysqld(_Z10do_commandP3THD+0x15e)[0x564b8365425e]
/usr/sbin/mysqld(_Z24do_handle_one_connectionP7CONNECT+0x28a)[0x564b83734fba]
/usr/sbin/mysqld(handle_one_connection+0x3d)[0x564b837350dd]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x7fa3)[0x7f9885f8afa3]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x3f)[0x7f98854c04cf]
 
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0x7f9874012540): select * from brands where id<1
Connection ID (thread ID): 35
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_pushd
own=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=on,table
_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_
pushdown_from_having=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.
Writing a core file...
Working directory at /var/lib/mysql
Resource Limits:
Limit                     Soft Limit           Hard Limit           Units
Max cpu time              unlimited            unlimited            seconds
Max file size             unlimited            unlimited            bytes
Max data size             unlimited            unlimited            bytes
Max stack size            8388608              unlimited            bytes
Max core file size        0                    unlimited            bytes
Max resident set          unlimited            unlimited            bytes
Max processes             7866                 7866                 processes
Max open files            16364                16364                files
Max locked memory         65536                65536                bytes
Max address space         unlimited            unlimited            bytes
Max file locks            unlimited            unlimited            locks
Max pending signals       7866                 7866                 signals
Max msgqueue size         819200               819200               bytes
Max nice priority         0                    0
Max realtime priority     0                    0
Max realtime timeout      unlimited            unlimited            us
Core pattern: core
 
2019-07-29 16:38:49 0 [Note] CONNECT: Version 1.06.0009 January 27, 2019
2019-07-29 16:38:49 0 [Note] InnoDB: Using Linux native AIO
2019-07-29 16:38:49 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-07-29 16:38:49 0 [Note] InnoDB: Uses event mutexes
2019-07-29 16:38:49 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-07-29 16:38:49 0 [Note] InnoDB: Number of pools: 1
2019-07-29 16:38:49 0 [Note] InnoDB: Using SSE2 crc32 instructions
2019-07-29 16:38:49 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
2019-07-29 16:38:49 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2019-07-29 16:38:49 0 [Note] InnoDB: Completed initialization of buffer pool
2019-07-29 16:38:49 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2019-07-29 16:38:49 0 [Note] InnoDB: Starting crash recovery from checkpoint LSN=1631307
2019-07-29 16:38:49 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
2019-07-29 16:38:49 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2019-07-29 16:38:49 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2019-07-29 16:38:49 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2019-07-29 16:38:49 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2019-07-29 16:38:49 0 [Note] InnoDB: Waiting for purge to start
2019-07-29 16:38:49 0 [Note] InnoDB: 10.4.6 started; log sequence number 1631316; transaction id 21
2019-07-29 16:38:49 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2019-07-29 16:38:49 0 [Note] InnoDB: Buffer pool(s) load completed at 190729 16:38:49
2019-07-29 16:38:49 0 [Note] Plugin 'FEEDBACK' is disabled.
2019-07-29 16:38:49 0 [Note] Server socket created on IP: '127.0.0.1'.
2019-07-29 16:38:49 0 [Note] Reading of all Master_info entries succeeded
2019-07-29 16:38:49 0 [Note] Added new Master_info '' to hash table
2019-07-29 16:38:49 0 [Note] /usr/sbin/mysqld: ready for connections.
Version: '10.4.6-MariaDB-1:10.4.6+maria~buster'  socket: '/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution



 Comments   
Comment by Olivier Bertrand [ 2019-07-30 ]

Just one question before I work on this issue: what makes MYSQL tables unable to make SSL connections? And is this the same using the FEDERATED engine?

Comment by Olivier Bertrand [ 2019-07-30 ]

I tried to reproduce this on Windows with no error. Note that ODBC is an original Windows feature that has been adapted on Linux by different products such as UnixODBC. Looking into your log listing, it appears that the error occured into UnixODBC. That is not the first time such problems occur on Linux.

A safer method seems to use JDBC instead of ODBC. The JDBC Java code is the same on Windows and Linux, and it appears that there are less such issues with JDBC than with ODBC.

Comment by Hans [ 2019-07-31 ]

I can use FEDERATED or CONNECT TABLE_TYPE=MYSQL, but only for MySQL servers which do not force a SSL connection. For MySQL SSL connections I've been dependant on unixODBC which works fine when using "isql" CLI tool but not when using CONNECT TABLE_TYPE=ODBC.
I've seen, that JDBC is supported also, but I'm no pro in using it. So far I didn't found any how to for setting up a JDBC connection in MariaDB under Debian.

Regarding https://jira.mariadb.org/browse/MDEV-10936 I've installed OpenJDK 11 but when using TABLE_TYPE=JDBC I get "ERROR 1296 (HY000): Got error 174 'ERROR: class wrappers/JdbcInterface not found!' from CONNECT" but don't know where to place JavaWrappers.jar.

EDIT: OMG, got JDBC working. For a Java noob it's really hard to deal with all this paths and JAR files. As setting CLASSPATH in /etc/profiles is ignored in MariaDB I'm going to check another approach for persisting these paths.

Comment by Olivier Bertrand [ 2019-07-31 ]

Got error 174 'ERROR: class wrappers/JdbcInterface not found!' from CONNECT" but don't know where to place JavaWrappers.jar

Look in the MariaDB documentation for CONNECT. In the chapter about JDBC tables, sub-chapter Java Class Path explains what to do for setting the CLASS PATH that is used to indicate where are the required *.jar files. These are the drivers used for the connections and the JavaWrappers.jar that contains the JdbcInterface class.

Comment by Olivier Bertrand [ 2019-07-31 ]

As setting CLASSPATH in /etc/profiles is ignored in MariaDB I'm going to check another approach for persisting these path

Perhaps by setting connect_class_path in my.cnf.

Comment by Hans [ 2019-08-01 ]

Thanks for your help. I'm going to look how to set the variables permanently and I think I'll give JDBC a try for my project. Please decide on your own, what to do with this ticket. But I can't believe that this problem is related to unixODBC only. Also, I understand that it is hard to deal with it, as it could be related to MariaDB, to unixODBC and to MySQL too (because driver from DevArt is working).

Comment by Olivier Bertrand [ 2019-09-02 ]

Got error 174 'ERROR: class wrappers/JdbcInterface not found!' from CONNECT" but don't know where to place JavaWrappers.jar

Normally it is placed in the plugin directory and automatically recognized. However, if it was not done, it might be the best directory to place it into. I did not test this on Linux myself but several customers use JDBC successfully on Linux.

Incidentally, I was only signaled today by JIRA of your last comment dating... one month ago.

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