我使用与JdbcChannelMessageStore的spring集成,使用pgbouncer备份postgres。我运行了多个jvm,得到了:
由于并发删除(或更新),无法序列化访问
这是problem?
发布于 2022-07-21 06:12:15
JdbcChannelMessageStore
不启动事务,它只是参与现有的事务。看,你是从你的服务水平开始的。也许它只是一个@Transactional
,它确实有这样的选项:
/**
* 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;
选项确实提供了类似方式配置它的钩子:https://docs.spring.io/spring-integration/docs/current/reference/html/transactions.html#transactions
发布于 2022-07-21 07:24:06
对于一个波勒来说,这似乎是这样做的:
@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;
}
https://stackoverflow.com/questions/73064355
复制相似问题