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 2022/10/10 06:42:40 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
   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 :
   ```java
       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
   ```java
   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.
    ```java
   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.apache.org

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


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

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on issue #12479:
URL: https://github.com/apache/shardingsphere/issues/12479#issuecomment-1272350753

   Hello , this issue has not received a reply for several days.
   This issue is supposed to be closed.


-- 
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


Re: [I] class ExecutorEngine, parallelExecute contains sync execute code,will eat the exception [shardingsphere]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #12479:
URL: https://github.com/apache/shardingsphere/issues/12479#issuecomment-2026022849

   There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.


-- 
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] github-actions[bot] closed issue #12479: class ExecutorEngine, parallelExecute contains sync execute code,will eat the exception

Posted by GitBox <gi...@apache.org>.
github-actions[bot] closed issue #12479: class ExecutorEngine, parallelExecute contains sync execute code,will eat the exception
URL: https://github.com/apache/shardingsphere/issues/12479


-- 
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