Skip to content

Issue when use the proxy on a ConnectionPool #54

Closed
@deblockt

Description

@deblockt

Bug Report

I found some errors running perf test using the proxy around a ConnectionPool

Versions

  • Driver: 0.8.RELEASE
  • Database: postgres
  • Java: 1.11
  • OS: ubuntu

Current Behavior

Using a proxy around a ConnectionPool do some error running perf test on my api.
We found some error like

  • java.lang.IndexOutOfBoundsException: Source emitted more than one item.
  • org.springframework.transaction.IllegalTransactionStateException: Transaction is already completed - do not call commit or rollback more than once per transaction
  • org.springframework.transaction.TransactionSystemException: Could not commit R2DBC transaction; nested exception is io.r2dbc.postgresql.ExceptionFactory$PostgresqlNonTransientResourceException: [34000] portal "B_986" does not exist

When I remove the proxy all is OK. Using the proxy on the ConnectionFactory instead of the ConnectionPool all is OK.

Table schema

This issue is not linked with a specific table.

Steps to reproduce

Create a Java API performing a get on a transaction using Spring Boot.
The proxy configuration is done using something like that;

@Configuration
public class R2dbcConfiguration {

    private final Tracer tracer;

    public R2dbcConfiguration(Tracer tracer) {
        this.tracer = tracer;
    }

    /**
     * this is a copy/past of org.springframework.boot.autoconfigure.r2dbc.ConnectionFactoryConfiguration.ConnectionPoolConnectionFactoryConfiguration
     * waiting an r2dbc zipkin implementation provided by Spring (see https://github.com/spring-projects-experimental/spring-boot-r2dbc/issues/71)
     */
    @Bean(destroyMethod = "dispose")
    public ConnectionPool withTracing(R2dbcProperties properties,
                                  List<ConnectionFactoryOptionsBuilderCustomizer> customizers) {
        ConnectionFactory connectionFactory =  ConnectionFactoryBuilder.create(properties).customize(customizers)
            .build();
        R2dbcProperties.Pool pool = properties.getPool();
        ConnectionPoolConfiguration.Builder builder = ConnectionPoolConfiguration.builder(connectionFactory)
            .maxSize(pool.getMaxSize()).initialSize(pool.getInitialSize()).maxIdleTime(pool.getMaxIdleTime());
        if (StringUtils.hasText(pool.getValidationQuery())) {
            builder.validationQuery(pool.getValidationQuery());
        }
        return new ConnectionPool(builder.build());
    }

    @Primary
    @Bean
    public ConnectionFactory connectionFactoryWithTracing(ConnectionFactory original) {
        return ProxyConnectionFactory.builder(original)
            .listener(new TracingExecutionListener(tracer))
            .build();
    }
}

Expected behavior/code

No exception like without using the proxy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions