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

rpuch 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 1446b95be68 IGNITE-26819 Do not check whether table is dropped for 
TableWriteIntentSwitchReplicaRequest (#6944)
1446b95be68 is described below

commit 1446b95be6858db9ec6c7a546b74720d0a20e0f0
Author: Roman Puchkovskiy <[email protected]>
AuthorDate: Wed Nov 12 10:05:37 2025 +0400

    IGNITE-26819 Do not check whether table is dropped for 
TableWriteIntentSwitchReplicaRequest (#6944)
---
 .../TableAwareReplicaRequestPreProcessor.java      |  7 ++-
 .../ZonePartitionReplicaListenerTest.java          | 54 ++++++++++++++++++++--
 2 files changed, 57 insertions(+), 4 deletions(-)

diff --git 
a/modules/partition-replicator/src/main/java/org/apache/ignite/internal/partition/replicator/TableAwareReplicaRequestPreProcessor.java
 
b/modules/partition-replicator/src/main/java/org/apache/ignite/internal/partition/replicator/TableAwareReplicaRequestPreProcessor.java
index 17f25b12c00..5265760d11a 100644
--- 
a/modules/partition-replicator/src/main/java/org/apache/ignite/internal/partition/replicator/TableAwareReplicaRequestPreProcessor.java
+++ 
b/modules/partition-replicator/src/main/java/org/apache/ignite/internal/partition/replicator/TableAwareReplicaRequestPreProcessor.java
@@ -104,7 +104,12 @@ public class TableAwareReplicaRequestPreProcessor {
 
         @Nullable HybridTimestamp finalTxTs = txTs;
         Runnable validateClo = () -> {
-            schemaCompatValidator.failIfTableDoesNotExistAt(opTs, tableId);
+            // Some requests require a schema sync (this makes sure we wait 
till table replica processor is added for per-zone case),
+            // but we don't need to validate table existence (as for this kind 
of request this is done further, in the request handling
+            // logic).
+            if (!(request instanceof TableWriteIntentSwitchReplicaRequest)) {
+                schemaCompatValidator.failIfTableDoesNotExistAt(opTs, tableId);
+            }
 
             boolean hasSchemaVersion = request instanceof 
SchemaVersionAwareReplicaRequest;
 
diff --git 
a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/replication/ZonePartitionReplicaListenerTest.java
 
b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/replication/ZonePartitionReplicaListenerTest.java
index 46d2068d048..407835cf095 100644
--- 
a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/replication/ZonePartitionReplicaListenerTest.java
+++ 
b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/replication/ZonePartitionReplicaListenerTest.java
@@ -437,6 +437,8 @@ public class ZonePartitionReplicaListenerTest extends 
IgniteAbstractTest {
     /** Primary index. */
     private Lazy<TableSchemaAwareIndexStorage> pkStorageSupplier;
 
+    private CatalogIndexDescriptor pkIndexDescriptor;
+
     /** If true the local replica is considered leader, false otherwise. */
     private boolean localLeader;
 
@@ -560,10 +562,10 @@ public class ZonePartitionReplicaListenerTest extends 
IgniteAbstractTest {
                 
DummyInternalTableImpl.createTableIndexStoragesSupplier(Map.of(pkStorage().id(),
 pkStorage()))
         );
 
-        CatalogIndexDescriptor indexDescriptor = 
mock(CatalogIndexDescriptor.class);
-        when(indexDescriptor.id()).thenReturn(pkIndexId);
+        pkIndexDescriptor = mock(CatalogIndexDescriptor.class);
+        when(pkIndexDescriptor.id()).thenReturn(pkIndexId);
 
-        when(catalog.indexes(anyInt())).thenReturn(List.of(indexDescriptor));
+        when(catalog.indexes(anyInt())).thenReturn(List.of(pkIndexDescriptor));
 
         configureTxManager(txManager);
 
@@ -1509,6 +1511,52 @@ public class ZonePartitionReplicaListenerTest extends 
IgniteAbstractTest {
         zonePartitionReplicaListener.removeTableReplicaProcessor(TABLE_ID);
     }
 
+    @ParameterizedTest
+    @ValueSource(booleans = {true, false})
+    @WithSystemProperty(key = COLOCATION_FEATURE_FLAG, value = "true")
+    void writeIntentSwitchForDroppedTableWorks(boolean commit) {
+        Catalog catalogWithoutTable = mock(Catalog.class);
+        
when(catalogWithoutTable.indexes(anyInt())).thenReturn(List.of(pkIndexDescriptor));
+
+        UUID txId = newTxId();
+        HybridTimestamp beginTs = beginTimestamp(txId);
+        HybridTimestamp commitTs = clock.now();
+
+        // We have to force push clock forward because we will invoke listener 
directly bypassing ReplicaManager or MessageService, so clock
+        // won't be updated if the test computes too fast for physical clock 
ticking and then we may have equal clock#current and the
+        // given above commit timestamp.
+        clock.update(commitTs);
+
+        HybridTimestamp reliableCatalogVersionTs = commit ? commitTs : beginTs;
+        when(catalogService.activeCatalog(anyLong())).then(invocation -> {
+            long ts = invocation.getArgument(0);
+            if (ts >= reliableCatalogVersionTs.longValue()) {
+                return catalogWithoutTable;
+            } else {
+                return catalog;
+            }
+        });
+        when(catalogWithoutTable.table(grpId.tableId())).thenReturn(null);
+
+        zonePartitionReplicaListener.addTableReplicaProcessor(TABLE_ID, mocked 
-> tableReplicaProcessor);
+
+        CompletableFuture<ReplicaResult> invokeFuture = 
zonePartitionReplicaListener.invoke(
+                TX_MESSAGES_FACTORY.writeIntentSwitchReplicaRequest()
+                        .groupId(tablePartitionIdMessage(grpId))
+                        .tableIds(Set.of(grpId.tableId()))
+                        .txId(txId)
+                        .commit(commit)
+                        .commitTimestamp(commit ? commitTs : null)
+                        .build(),
+                localNode.id()
+        );
+
+        assertThat(invokeFuture, willCompleteSuccessfully());
+        assertThat(invokeFuture.join().applyResult().replicationFuture(), 
willCompleteSuccessfully());
+
+        zonePartitionReplicaListener.removeTableReplicaProcessor(TABLE_ID);
+    }
+
     @Test
     public void abortsSuccessfully() {
         AtomicReference<Boolean> committed = interceptFinishTxCommand();

Reply via email to