tkalkirill commented on code in PR #1263:
URL: https://github.com/apache/ignite-3/pull/1263#discussion_r1007822282
##########
modules/table/src/test/java/org/apache/ignite/internal/table/distributed/raft/PartitionCommandListenerTest.java:
##########
@@ -206,6 +215,42 @@ public void testInsertRowsBatchedAndCheck() {
readAndCheck(false);
}
+ /**
+ * The test checks that {@link PartitionListener#onSnapshotSave(Path,
Consumer)} propagates
+ * the maximal last applied index among storages to all storages.
+ */
+ @Test
+ public void testOnSnapshotSavePropagateLastAppliedIndex() {
+ ReplicaService replicaService = mock(ReplicaService.class,
RETURNS_DEEP_STUBS);
+
+ TestConcurrentHashMapTxStateStorage txStateStorage = new
TestConcurrentHashMapTxStateStorage();
+
+ TestPartitionDataStorage partitionDataStorage = new
TestPartitionDataStorage(mvPartitionStorage);
+
+ PartitionListener testCommandListener = new PartitionListener(
+ partitionDataStorage,
+ txStateStorage,
+ new TxManagerImpl(replicaService, new HeapLockManager(), new
HybridClock()),
+ () -> Map.of(pkStorage.id(), pkStorage)
+ );
+
+ txStateStorage.lastAppliedIndex(3L);
+
+ partitionDataStorage.lastAppliedIndex(5L);
+
+ AtomicLong counter = new AtomicLong(0);
+
+ testCommandListener.onSnapshotSave(workDir, (throwable) -> {
+ counter.incrementAndGet();
+ });
+
+ assertEquals(1L, counter.get());
+
+ assertEquals(5L, partitionDataStorage.lastAppliedIndex());
Review Comment:
Here it is not checked what exactly the maximum was taken, but only for
`partitionDataStorage` let's run **onSnapshotSave** one more time but with a
maximum for `txStateStorage`.
##########
modules/transactions/src/testFixtures/java/org/apache/ignite/internal/tx/storage/state/test/TestConcurrentHashMapTxStateStorage.java:
##########
@@ -57,13 +57,17 @@ public boolean compareAndSet(UUID txId, TxState
txStateExpected, @NotNull TxMeta
if (old == null && txStateExpected == null) {
TxMeta oldMeta = storage.putIfAbsent(txId, txMeta);
if (oldMeta == null) {
Review Comment:
For example, this check is not needed, let's do something like
`TxStateRocksDbStorage#compareAndSet`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]