sashapolo commented on code in PR #3216:
URL: https://github.com/apache/ignite-3/pull/3216#discussion_r1494176535


##########
modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItBuildIndexTest.java:
##########
@@ -133,23 +137,115 @@ void testDropIndexDuringTransaction() throws Exception {
 
         checkIndexBuild(partitions, replicas, INDEX_NAME);
 
+        CompletableFuture<Void> indexRemovedFuture = indexRemovedFuture();
+
         IgniteImpl node = CLUSTER.aliveNode();
 
         // Start a transaction. We expect that the index will not be removed 
until this transaction completes.
-        Transaction tx = node.transactions().begin(new 
TransactionOptions().readOnly(false));
+        node.transactions().runInTransaction(tx -> {
+            dropIndex(INDEX_NAME);
+
+            CatalogIndexDescriptor indexDescriptor = 
node.catalogManager().index(INDEX_NAME, node.clock().nowLong());
+
+            assertThat(indexDescriptor, is(notNullValue()));
+            assertThat(indexDescriptor.status(), 
is(CatalogIndexStatus.STOPPING));
+        }, new TransactionOptions().readOnly(false));
+
+        assertThat(indexRemovedFuture, willCompleteSuccessfully());
+    }
+
+    @Test
+    void testDropIndexAfterRegistering() {
+        int partitions = initialNodes();
+
+        int replicas = initialNodes();
+
+        createAndPopulateTable(replicas, partitions);
+
+        CompletableFuture<Void> indexRemovedFuture = indexRemovedFuture();
+
+        CLUSTER.aliveNode().transactions().runInTransaction(tx -> {
+            // Create an index inside a transaction, this will prevent the 
index from building.
+            try {
+                createIndex(INDEX_NAME);
+
+                dropIndex(INDEX_NAME);
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+        }, new TransactionOptions().readOnly(false));
+
+        assertThat(indexRemovedFuture, willCompleteSuccessfully());

Review Comment:
   This will not work, the index will not be removed until all transactions, 
that had observed it, have finished



##########
modules/index/src/integrationTest/java/org/apache/ignite/internal/index/ItBuildIndexTest.java:
##########
@@ -133,23 +137,115 @@ void testDropIndexDuringTransaction() throws Exception {
 
         checkIndexBuild(partitions, replicas, INDEX_NAME);
 
+        CompletableFuture<Void> indexRemovedFuture = indexRemovedFuture();
+
         IgniteImpl node = CLUSTER.aliveNode();
 
         // Start a transaction. We expect that the index will not be removed 
until this transaction completes.
-        Transaction tx = node.transactions().begin(new 
TransactionOptions().readOnly(false));
+        node.transactions().runInTransaction(tx -> {
+            dropIndex(INDEX_NAME);
+
+            CatalogIndexDescriptor indexDescriptor = 
node.catalogManager().index(INDEX_NAME, node.clock().nowLong());
+
+            assertThat(indexDescriptor, is(notNullValue()));
+            assertThat(indexDescriptor.status(), 
is(CatalogIndexStatus.STOPPING));
+        }, new TransactionOptions().readOnly(false));
+
+        assertThat(indexRemovedFuture, willCompleteSuccessfully());
+    }
+
+    @Test
+    void testDropIndexAfterRegistering() {
+        int partitions = initialNodes();
+
+        int replicas = initialNodes();
+
+        createAndPopulateTable(replicas, partitions);
+
+        CompletableFuture<Void> indexRemovedFuture = indexRemovedFuture();
+
+        CLUSTER.aliveNode().transactions().runInTransaction(tx -> {
+            // Create an index inside a transaction, this will prevent the 
index from building.
+            try {
+                createIndex(INDEX_NAME);
+
+                dropIndex(INDEX_NAME);
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+        }, new TransactionOptions().readOnly(false));
+
+        assertThat(indexRemovedFuture, willCompleteSuccessfully());
+    }
+
+    @Test
+    void testDropIndexDuringBuilding() throws Exception {
+        int partitions = initialNodes();
+
+        int replicas = initialNodes();
+
+        createAndPopulateTable(replicas, partitions);
+
+        // Block index building messages, this way index will never become 
AVAILABLE.
+        CLUSTER.runningNodes().forEach(ignite -> ignite.dropMessages((id, 
message) -> message instanceof BuildIndexReplicaRequest));
+
+        CompletableFuture<Void> indexBuildingFuture = indexBuildingFuture();
+
+        CompletableFuture<Void> indexRemovedFuture = indexRemovedFuture();
+
+        createIndex(INDEX_NAME);
+
+        assertThat(indexBuildingFuture, willCompleteSuccessfully());
 
         dropIndex(INDEX_NAME);
 
-        CatalogService catalog = node.catalogManager();
+        assertThat(indexRemovedFuture, willCompleteSuccessfully());

Review Comment:
   please see my answer above



-- 
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]

Reply via email to