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:44:02 UTC

[GitHub] [shardingsphere] 15724757448 opened a new issue, #10640: AbstractConnectionAdapter#getConnections Is it possible to make effective use of Connections? version 4.1.0

15724757448 opened a new issue, #10640:
URL: https://github.com/apache/shardingsphere/issues/10640

   ----------------------code----------------------
   public final List<Connection> getConnections(final ConnectionMode connectionMode, final String dataSourceName, final int connectionSize) throws SQLException {
           DataSource dataSource = getDataSourceMap().get(dataSourceName);
           Preconditions.checkState(null != dataSource, "Missing the data source name: '%s'", dataSourceName);
           Collection<Connection> connections;
           synchronized (cachedConnections) {
               connections = cachedConnections.get(dataSourceName);
           }
           List<Connection> result;
           if (connections.size() >= connectionSize) {
               result = new ArrayList<>(connections).subList(0, connectionSize);
           } else if (!connections.isEmpty()) {
               result = new ArrayList<>(connectionSize);
               result.addAll(connections);
               List<Connection> newConnections = createConnections(dataSourceName, connectionMode, dataSource, connectionSize - connections.size());
               result.addAll(newConnections);
               synchronized (cachedConnections) {
                   cachedConnections.putAll(dataSourceName, newConnections);
               }
           } else {
               result = new ArrayList<>(createConnections(dataSourceName, connectionMode, dataSource, connectionSize));
               synchronized (cachedConnections) {
                   cachedConnections.putAll(dataSourceName, result);
               }
           }
           return result;
       }
   
   ----------------------question----------------------
   When cachedconnections > = connectionsize, the data source is obtained from cachedconnections. If the maximum number of connections of the data source is greater than max.connections.size.per.query, will the maximum number of links never be used?
   
   for example
   
   <bean  id="druidDataSource" class="com.alibaba.druid.pool.DruidDataSource" >
       <property name="maxActive" value="80"/>
   </bean>
   <bean class="xxxDataSourceBuilder" actory-method="buildShardingDataSource">
       <constructor-arg name="dataSource" ref="druidDataSource"/>
       <constructor-arg name="properties">
           <props>
               <prop key="sql.show">true</prop>
               <prop key="max.connections.size.per.query">20</prop>
               <prop key="executor.size">20</prop>
           </props>
       </constructor-arg>
   </bean>
   
   maxActive=80. max.connections.size.per.query=20
   If this data source is only used by shardingDataSource, is maxactive limited to 20 at most?
   


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


Re: [I] AbstractConnectionAdapter#getConnections Is it possible to make effective use of Connections? version 4.1.0 [shardingsphere]

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

   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] hza2022x commented on issue #10640: AbstractConnectionAdapter#getConnections Is it possible to make effective use of Connections? version 4.1.0

Posted by "hza2022x (via GitHub)" <gi...@apache.org>.
hza2022x commented on issue #10640:
URL: https://github.com/apache/shardingsphere/issues/10640#issuecomment-1469164153

   i have the same question


-- 
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 #10640: AbstractConnectionAdapter#getConnections Is it possible to make effective use of Connections? version 4.1.0

Posted by GitBox <gi...@apache.org>.
github-actions[bot] closed issue #10640: AbstractConnectionAdapter#getConnections Is it possible to make effective use of Connections? version 4.1.0
URL: https://github.com/apache/shardingsphere/issues/10640


-- 
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] commented on issue #10640: AbstractConnectionAdapter#getConnections Is it possible to make effective use of Connections? version 4.1.0

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

   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


[GitHub] [shardingsphere] hza2022x commented on issue #10640: AbstractConnectionAdapter#getConnections Is it possible to make effective use of Connections? version 4.1.0

Posted by "hza2022x (via GitHub)" <gi...@apache.org>.
hza2022x commented on issue #10640:
URL: https://github.com/apache/shardingsphere/issues/10640#issuecomment-1469167353

   i changed the code to the following:
   
           List<Connection> result;
           if (connections.size() >= connectionSize) {
               // change to random
               //result = new ArrayList<>(connections).subList(0, connectionSize);
               result = CollectionUtil.random(connections, 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.

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

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