mysql 连接池 dbcb2_postgres r2dbc-pool的连接池大小

bd96500e110b49cbb3cd949968f18be7.png

I'm not able to open more than 10 connections with spring-webflux and r2dbc (with r2dbc-pool driver 0.8.0.M8). My config looks like:

@Configuration

public class PostgresConfig extends AbstractR2dbcConfiguration {

@Override

@Bean

public ConnectionFactory connectionFactory() {

ConnectionFactory connectionFactory = ConnectionFactories.get(ConnectionFactoryOptions.builder()

.option(DRIVER, "pool")

.option(PROTOCOL, "postgresql")

.option(HOST, host)

.option(USER, user)

.option(PASSWORD, password)

.option(DATABASE, database)

.build());

ConnectionPoolConfiguration configuration = ConnectionPoolConfiguration.builder(connectionFactory)

.maxIdleTime(Duration.ofMinutes(30))

.initialSize(initialSize)

.maxSize(maxSize)

.maxCreateConnectionTime(Duration.ofSeconds(1))

.build();

return new ConnectionPool(configuration);

}

}

When I'm specifying more than 10 connections I get errors like:

org.springframework.dao.DataAccessResourceFailureException:

Failed to obtain R2DBC Connection; nested exception is

java.util.concurrent.TimeoutException:

Did not observe any item or terminal signal within 1000ms in 'lift'

(and no fallback has been configured)

at org.springframework.data.r2dbc.connectionfactory.ConnectionFactoryUtils

.lambda$getConnection$0(ConnectionFactoryUtils.java:71)

Moreover, number of connections remain the same as initial size. New connections are not created.

解决方案

Ok, the MAX_SIZE should be also specified for ConnectionFactoryOptions. Otherwise connection pool size still remains 10.

import static io.r2dbc.pool.PoolingConnectionFactoryProvider.MAX_SIZE;

ConnectionFactory connectionFactory = ConnectionFactories.get(ConnectionFactoryOptions.builder()

.option(DRIVER, "pool")

.option(PROTOCOL, "postgresql")

.option(HOST, host)

.option(USER, user)

.option(PASSWORD, password)

.option(DATABASE, database)

.option(MAX_SIZE, maxSize)

.build());

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值