-
Notifications
You must be signed in to change notification settings - Fork 350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
spring r2dbc-psql throws: Failed to obtain R2DBC Connection #1608
Comments
You're allocating more connections than permitted:
|
The thing is, it breaks on my app server where different threads are calling That's why i reproduced it with flatMap(). I was under the impression that if i enable the pooling feature, then the connections should never exceed Shouldn't the pool handle the concurrency as it requests for new connection on each request?. |
While the pool limits concurrency, the pool might still be configured to allow more connections than your server does. |
I'm using the default one spring provides me by injecting The only place where i write some config code for r2dbc is here: @Configuration
//@EnableR2dbcRepositories
@EnableTransactionManagement
public class R2dbcConfig extends AbstractR2dbcConfiguration {
private final String username;
private final String password;
private final String url;
private final String database;
private final List<Converter<Object, Object>> converters;
R2dbcConfig(
@Value("${spring.r2dbc.username}") String username,
@Value("${spring.r2dbc.password}") String password,
@Value("${spring.r2dbc.url}") String url,
@Value("${spring.r2dbc.database}") String database,
@Autowired List<Converter<Object, Object>> converters
) {
this.username = username;
this.password = password;
this.url = url;
this.database = database;
this.converters = converters;
}
@Bean
public ReactiveTransactionManager transactionManager(ConnectionFactory connectionFactory) {
return new R2dbcTransactionManager(connectionFactory);
}
@Override
@Bean
public @NonNull ConnectionFactory connectionFactory() {
return ConnectionFactoryBuilder
.withUrl(url)
.username(username)
.password(password)
.database(database)
.build();
}
@Override
protected @NonNull List<Object> getCustomConverters() {
List<Object> customConverters = new ArrayList<>();
customConverters.add(new LocalDateTimeToLongConverter());
customConverters.add(new JsonToMapConverter());
customConverters.addAll(converters);
customConverters.addAll(PostgresDialect.INSTANCE.getConverters());
return customConverters;
}
} |
Unless your R2DBC URL starts with |
I tested that option in the morning but it threw an exception that stated: i cannot use both configs app.props and pool in url. I cannot post the exception atm since the code is on my "work" computer, i will get back at you tomorrow. Thanks for the help though ! |
Hey, here is the exception if I enable the pooling feature both in URL and
But it seems choosing to enable the feature through URL, it works and Im not getting the error:
Thanks for the help. So maybe there is a bug in enabling the pooling through
|
If you use properties-based configuration, then please remove your |
Oh i see, that makes sense. |
I have a simple project where i do some concurrent inserts:
application properties:
I was under the impression that if i enable the pooling feature, then the connections should never exceed
10
. Is this a bug or am i understanding something incorecctly ?Logs:
If this issue is more relevant to
r2dbc-postgresql
or tor2dbc-pool
let me know.springboot:3.1.2
postgresql:15.3
The text was updated successfully, but these errors were encountered: