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/01/21 05:41:09 UTC

[GitHub] [shardingsphere] Linliangkung opened a new issue #9115: 4.1.1版本 CONNECTION_STRICTLY 模式下死锁

Linliangkung opened a new issue #9115:
URL: https://github.com/apache/shardingsphere/issues/9115


   AbstractConnectionAdapter.createConnections方法(问题描述在代码块注释中)
   ``` java
   private List<Connection> createConnections(final String dataSourceName, final ConnectionMode connectionMode, final DataSource dataSource, final int connectionSize) throws SQLException {
           if (1 == connectionSize) {
               Connection connection = createConnection(dataSourceName, dataSource);
               replayMethodsInvocation(connection);
               return Collections.singletonList(connection);
           }
           if (ConnectionMode.CONNECTION_STRICTLY == connectionMode) {
               //CONNECTION_STRICTLY 模式下为什么没有加synchronized代码块
              //假设我的connectionSize为2,数据源最大线程数是2
              //现在有两个线程A和线程B同时执行下面的createConnections方法
              //如果线程A和线程B都同时拿到一个连接,然后再去拿第二个连接的时候就会出现占有一个连接,相互等待对方释放连接的情况出现
               return createConnections(dataSourceName, dataSource, connectionSize);
           }
           synchronized (dataSource) {
               return createConnections(dataSourceName, dataSource, connectionSize);
           }
       } 
   ```


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

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



[GitHub] [shardingsphere] Linliangkung commented on issue #9115: 4.1.1版本 CONNECTION_STRICTLY 模式下死锁

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


   > **For English only**, other languages will not accept.
   Hi terrymanu!
   My English is terrible.Can i send a email to you.I want to konw the answer for the code design.


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

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



[GitHub] [shardingsphere] terrymanu closed issue #9115: 4.1.1版本 CONNECTION_STRICTLY 模式下死锁

Posted by GitBox <gi...@apache.org>.
terrymanu closed issue #9115:
URL: https://github.com/apache/shardingsphere/issues/9115


   


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

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



[GitHub] [shardingsphere] Linliangkung commented on issue #9115: 4.1.1版本 CONNECTION_STRICTLY 模式下死锁

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






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

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



[GitHub] [shardingsphere] terrymanu closed issue #9115: 4.1.1版本 CONNECTION_STRICTLY 模式下死锁

Posted by GitBox <gi...@apache.org>.
terrymanu closed issue #9115:
URL: https://github.com/apache/shardingsphere/issues/9115


   


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

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



[GitHub] [shardingsphere] terrymanu commented on issue #9115: 4.1.1版本 CONNECTION_STRICTLY 模式下死锁

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


   **For English only**, other languages will not accept.


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

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



[GitHub] [shardingsphere] Linliangkung commented on issue #9115: 4.1.1版本 CONNECTION_STRICTLY 模式下死锁

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


   我的问题是为什么在CONNECTION_STRICTLY模式下不使用synchronized获取连接,而在MEMORY_STRICTLY模式下会考虑到死锁问题使用synchronized代码块获取连接。在这两个模式下应该都是存在死锁风险。


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

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



[GitHub] [shardingsphere] terrymanu commented on issue #9115: 4.1.1版本 CONNECTION_STRICTLY 模式下死锁

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


   **For English only**, other languages will not accept.


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

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