Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ATTACH mysql database does not support concurrency #89

Open
robotslacker opened this issue Sep 18, 2024 · 3 comments
Open

ATTACH mysql database does not support concurrency #89

robotslacker opened this issue Sep 18, 2024 · 3 comments

Comments

@robotslacker
Copy link

As we know, mysql extension and PG extension are both working on session layer, which means that if there are multiple sessions and each session needs to access external data, then each session must perform it's own attach operation.
If we perform attach concurrently, we may encounter errors:

Invalid Input Error: Initialization function "mysql_scanner_init"
from file "extensions/v1.1.0/linux_amd64/gcc4/mysql_scanner.duckdb_extension"
threw an exception: “Table Function with name "mysql_clear_cache" already exists!"

@Mytherin
Copy link
Contributor

Thanks for the report!

As we know, mysql extension and PG extension are both working on session layer, which means that if there are multiple sessions and each session needs to access external data, then each session must perform it's own attach operation.

This is not accurate, attached databases are shared across connections to the same DuckDB instance.

If we perform attach concurrently, we may encounter errors:

That seems like the extension is being loaded twice. Are you attaching concurrently from separate threads? Which API are you using? Could you provide a complete reproducible example?

@robotslacker
Copy link
Author

"Are you attaching concurrently from separate threads?"
Yes. I tried to attach the schema with "ATTACH IF NOT EXIST '' AS db ..." from separate thread.
Each thread has a separate connection, duplicate() from master connection.
I executed this sql with jdbc statement.execute().

I will try upload complete reproducible example later, it is not very easy.
Because this issue is intermittent.

@Mytherin
Copy link
Contributor

It sounds like this is caused by loading the extension concurrently in separate threads. You can solve this by calling LOAD mysql once right after connecting to the system for the first time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants