duckdb / duckdb_mysql

https://duckdb.org/docs/extensions/mysql
MIT License
55 stars 13 forks source link

Memory corruption in mysql_real_query #97

Closed Vercantez closed 1 week ago

Vercantez commented 1 week ago

What happens?

When scanning my very small MySQL server I consistently get a SIGABRT in mysql_real_query. It looks like it's due to mysql_real_query not being protected by a lock as it should be according to the libmysql docs

In particular, you must ensure that between calls to mysql_real_query() or mysql_query() and mysql_store_result() in one thread, no other thread uses the same connection.

macOS crash report attached. Two threads are clearly simultaneously in mysql_real_query(). Python-2024-11-12-142406.ips.zip

To Reproduce

Different on macOS vs Amazon linux.

        db = duckdb.connect(":memory:")
        db.execute("INSTALL MYSQL;")
        db.execute(f"ATTACH 'database={database_connection_info['database']} user={database_connection_info['user']} password={database_connection_info['password']} host={database_connection_info['host']} port={database_connection_info['port']}' AS mysqldb (TYPE MYSQL, READ_ONLY);")
        db.execute(f"USE mysqldb.{database_connection_info['database']};")
        db.execute("SET enable_external_access = false;")
        db.execute("SHOW;")

OS:

macOS 15.1 and Amazon Linux 2023

MySQL Version:

8.0.35

DuckDB Version:

v1.1.2 f680b7d08f

DuckDB Client:

Python

Full Name:

Miguel Angel Salinas

Affiliation:

camelAI

Have you tried this on the latest main branch?

Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?