gpt4 book ai didi

hibernate - AtomikosSQL异常 : Connection pool exhausted - Connection getting exhausted whenever application throws exception

转载 作者:行者123 更新时间:2023-12-02 00:59:59 26 4
gpt4 key购买 nike

在我的 spring mvc 应用程序中,我使用 Atomikos Transaction API (v3.9.3) 和 JPA(Hibernate 作为供应商)。我有两个实体管理器连接到两个数据源。下面提供了其中一个数据源的配置。我面临一个问题,每当我的应用程序抛出异常时,连接就会耗尽并且无法获取。当池中的所有连接都耗尽时,我最终会得到 AtomikosSQLException: Connection pool Exeded。任何人都可以帮助我的配置中缺少什么吗?在实现这一点时,我关注了这个博客:

http://fabiomaffioletti.me/blog/2014/04/15/distributed-transactions-multiple-databases-spring-boot-spring-data-jpa-atomikos/

这是我的数据源配置:

@Bean(name = "masterDataSource", initMethod = "init", destroyMethod = "close")
public DataSource masterDataSource() {
final MysqlXADataSource mysqlXaDataSource = new MysqlXADataSource();
mysqlXaDataSource.setUrl(Preconditions.checkNotNull(env.getProperty("dataSource.master.url")));
mysqlXaDataSource.setPinGlobalTxToPhysicalConnection(true);
mysqlXaDataSource.setUser(Preconditions.checkNotNull(env.getProperty("dataSource.username")));
mysqlXaDataSource.setPassword(Preconditions.checkNotNull(env.getProperty("dataSource.password")));

AtomikosDataSourceBean xaDataSource = new AtomikosDataSourceBean();
xaDataSource.setXaDataSource(mysqlXaDataSource);
xaDataSource.setUniqueResourceName("ds_master");

return xaDataSource;
}

这是堆栈跟踪:

Unable to acquire JDBC Connection [n/a] 2016-11-11 10:50:58,487com.atomikos.jdbc.AtomikosSQLException: Connection pool exhausted - try increasing 'maxPoolSize' and/or 'borrowConnectionTimeout' on the DataSourceBean.
at com.atomikos.jdbc.AtomikosSQLException.throwAtomikosSQLException(AtomikosSQLException.java:46)
at com.atomikos.jdbc.AbstractDataSourceBean.throwAtomikosSQLException(AbstractDataSourceBean.java:90)
at com.atomikos.jdbc.AbstractDataSourceBean.throwAtomikosSQLException(AbstractDataSourceBean.java:85)
at com.atomikos.jdbc.AbstractDataSourceBean.getConnection(AbstractDataSourceBean.java:347)
at com.atomikos.jdbc.AbstractDataSourceBean.getConnection(AbstractDataSourceBean.java:394)
at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122)
at org.hibernate.internal.NonContextualJdbcConnectionAccess.obtainConnection(NonContextualJdbcConnectionAccess.java:35)
at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:99)
at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:129)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.connection(StatementPreparerImpl.java:47)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:146)

最佳答案

我遇到了同样的问题,这似乎是 Atomikos 上的问题,我通过将atomikos版本升级到4.0.6来解决,如果您是商业用户,您可以尝试使用3.9.4

关于hibernate - AtomikosSQL异常 : Connection pool exhausted - Connection getting exhausted whenever application throws exception,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40542455/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com