0

I using spring integration with JdbcChannelMessageStore backed up with postgres using pgbouncer. I have multiple jvms running, and got:

Could not serialize access due to concurrent delete (or update)

  1. Is this a problem?
  2. Can/should I switch to read committed (and if so, how)?
wdk
  • 373
  • 2
  • 8

2 Answers2

0

The JdbcChannelMessageStore does not start transaction, it is just participate in the existing one. Look ho you start it on your service level. Perhaps it is just a @Transactional and it does have this option:

/**
 * The transaction isolation level.
 * <p>Defaults to {@link Isolation#DEFAULT}.
 * <p>Exclusively designed for use with {@link Propagation#REQUIRED} or
 * {@link Propagation#REQUIRES_NEW} since it only applies to newly started
 * transactions. Consider switching the "validateExistingTransactions" flag to
 * "true" on your transaction manager if you'd like isolation level declarations
 * to get rejected when participating in an existing transaction with a different
 * isolation level.
 * @see org.springframework.transaction.interceptor.TransactionAttribute#getIsolationLevel()
 * @see org.springframework.transaction.support.AbstractPlatformTransactionManager#setValidateExistingTransaction
 */
Isolation isolation() default Isolation.DEFAULT;

The Spring Integration transactions support options do provide hooks to configure it similar way: https://docs.spring.io/spring-integration/docs/current/reference/html/transactions.html#transactions

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118
0

For a Poller it seems to be done like this:

  @Bean(MESSAGING_TRANSACTION_INTERCEPTOR)
    public static TransactionInterceptor transactionInterceptor() {
        return new TransactionInterceptorBuilder(true)
                .isolation(READ_COMMITTED) // The default ISOLATION_REPEATABLE_READ leads to errors and is not needed
                .build();
    }

    @Bean(name = DEFAULT_POLLER)
    public PollerMetadata pollerMetaData(@Qualifier(MESSAGING_TRANSACTION_INTERCEPTOR) TransactionInterceptor transactionInterceptor) {
        PollerMetadata meta = new PollerMetadata();
        meta.setAdviceChain(List.of(transactionInterceptor));
        return meta;
    }
wdk
  • 373
  • 2
  • 8