Caideyipi commented on code in PR #18806:
URL: https://github.com/apache/iotdb/pull/18806#discussion_r4237708898


##########
integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBTableIT.java:
##########
@@ -1229,4 +1230,79 @@ public void testTreeViewTable() throws Exception {
       }
     }
   }
+
+  @Test
+  public void testAsyncDropTableProgress() throws Exception {
+    try (final Connection connection =
+            EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+        final Statement statement = connection.createStatement()) {
+      statement.execute("create database async_drop_db");
+      statement.execute("use async_drop_db");
+      statement.execute("create table drop_target (device string tag, reading 
int32)");
+      statement.execute("drop table drop_target");
+
+      try (final ResultSet resultSet =
+          statement.executeQuery(
+              "select procedure_id, state, progress "
+                  + "from information_schema.drop_table_procedures "
+                  + "where database = 'async_drop_db' and table_name = 
'drop_target'")) {
+        assertTrue(resultSet.next());
+        assertTrue(resultSet.getLong(1) >= 0);
+        assertFalse(resultSet.getString(2).isEmpty());
+        assertFalse(resultSet.getString(3).isEmpty());
+        assertFalse(resultSet.next());
+      }

Review Comment:
   Updated the IT to wait for completion and verify the retained SUCCESS 
result, removing the redundant query immediately after DROP TABLE. This covers 
both a drop that finishes before the first query and one that is still running. 
The unit test checks the active deletion stage while execution is held by a 
CountDownLatch, so that assertion does not depend on deletion timing.



##########
integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBTableIT.java:
##########
@@ -1229,4 +1230,79 @@ public void testTreeViewTable() throws Exception {
       }
     }
   }
+
+  @Test
+  public void testAsyncDropTableProgress() throws Exception {
+    try (final Connection connection =
+            EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+        final Statement statement = connection.createStatement()) {
+      statement.execute("create database async_drop_db");
+      statement.execute("use async_drop_db");
+      statement.execute("create table drop_target (device string tag, reading 
int32)");
+      statement.execute("drop table drop_target");
+
+      try (final ResultSet resultSet =
+          statement.executeQuery(
+              "select procedure_id, state, progress "
+                  + "from information_schema.drop_table_procedures "
+                  + "where database = 'async_drop_db' and table_name = 
'drop_target'")) {
+        assertTrue(resultSet.next());
+        assertTrue(resultSet.getLong(1) >= 0);
+        assertFalse(resultSet.getString(2).isEmpty());
+        assertFalse(resultSet.getString(3).isEmpty());
+        assertFalse(resultSet.next());
+      }
+
+      awaitDropProcedure(statement, "async_drop_db", "drop_target");
+      TestUtils.assertResultSetEqual(
+          statement.executeQuery("show tables from async_drop_db"),
+          "TableName,TTL(ms),",
+          Collections.emptySet());
+      try (final ResultSet resultSet =
+          statement.executeQuery(
+              "select procedure_id, state, progress, error_message "
+                  + "from information_schema.drop_table_procedures "
+                  + "where database = 'async_drop_db' and table_name = 
'drop_target'")) {
+        assertTrue(resultSet.next());
+        assertTrue(resultSet.getLong(1) >= 0);
+        assertEquals("SUCCESS", resultSet.getString(2));
+        assertEquals("SUCCESS", resultSet.getString(3));
+        Assert.assertNull(resultSet.getString(4));
+        assertFalse(resultSet.next());
+      }

Review Comment:
   Yes. The view includes both active drops and completed results retained by 
the executor's existing completed-procedure cleaner. Retention uses 
procedure_completed_evict_ttl (60 seconds by default, measured from the 
procedure's last update); the cleaner runs every 
procedure_completed_clean_interval (30 seconds by default), so an expired 
record disappears on a subsequent cleanup. There is no separate count limit: 
all drop results within that retention window are included. This PR reuses the 
existing procedure store and cleanup policy rather than adding a separate 
history store. I also documented the shared TTL retention on 
getDropTableProcedures().



##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/ProcedureExecutor.java:
##########
@@ -134,12 +140,17 @@ public void init(int numThreads) {
     workId.set(0);
     workerThreads = new CopyOnWriteArrayList<>();
     for (int i = 0; i < corePoolSize; i++) {
-      workerThreads.add(new WorkerThread(threadGroup));
+      workerThreads.add(new WorkerThread(threadGroup, scheduler));
     }
+    dropTableWorkerThreads = new CopyOnWriteArrayList<>();
+    dropTableWorkerThreads.add(
+        new WorkerThread(threadGroup, dropTableScheduler, 
"DropTableProcedureWorker-"));

Review Comment:
   Changed this to lazy initialization: init()/startWorkers() no longer create 
a DROP TABLE worker when there is no drop to run. The first scheduled drop 
creates one worker; recovered runnable/failed drops create it during recovery 
and start it in startWorkers(). Initialization, startup, and shutdown share the 
lifecycle lock so concurrent first submissions cannot create or start it twice. 
Added regression coverage for concurrent first drops, recovery/restart, 
completed drops not creating a worker, DROP VIEW routing, and regular 
procedures progressing while a drop is blocked.



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