vert-x3 / vertx-mysql-postgresql-client

This client is deprecated - use instead
https://github.com/eclipse-vertx/vertx-sql-client
Apache License 2.0
117 stars 59 forks source link

exception being thrown when concurrent statements issued #172

Open radai-rosenblatt opened 4 years ago

radai-rosenblatt commented 4 years ago

Version

3.8.4

Context

i have code that looks like this:

sqlCLient.getConnection(new Handler<AsyncResult<SQLConnection>>() {
   @Override
   public void handle(AsyncResult<SQLConnection> event) {
      //ignore failure
      SQLConnection conn = event.result();
      conn.setAutoCommit(false, new Handler<AsyncResult<Void>>() {
         @Override
         public void handle(AsyncResult<Void> event) {
            //ignore failure
            Promise<UpdateResult> insert1p = Promise.promise();
            Promise<UpdateResult> insert2p = Promise.promise();
            conn.updateWithParams("...", p1);
            conn.updateWithParams("...", p2); <---- THIS THROWS
            CompositeFuture.all(p1.future(), p2.future()).setHandler(
               //handler code. NEVER INVOKED
            )
         }
      }
}

issuing the 2nd update throws an exception:

<<mysql-connection-1>> - There is a query still being run here - race -> false
com.github.jasync.sql.db.exceptions.ConnectionStillRunningQueryException: <<mysql-connection-1>> - There is a query still being run here - race -> false
    at com.github.jasync.sql.db.mysql.MySQLConnection.validateIsReadyForQuery(MySQLConnection.kt:317)
    at com.github.jasync.sql.db.mysql.MySQLConnection.sendPreparedStatementDirect(MySQLConnection.kt:290)
    at com.github.jasync.sql.db.ConcreteConnectionBase$sendPreparedStatement$1.invoke(ConcreteConnectionBase.kt:75)
    at com.github.jasync.sql.db.ConcreteConnectionBase$sendPreparedStatement$1.invoke(ConcreteConnectionBase.kt:16)
    at com.github.jasync.sql.db.interceptor.ConnectionInterceptorHelperKt.wrapPreparedStatementWithInterceptors(ConnectionInterceptorHelper.kt:35)
    at com.github.jasync.sql.db.ConcreteConnectionBase.sendPreparedStatement(ConcreteConnectionBase.kt:67)
    at com.github.jasync.sql.db.Connection$DefaultImpls.sendPreparedStatement(Connection.kt:137)
    at com.github.jasync.sql.db.ConcreteConnection$DefaultImpls.sendPreparedStatement(ConcreteConnection.kt)
    at com.github.jasync.sql.db.ConcreteConnectionBase.sendPreparedStatement(ConcreteConnectionBase.kt:16)
    at io.vertx.ext.asyncsql.impl.AsyncSQLConnectionImpl.lambda$updateWithParams$6(AsyncSQLConnectionImpl.java:168)
    at io.vertx.ext.asyncsql.impl.AsyncSQLConnectionImpl.beginTransactionIfNeeded(AsyncSQLConnectionImpl.java:307)
    at io.vertx.ext.asyncsql.impl.AsyncSQLConnectionImpl.updateWithParams(AsyncSQLConnectionImpl.java:166)

i understand (now) that concurrent statements are not supported, but by default nothing catches and/or prints the exception - there was no trace of it until i started adding catch blocks out of desperation.

wouldnt it be more correct to make p2 fail with this exception instead of (or maybe in addition to) throwing it?

also, are exceptions thrown out of handlers never printed?