This is an automated email from the ASF dual-hosted git repository.

ibessonov pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


The following commit(s) were added to refs/heads/main by this push:
     new 9163f41a40f IGNITE-27054 Add integration test for durable log 
destruction (#7447)
9163f41a40f is described below

commit 9163f41a40f919cf646cf29617e7576b2127ba0f
Author: Ivan Bessonov <[email protected]>
AuthorDate: Wed Jan 21 14:00:51 2026 +0300

    IGNITE-27054 Add integration test for durable log destruction (#7447)
---
 .../internal/raft/server/impl/JraftServerImpl.java |  2 +-
 .../storage/GroupStoragesDestructionIntents.java   |  3 +-
 .../impl/NoopGroupStoragesDestructionIntents.java  |  3 +-
 .../impl/VaultGroupStoragesDestructionIntents.java |  3 +-
 .../partition/ItPartitionDestructionTest.java      | 50 ++++++++++++++++++++++
 5 files changed, 54 insertions(+), 7 deletions(-)

diff --git 
a/modules/raft/src/main/java/org/apache/ignite/internal/raft/server/impl/JraftServerImpl.java
 
b/modules/raft/src/main/java/org/apache/ignite/internal/raft/server/impl/JraftServerImpl.java
index 1efb37bdbcf..967e0128ea3 100644
--- 
a/modules/raft/src/main/java/org/apache/ignite/internal/raft/server/impl/JraftServerImpl.java
+++ 
b/modules/raft/src/main/java/org/apache/ignite/internal/raft/server/impl/JraftServerImpl.java
@@ -634,7 +634,7 @@ public class JraftServerImpl implements RaftServer {
         StorageDestructionIntent intent = 
groupStoragesContextResolver.getIntent(nodeId, groupOptions.volatileStores());
 
         if (durable) {
-            
groupStoragesDestructionIntents.saveStorageDestructionIntent(nodeId.groupId(), 
intent);
+            
groupStoragesDestructionIntents.saveStorageDestructionIntent(intent);
         }
 
         destroyStorages(
diff --git 
a/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/GroupStoragesDestructionIntents.java
 
b/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/GroupStoragesDestructionIntents.java
index 58c8def6073..59d774d70c3 100644
--- 
a/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/GroupStoragesDestructionIntents.java
+++ 
b/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/GroupStoragesDestructionIntents.java
@@ -19,12 +19,11 @@ package org.apache.ignite.internal.raft.storage;
 
 import java.util.Collection;
 import org.apache.ignite.internal.raft.storage.impl.StorageDestructionIntent;
-import org.apache.ignite.internal.replicator.ReplicationGroupId;
 
 /** Persists and retrieves intent to complete storages destruction on node 
start. */
 public interface GroupStoragesDestructionIntents {
     /** Save intent to destroy raft storages. */
-    void saveStorageDestructionIntent(ReplicationGroupId groupId, 
StorageDestructionIntent intent);
+    void saveStorageDestructionIntent(StorageDestructionIntent intent);
 
     /** Remove intent to destroy raft storages. */
     void removeStorageDestructionIntent(String nodeId);
diff --git 
a/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/impl/NoopGroupStoragesDestructionIntents.java
 
b/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/impl/NoopGroupStoragesDestructionIntents.java
index e2a3e6e180b..ef9d79854f9 100644
--- 
a/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/impl/NoopGroupStoragesDestructionIntents.java
+++ 
b/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/impl/NoopGroupStoragesDestructionIntents.java
@@ -20,12 +20,11 @@ package org.apache.ignite.internal.raft.storage.impl;
 import java.util.Collection;
 import java.util.Collections;
 import org.apache.ignite.internal.raft.storage.GroupStoragesDestructionIntents;
-import org.apache.ignite.internal.replicator.ReplicationGroupId;
 
 /** Storage that doesn't save intents to destroy group storages. Used for 
tests. */
 public class NoopGroupStoragesDestructionIntents implements 
GroupStoragesDestructionIntents {
     @Override
-    public void saveStorageDestructionIntent(ReplicationGroupId groupId, 
StorageDestructionIntent intent) {
+    public void saveStorageDestructionIntent(StorageDestructionIntent intent) {
         // No-op.
     }
 
diff --git 
a/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/impl/VaultGroupStoragesDestructionIntents.java
 
b/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/impl/VaultGroupStoragesDestructionIntents.java
index f3bdef9ef57..d870dab9468 100644
--- 
a/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/impl/VaultGroupStoragesDestructionIntents.java
+++ 
b/modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/impl/VaultGroupStoragesDestructionIntents.java
@@ -25,7 +25,6 @@ import java.util.ArrayList;
 import java.util.Collection;
 import org.apache.ignite.internal.lang.ByteArray;
 import org.apache.ignite.internal.raft.storage.GroupStoragesDestructionIntents;
-import org.apache.ignite.internal.replicator.ReplicationGroupId;
 import org.apache.ignite.internal.util.Cursor;
 import org.apache.ignite.internal.vault.VaultEntry;
 import org.apache.ignite.internal.vault.VaultManager;
@@ -44,7 +43,7 @@ public class VaultGroupStoragesDestructionIntents implements 
GroupStoragesDestru
     }
 
     @Override
-    public void saveStorageDestructionIntent(ReplicationGroupId groupId, 
StorageDestructionIntent storageDestructionIntent) {
+    public void saveStorageDestructionIntent(StorageDestructionIntent 
storageDestructionIntent) {
         vault.put(
                 buildKey(storageDestructionIntent.nodeId()),
                 VersionedSerialization.toBytes(storageDestructionIntent, 
StorageDestructionIntentSerializer.INSTANCE)
diff --git 
a/modules/table/src/integrationTest/java/org/apache/ignite/internal/partition/ItPartitionDestructionTest.java
 
b/modules/table/src/integrationTest/java/org/apache/ignite/internal/partition/ItPartitionDestructionTest.java
index bc827ba512f..7e7a71dfc2e 100644
--- 
a/modules/table/src/integrationTest/java/org/apache/ignite/internal/partition/ItPartitionDestructionTest.java
+++ 
b/modules/table/src/integrationTest/java/org/apache/ignite/internal/partition/ItPartitionDestructionTest.java
@@ -40,6 +40,7 @@ import static org.hamcrest.Matchers.greaterThan;
 import static org.hamcrest.Matchers.hasSize;
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
 import static org.hamcrest.io.FileMatchers.anExistingFile;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.Mockito.mock;
@@ -47,6 +48,7 @@ import static org.mockito.Mockito.mock;
 import java.io.File;
 import java.nio.ByteBuffer;
 import java.nio.file.Path;
+import java.util.List;
 import java.util.Objects;
 import java.util.Set;
 import java.util.concurrent.CompletableFuture;
@@ -69,6 +71,8 @@ import 
org.apache.ignite.internal.partitiondistribution.Assignment;
 import org.apache.ignite.internal.partitiondistribution.TokenizedAssignments;
 import org.apache.ignite.internal.raft.Peer;
 import org.apache.ignite.internal.raft.RaftNodeId;
+import org.apache.ignite.internal.raft.storage.impl.StorageDestructionIntent;
+import 
org.apache.ignite.internal.raft.storage.impl.VaultGroupStoragesDestructionIntents;
 import org.apache.ignite.internal.replicator.PartitionGroupId;
 import org.apache.ignite.internal.replicator.ZonePartitionId;
 import org.apache.ignite.internal.sql.engine.util.SqlTestUtils;
@@ -79,6 +83,12 @@ import 
org.apache.ignite.internal.tx.metrics.ResourceVacuumMetrics;
 import 
org.apache.ignite.internal.tx.storage.state.rocksdb.TxStateRocksDbPartitionStorage;
 import org.apache.ignite.internal.vault.VaultService;
 import org.apache.ignite.internal.vault.persistence.PersistentVaultService;
+import org.apache.ignite.raft.jraft.conf.ConfigurationManager;
+import org.apache.ignite.raft.jraft.entity.EnumOutter.EntryType;
+import org.apache.ignite.raft.jraft.entity.LogEntry;
+import org.apache.ignite.raft.jraft.entity.LogId;
+import org.apache.ignite.raft.jraft.entity.codec.DefaultLogEntryCodecFactory;
+import org.apache.ignite.raft.jraft.option.LogStorageOptions;
 import org.apache.ignite.raft.jraft.option.RaftOptions;
 import org.apache.ignite.raft.jraft.storage.LogStorage;
 import org.apache.ignite.table.Table;
@@ -356,6 +366,34 @@ class ItPartitionDestructionTest extends 
ClusterPerTestIntegrationTest {
         verifyPartitionMvDataGetsRemovedFromDisk(restartedIgnite0, tableId, 
replicationGroupId);
     }
 
+    @Test
+    void testDurableLogDestruction() {
+        cluster.startAndInit(1);
+
+        IgniteImpl ignite = unwrapIgniteImpl(cluster.node(0));
+
+        String groupId = "test-group";
+        String groupName = "partition"; // Copied from 
"org.apache.ignite.internal.app.IgniteImpl.PARTITION_GROUP_NAME".
+
+        var destructionIntents = new 
VaultGroupStoragesDestructionIntents(ignite.vault());
+        destructionIntents.saveStorageDestructionIntent(new 
StorageDestructionIntent(groupId, groupName, false));
+
+        LogStorage logStorage = createAndInitCustomLogStorage(ignite, groupId);
+
+        LogEntry entry = new LogEntry();
+        entry.setId(new LogId(1, 1));
+        entry.setType(EntryType.ENTRY_TYPE_NO_OP);
+
+        logStorage.appendEntries(List.of(entry));
+
+        ignite = unwrapIgniteImpl(cluster.restartNode(0));
+
+        LogStorage logStorage0 = createAndInitCustomLogStorage(ignite, 
groupId);
+
+        // Destruction might be asynchronous.
+        await().timeout(2, SECONDS).until(() -> logStorage0.getEntry(1), 
is(nullValue()));
+    }
+
     private static void raisePersistedLwm(Path workDir, HybridTimestamp 
newLwm) {
         VaultService vaultService = new 
PersistentVaultService(IgnitePaths.vaultPath(workDir));
 
@@ -781,4 +819,16 @@ class ItPartitionDestructionTest extends 
ClusterPerTestIntegrationTest {
                     );
                 });
     }
+
+    private static LogStorage createAndInitCustomLogStorage(IgniteImpl ignite, 
String groupId) {
+        RaftOptions raftOptions = 
ignite.raftManager().server().options().getRaftOptions();
+        LogStorage logStorage = 
ignite.partitionsLogStorageFactory().createLogStorage(groupId, raftOptions);
+
+        LogStorageOptions logStorageOptions = new LogStorageOptions();
+        logStorageOptions.setConfigurationManager(new ConfigurationManager());
+        
logStorageOptions.setLogEntryCodecFactory(DefaultLogEntryCodecFactory.getInstance());
+
+        logStorage.init(logStorageOptions);
+        return logStorage;
+    }
 }

Reply via email to