我无法使用 spring-webflux 和 r2dbc(使用 r2dbc-pool driver 0.8.0.M8
)打开超过 10 个连接。我的配置看起来像:
@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);
}
}
当我指定超过 10 个连接时,我收到如下错误:
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)
此外,连接数保持与初始大小相同。不会创建新连接。