首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >隔离是必需的,还是我也可以使用read?

隔离是必需的,还是我也可以使用read?
EN

Stack Overflow用户
提问于 2022-07-21 10:13:20
回答 2查看 65关注 0票数 0

我使用与JdbcChannelMessageStore的spring集成,使用pgbouncer备份postgres。我运行了多个jvm,得到了:

由于并发删除(或更新),无法序列化访问

这是problem?

  • Can/should i切换为read提交的
  1. (如果是,如何实现)?
EN

回答 2

Stack Overflow用户

发布于 2022-07-21 14:12:15

JdbcChannelMessageStore不启动事务,它只是参与现有的事务。看,你是从你的服务水平开始的。也许它只是一个@Transactional,它确实有这样的选项:

代码语言:javascript
复制
/**
 * 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

票数 0
EN

Stack Overflow用户

发布于 2022-07-21 15:24:06

对于一个波勒来说,这似乎是这样做的:

代码语言:javascript
复制
  @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;
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73064355

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档