Is there SQL database that supports nonblocking ac...
# ktor
Is there SQL database that supports nonblocking access? It is kinda moot to use nonblocking ktor server only to end up blocking on JDBC queries.
MySQL 8 has non blocking way of executing queries with X DevAPI. The API is kinda bad with a lot of bugs, but with some additional code it is usable.
you can use a dedicated thread pool for blocking JDBC queries, e.g.
Copy code
withContext(<http://Dispatchers.IO|Dispatchers.IO>) {}
Details and a proof-of-concept in this article:
It is great that Exposed now has suspendedTransaction, before that for transaction management they were using thread-local variables, which was deal-breaker for me then ­čÖé
How can Exposed suspend transaction?
It still uses JDBC behind the scenes right?
So it has to block at some point
But ... sorry there is a but ... I used Exposed with the DAO Model and when dealing with lazy executing queries, the needed Transaction will not be found.
@Matej Drobni─Ź I am not sure that I understand what you mean by that... The
function just "propagates" the transaction by keeping it in the
, so it won't be "lost" when different thread resumes the execution.
you can use a dedicated thread pool for blocking JDBC queries, e.g.
Right, but how is this any better than just going blocking all the way if you are already going to use a lot of blocking threads?
because most web requests just hit database, so 90% of the time, request would be blocking
The dedicated thread pool just gives a way to limit the number of concurrent requests to the database.
If you have pool with DB connections and thread pool with appropriate number of threads, only those threads will block, the other threads are free to handle web requests.
I've used jasync-db on postgres, works really well.