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

amashenkov 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 85205f6f1b3 IGNITE-27045 Dropping a table right after dropping index 
leads to catalog update failure (#6967)
85205f6f1b3 is described below

commit 85205f6f1b37a7dbe9c3e24488db49b009fb7192
Author: Andrew V. Mashenkov <[email protected]>
AuthorDate: Tue Nov 18 16:15:06 2025 +0300

    IGNITE-27045 Dropping a table right after dropping index leads to catalog 
update failure (#6967)
---
 .../sql/engine/exec/fsm/DdlBatchGroup.java         |  4 +-
 .../sql/engine/sql/IgniteSqlDropIndex.java         |  6 ++-
 .../internal/sql/engine/exec/DdlBatchingTest.java  | 51 ++++++++++++++++++++++
 3 files changed, 59 insertions(+), 2 deletions(-)

diff --git 
a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/fsm/DdlBatchGroup.java
 
b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/fsm/DdlBatchGroup.java
index 9dd5b09a555..216b4d70ad5 100644
--- 
a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/fsm/DdlBatchGroup.java
+++ 
b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/fsm/DdlBatchGroup.java
@@ -25,7 +25,9 @@ package org.apache.ignite.internal.sql.engine.exec.fsm;
 public enum DdlBatchGroup {
     /** Group for CREATE operations. */
     CREATE,
-    /** Group for DROP operations. */
+    /** Group for DROP index operations. */
+    DROP_INDEX,
+    /** Group for other DROP operations. */
     DROP,
     /** Group for other DDL operations. */
     OTHER;
diff --git 
a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/sql/IgniteSqlDropIndex.java
 
b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/sql/IgniteSqlDropIndex.java
index f7a33fbcd47..bab58fadfde 100644
--- 
a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/sql/IgniteSqlDropIndex.java
+++ 
b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/sql/IgniteSqlDropIndex.java
@@ -35,7 +35,11 @@ import org.jetbrains.annotations.Nullable;
 /**
  * Parse tree for {@code DROP INDEX} statement.
  */
-@DdlBatchAware(group = DdlBatchGroup.DROP)
+// Note: This operation changes index state for available indexes and can't be 
batched with DROP TABLE operations.
+//    Actually, this is a dirty hack and it can and should be batched, but 
"the voices in one's had" do NOT allow just ignore DROP_INDEX
+//    late event and the objective reality, when an index has been dropped 
together with it's table in the same DDL batch (script).
+//    However, the same "voices" are ok with ignoring errors, when the table 
is dropped concurrently while the index purging is in progress.
+@DdlBatchAware(group = DdlBatchGroup.DROP_INDEX)
 public class IgniteSqlDropIndex extends SqlDrop {
 
     /** DROP INDEX operator. */
diff --git 
a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/DdlBatchingTest.java
 
b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/DdlBatchingTest.java
index bde3b3964cd..3be5cfac316 100644
--- 
a/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/DdlBatchingTest.java
+++ 
b/modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/DdlBatchingTest.java
@@ -283,6 +283,57 @@ public class DdlBatchingTest extends 
BaseIgniteAbstractTest {
         assertIndexNotExists("t1_ind_1");
     }
 
+    @Test
+    void batchIsSplitByDropIndex() {
+        AsyncSqlCursor<InternalSqlRow> cursor = gatewayNode.executeQuery(
+                "CREATE TABLE t1 (id INT PRIMARY KEY, val_1 INT, val_2 INT);"
+                        + "CREATE INDEX t1_ind_1 ON t1 (val_1);"
+                        + "CREATE INDEX t1_ind_2 ON t1 (val_2);"
+                        + "DROP INDEX t1_ind_1;"
+                        + "DROP INDEX t1_ind_2;"
+                        + "DROP TABLE t1;"
+        );
+
+        // CREATE TABLE t1 (id INT PRIMARY KEY, val_1 INT, val_2 INT)
+        assertDdlResult(cursor, true);
+        assertThat(cursor.hasNextResult(), is(true));
+        assertThat(cursor.nextResult(), willSucceedFast());
+
+        // CREATE INDEX t1_ind_1 ON t1 (val_1)
+        cursor = cursor.nextResult().join();
+        assertDdlResult(cursor, true);
+        assertThat(cursor.hasNextResult(), is(true));
+        assertThat(cursor.nextResult(), willSucceedFast());
+
+        // CREATE INDEX t1_ind_2 ON t1 (val_2)
+        cursor = cursor.nextResult().join();
+        assertDdlResult(cursor, true);
+        assertThat(cursor.hasNextResult(), is(true));
+        assertThat(cursor.nextResult(), willSucceedFast());
+
+        // DROP INDEX t1_ind_1
+        cursor = cursor.nextResult().join();
+        assertDdlResult(cursor, true);
+        assertThat(cursor.hasNextResult(), is(true));
+        assertThat(cursor.nextResult(), willSucceedFast());
+
+        // DROP INDEX t1_ind_1
+        cursor = cursor.nextResult().join();
+        assertDdlResult(cursor, true);
+        assertThat(cursor.hasNextResult(), is(true));
+        assertThat(cursor.nextResult(), willSucceedFast());
+
+        // DROP TABLE t1
+        cursor = cursor.nextResult().join();
+        assertDdlResult(cursor, true);
+        assertThat(cursor.hasNextResult(), is(false));
+
+        assertEquals(3, executeCallCounter.get());
+        assertTableNotExists("t1");
+        assertIndexNotExists("t1_ind_1");
+        assertIndexNotExists("t1_ind_2");
+    }
+
     @Test
     void batchIsSplitByOtherStatements() {
         AsyncSqlCursor<InternalSqlRow> cursor = gatewayNode.executeQuery(

Reply via email to