Transactions 在读取提交模式下点燃事务不一致

Transactions 在读取提交模式下点燃事务不一致,transactions,ignite,Transactions,Ignite,我们在READ_Committed模式下使用Ignite事务,我们还使用乐观离线锁设计模式来满足数据一致性要求和读取时的延迟。对于我们的业务来说,在读取时不要在缓存中看到部分更新的数据,这一点很重要。可重复读取会阻止我们的读取,这就是我们不使用它的原因 读取事务: @Override public SearchResult apply(ComputeTaskInData<SearchProductOffer> data) { while (true) { tr

我们在READ_Committed模式下使用Ignite事务,我们还使用乐观离线锁设计模式来满足数据一致性要求和读取时的延迟。对于我们的业务来说,在读取时不要在缓存中看到部分更新的数据,这一点很重要。可重复读取会阻止我们的读取,这就是我们不使用它的原因

读取事务:

@Override
public SearchResult apply(ComputeTaskInData<SearchProductOffer> data) {
    while (true) {
        try (Transaction tx = ignite.transactions().txStart(PESSIMISTIC, READ_COMMITTED)) {
            Long initialTimestamp = getCurrentTimestampFromIgniteCache();
            ... // multiple caches read where we can see commited data in the middle of read
            Long finalTimestamp = getCurrentTimestampFromigniteCache();

            // Check if transaction was commited in the middle of read request. If so, retry. This 
               timestamp increments in update transaction.
            if (finalTimestamp > initialTimestamp) continue;

            return readResult;
    }
        try (Transaction transaction = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
        // Multiple caches update.
           IgniteCache<OfflineLockKey, Long> offerOfflineLock = 
                                               ignite.getOrCreateCache(OFFLINE_LOCK.name());
            OfflineLockKey offlineLockKey = new 
                                    OfflineLockKey(segmentIndex.segmentInfo.getSegmentId());
            Long offerTimestamp = offerOfflineLock.get(offlineLockKey);
            if (offerTimestamp == null) {
                offerTimestamp = 0L;
            }
            offerTimestamp++;
            offerOfflineLock.put(offlineLockKey, offerTimestamp);

            transaction.commit();
        }
@覆盖
公共搜索结果应用(ComputeTaskInData数据){
while(true){
try(Transaction tx=ignite.transactions().txStart(悲观,已读){
Long initialTimestamp=getCurrentTimestampFromIgniteCache();
…//多个高速缓存读取在读取中间数据的位置。
Long finalTimestamp=getCurrentTimestampFromigniteCache();
/检查事务是否在读取请求的中间被提交。如果是,请重试。
更新事务中的时间戳增量。
如果(finalTimestamp>initialTimestamp)继续;
返回readResult;
}
}

更新交易记录:

@Override
public SearchResult apply(ComputeTaskInData<SearchProductOffer> data) {
    while (true) {
        try (Transaction tx = ignite.transactions().txStart(PESSIMISTIC, READ_COMMITTED)) {
            Long initialTimestamp = getCurrentTimestampFromIgniteCache();
            ... // multiple caches read where we can see commited data in the middle of read
            Long finalTimestamp = getCurrentTimestampFromigniteCache();

            // Check if transaction was commited in the middle of read request. If so, retry. This 
               timestamp increments in update transaction.
            if (finalTimestamp > initialTimestamp) continue;

            return readResult;
    }
        try (Transaction transaction = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
        // Multiple caches update.
           IgniteCache<OfflineLockKey, Long> offerOfflineLock = 
                                               ignite.getOrCreateCache(OFFLINE_LOCK.name());
            OfflineLockKey offlineLockKey = new 
                                    OfflineLockKey(segmentIndex.segmentInfo.getSegmentId());
            Long offerTimestamp = offerOfflineLock.get(offlineLockKey);
            if (offerTimestamp == null) {
                offerTimestamp = 0L;
            }
            offerTimestamp++;
            offerOfflineLock.put(offlineLockKey, offerTimestamp);

            transaction.commit();
        }
try(事务=ignite.transactions().txStart(悲观的、可重复的读取)){
//多个缓存更新。
IgniteCache OFFERLINELOCK=
ignite.getOrCreateCache(OFFLINE_LOCK.name());
OfflineLockKey OfflineLockKey=新
OfflineLockKey(segmentIndex.segmentInfo.getSegmentId());
Long offerTimestamp=OFFEROFLINELOCK.get(离线锁定键);
if(offerTimestamp==null){
offerTimestamp=0升;
}
offerTimestamp++;
offerofrinelock.put(离线锁定键,offerTimestamp);
commit();
}
但问题是,我们读取不一致的数据,并且不重试。ignite事务似乎不是原子事务,并且我们没有得到递增的时间戳。这是否应该是悲观读取提交模式的行为? 我们尝试了脱机锁定缓存的不同缓存模式。
是的,所有缓存都是事务性的。

我这边的问题是缓存配置

您必须使用该配置获取缓存(在我的情况下,它是我的本地缓存)