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

Concurrent database calls #80

Closed
amitmurthy opened this issue Apr 30, 2015 · 11 comments
Closed

Concurrent database calls #80

amitmurthy opened this issue Apr 30, 2015 · 11 comments

Comments

@amitmurthy
Copy link

https://github.com/wankdanker/node-odbc the ODBC interface for Node, uses separate threads for database calls in parallel. Since Julia too uses libuv, it makes sense to incorporate, or at least try out, the same strategy for parallel DB calls..

Creating an issue here, in case someone feels like taking it up.

@amitmurthy
Copy link
Author

Maybe worthwhile to see if @threadcall - https://github.com/JuliaLang/julia/blob/master/base/threadcall.jl - can be used here for concurrent ODBC calls.

@quinnj
Copy link
Member

quinnj commented May 6, 2016

Hey @amitmurthy, do separate threads have the ability to do parallel IO? I'm wondering about the case where I want to do concurrent queries and stream the results to disk.

@amitmurthy
Copy link
Author

As long as we are not using the libuv API in the separate thread, there should be no issue. In this case since I/O is happening from the ODBC library call it should be perfectly OK.

We will have to be careful of not using ODBC handles across threads concurrently though.

@StefanKarpinski
Copy link
Member

This is basically the use-case for @threadcall: doing blocking C calls without blocking Julia.

@quinnj
Copy link
Member

quinnj commented May 6, 2016

I'm just worried about cases where you're streaming results to disk. You think you're doing "concurrent" database calls, which technically you are, but once you start writing the results to disk, things get locked up.

@quinnj
Copy link
Member

quinnj commented May 25, 2020

Ok, looked into this (finally!). I couldn't find a way that made thing work reliably. @threadcall doesn't support stdcall which is needed on windows; so we could just not support this on windows, but then running the test suite, I kept getting random hangs on OSX. I then tried just doing fetch(Threads.@spawn ccall(..., but even that produces some weird hangs when running the test suite.

@StefanKarpinski
Copy link
Member

Does ODBC have a non-blocking API?

quinnj added a commit that referenced this issue May 27, 2020
@quinnj
Copy link
Member

quinnj commented May 27, 2020

It looks like the spec does allow for async operations, so here's a PR that gives it a whirl: #269

@quinnj
Copy link
Member

quinnj commented May 27, 2020

It's a little unsatisfying because it depends on if the individual drivers actually implement the async abilities; as opposed to a @threadcall situation which would work no matter the driver.

@quinnj
Copy link
Member

quinnj commented May 27, 2020

Though on the other hand, in our new 1.3+ world, it's pretty easy for users to do Threads.@spawn DBInterface.execute(conn, sql) themselves, so maybe this isn't as pressing an issue ¯_(ツ)_/¯

@quinnj quinnj closed this as completed in bbbafb8 May 27, 2020
@StefanKarpinski
Copy link
Member

That's not guaranteed to run on a separate thread, so it may still block the entire application. Perhaps this is fine until we have a more general way to run potentially blocking calls on a separate thread. This is certainly not the only package that wants such a capability. Many GUI toolkits want the same ability as well.

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

3 participants