vertx-mysql-postgresql-client
vertx-mysql-postgresql-client copied to clipboard
Thread blocked - getConnection
Hi guys,
I faced this issue when trying to access a database, but my internet is really slow so it is taking some seconds to successfully establish a new connection, the problem is that it is blocking the main-thread.
Checking the error and the code I found something and would like to understand better: AsyncConnectionPool.java (line 63)
connection
.connect().onComplete(ScalaUtils.toFunction1(handler), VertxEventLoopExecutionContext.create(vertx));
Looks like this is using the current context to wait for the connection, right?
The stacktrace:
io.vertx.core.VertxException: Thread blocked
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323)
at java.net.InetAddress.getAllByName0(InetAddress.java:1276)
at java.net.InetAddress.getAllByName(InetAddress.java:1192)
at java.net.InetAddress.getAllByName(InetAddress.java:1126)
at java.net.InetAddress.getByName(InetAddress.java:1076)
at java.net.InetSocketAddress.<init>(InetSocketAddress.java:220)
at com.github.mauricio.async.db.mysql.codec.MySQLConnectionHandler.connect(MySQLConnectionHandler.scala:87)
at com.github.mauricio.async.db.mysql.MySQLConnection.connect(MySQLConnection.scala:84)
at io.vertx.ext.asyncsql.impl.pool.AsyncConnectionPool.createConnection(AsyncConnectionPool.java:63)
at io.vertx.ext.asyncsql.impl.pool.AsyncConnectionPool.createOrWaitForAvailableConnection(AsyncConnectionPool.java:77)
at io.vertx.ext.asyncsql.impl.pool.AsyncConnectionPool.take(AsyncConnectionPool.java:86)
I think it’s because the mysql driver does not use the async DNS API of Netty.
you can open an issue in this repo about it
On Mar 13, 2017, at 11:31 PM, Leonardo Silva [email protected] wrote:
Hi guys,
I faced this issue when trying to access a database, but my internet is really slow so it is taking some seconds to successfully establish a new connection, the problem is that it is blocking the main-thread.
Checking the error and the code I found something and would like to understand better: AsyncConnectionPool.java (line 63)
connection .connect().onComplete(ScalaUtils.toFunction1(handler), VertxEventLoopExecutionContext.create(vertx)); Looks like this is using the current context to wait for the connection, right?
The stacktrace:
io.vertx.core.VertxException: Thread blocked at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928) at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323) at java.net.InetAddress.getAllByName0(InetAddress.java:1276) at java.net.InetAddress.getAllByName(InetAddress.java:1192) at java.net.InetAddress.getAllByName(InetAddress.java:1126) at java.net.InetAddress.getByName(InetAddress.java:1076) at java.net.InetSocketAddress.
(InetSocketAddress.java:220) at com.github.mauricio.async.db.mysql.codec.MySQLConnectionHandler.connect(MySQLConnectionHandler.scala:87) at com.github.mauricio.async.db.mysql.MySQLConnection.connect(MySQLConnection.scala:84) at io.vertx.ext.asyncsql.impl.pool.AsyncConnectionPool.createConnection(AsyncConnectionPool.java:63) at io.vertx.ext.asyncsql.impl.pool.AsyncConnectionPool.createOrWaitForAvailableConnection(AsyncConnectionPool.java:77) at io.vertx.ext.asyncsql.impl.pool.AsyncConnectionPool.take(AsyncConnectionPool.java:86) — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/vert-x3/vertx-mysql-postgresql-client/issues/69, or mute the thread https://github.com/notifications/unsubscribe-auth/AANxii266pWMmdXdhl-KRd-tW84NJ740ks5rlcPdgaJpZM4Mb5se.
@vietj, would not be good just to use another execution service from our side? or run this in a executeBlocking just like we do with jdbc-async?
I believe it would be easier to use the io.vertx.core.impl.AddressResolver and then directly use the resolved InetSocketAddress
@vietj I can check this when have some time if needed, just need to understand better the integration
https://thoeni.io/post/macos-sierra-java/
this solution!