You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/09/16 07:40:32 UTC

[GitHub] [shardingsphere] xue2lang opened a new issue #12479: class ExecutorEngine, parallelExecute contains sync execute code,will eat the exception

xue2lang opened a new issue #12479:
URL: https://github.com/apache/shardingsphere/issues/12479


   ## Bug Report
   
   **For English only**, other languages will not accept.
   
   Before report a bug, make sure you have:
   
   - Searched open and closed [GitHub issues](https://github.com/apache/shardingsphere/issues).
   - Read documentation: [ShardingSphere Doc](https://shardingsphere.apache.org/document/current/en/overview).
   
   Please pay attention on issues you submitted, because we maybe need more details. 
   If no response anymore and we cannot reproduce it on current information, we will **close it**.
   
   Please answer these questions before submitting your issue. Thanks!
   
   ### Which version of ShardingSphere did you use?
   5.0.0-beta
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
    ShardingSphere-JDBC
   ### Expected behavior
   Lock wait timeout exceeded; try restarting transaction 
   ### Actual behavior
   java.lang.IndexOutOfBoundsException: Index: 3, Size: 3
   	at java.util.LinkedList.checkElementIndex(LinkedList.java:555)
   	at java.util.LinkedList.get(LinkedList.java:476)
   	at org.apache.shardingsphere.driver.executor.batch.BatchPreparedStatementExecutor.accumulate(BatchPreparedStatementExecutor.java:163)
   	at org.apache.shardingsphere.driver.executor.batch.BatchPreparedStatementExecutor.executeBatch(BatchPreparedStatementExecutor.java:143)
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.executeBatch(ShardingSpherePreparedStatement.java:548)
   ### Reason analyze (If you can)
   
   - not use transaction, code will execute  this method 
    org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine#parallelExecute   ,code is :
       private <I, O> List<O> parallelExecute(final Iterator<ExecutionGroup<I>> executionGroups, final ExecutorCallback<I, O> firstCallback, final ExecutorCallback<I, O> callback) throws SQLException {
           ExecutionGroup<I> firstInputs = executionGroups.next();
          **//the other group is async execute **
           Collection<ListenableFuture<Collection<O>>> restResultFutures = asyncExecute(executionGroups, callback);
         **// the first group will sync execute ,this the question **
           return getGroupResults(syncExecute(firstInputs, null == firstCallback ? callback : firstCallback), restResultFutures);
       }
   
   **in above code ,if the first group thrown expection,i can get ,it is my hope;but if the first group execute right,but the other group throw exeption,i can not get;
   Whether an exception is thrown,we see the following code**
   
   
   - Whether synchronous or asynchronous ,all will execute this method In the end
   
   org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutorCallback#execute(org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutionUnit, boolean, java.util.Map<java.lang.String,java.lang.Object>)
   
   
       private T execute(final JDBCExecutionUnit jdbcExecutionUnit, final boolean isTrunkThread, final Map<String, Object> dataMap) throws SQLException {
          ....
           try {
            .....
               return result;
           } catch (final SQLException ex) {
           //**when sync execute ,isTrunkThread=true,will execute next code ,and throw exception;but async execute ,isTrunkThread=false,will return null **
               if (!isTrunkThread) {
                   return null;
               }
            Optional<T> saneResult = getSaneResult(sqlStatement);
               if (saneResult.isPresent()) {
                   return saneResult.get();
               }
               sqlExecutionHook.finishFailure(ex);
               SQLExecutorExceptionHandler.handleException(ex);
           }
       }
   
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
    
   try {
               connection = dataSource.getConnection();
               preparedStatement = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
               for (int index = 0; index <itemIds.size(); index++){
                   if(index==0){
                //  the lock row belong to first group or the other group will make a difference
                       connectionLock = lockOneRowData(itemIds.get(index));
                   }
                   itemCollects.get(index).setAppId(replaceAppId);
                   setParametersTopreparedStatement(preparedStatement, itemCollects.get(index));
                   preparedStatement.addBatch();
               }
               replaceCount=preparedStatement.executeBatch();
   
           } catch (SQLException e) {
               e.printStackTrace();
               exception =e;
           }finally {
               Common.rollback(connectionLock);
           }
           Assert.assertTrue(getExceptionMsg(exception).toString().contains("Lock wait timeout exceeded; try restarting transaction"));
   
   
   
   ### Example codes for reproduce this issue (such as a github link).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] xue2lang commented on issue #12479: class ExecutorEngine, parallelExecute contains sync execute code,will eat the exception

Posted by GitBox <gi...@apache.org>.
xue2lang commented on issue #12479:
URL: https://github.com/apache/shardingsphere/issues/12479#issuecomment-920688452


   > @xue2lang Can you try to submit a pr to fix this problem?
   
   sorry , I am busy with project recently and have no time to solve it ,the problem can fix by your team?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tuichenchuxin commented on issue #12479: class ExecutorEngine, parallelExecute contains sync execute code,will eat the exception

Posted by GitBox <gi...@apache.org>.
tuichenchuxin commented on issue #12479:
URL: https://github.com/apache/shardingsphere/issues/12479#issuecomment-920673717


   @xue2lang Can you try to submit a pr to fix this problem?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] MingxingLAI commented on issue #12479: class ExecutorEngine, parallelExecute contains sync execute code,will eat the exception

Posted by GitBox <gi...@apache.org>.
MingxingLAI commented on issue #12479:
URL: https://github.com/apache/shardingsphere/issues/12479#issuecomment-998645234


   I am willing to solve this problem, Please assign to me. @terrymanu 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] terrymanu commented on issue #12479: class ExecutorEngine, parallelExecute contains sync execute code,will eat the exception

Posted by GitBox <gi...@apache.org>.
terrymanu commented on issue #12479:
URL: https://github.com/apache/shardingsphere/issues/12479#issuecomment-927301524


   @xue2lang Hi, it is not team but community.
   Does anyone interest this issue?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] strongduanmu commented on issue #12479: class ExecutorEngine, parallelExecute contains sync execute code,will eat the exception

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on issue #12479:
URL: https://github.com/apache/shardingsphere/issues/12479#issuecomment-998682748


   @MingxingLAI Welcome.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org