jt2594838 commented on code in PR #19019:
URL: https://github.com/apache/iotdb/pull/19019#discussion_r4384712824


##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/subscription/topic/AlterTopicProcedure.java:
##########
@@ -136,23 +171,75 @@ public boolean executeFromValidate(ConfigNodeProcedureEnv 
env) throws Subscripti
 
     subscriptionInfo.get().validateBeforeAlteringTopic(updatedTopicMeta);
 
+    if (Objects.nonNull(existedTopicMeta)
+        && existedTopicMeta.getConfig().isInitialMode()
+        && existedTopicMeta.getConfig().isProgressRetainedAfterUnsubscribe()
+        && !updatedTopicMeta.getConfig().isProgressRetainedAfterUnsubscribe()) 
{
+      prepareRetainedProgressCleanup(env);
+    }
+
     return true;
   }
 
+  private void prepareRetainedProgressCleanup(final ConfigNodeProcedureEnv 
env) {
+    final String topicName = updatedTopicMeta.getTopicName();
+    final boolean isTableModel = updatedTopicMeta.visibleUnderTableModel();
+    for (final ConsumerGroupMeta consumerGroupMeta :
+        
subscriptionInfo.get().getConsumerGroupsRetainingInitialTopic(topicName, 
isTableModel)) {
+      retainedConsumerGroupMetas.add(consumerGroupMeta);
+      retainedProgress.putAll(
+          subscriptionInfo
+              .get()
+              .getCommitProgressKeeper()
+              .getTopicProgress(consumerGroupMeta.getConsumerGroupId(), 
topicName));
+      final String pipeName =
+          PipeStaticMeta.generateSubscriptionPipeName(
+              topicName, consumerGroupMeta.getConsumerGroupId());
+      if (pipeTaskInfo.get().isPipeExisted(pipeName, isTableModel)) {
+        final DropPipeProcedureV2 dropPipeProcedure =
+            new DropPipeProcedureV2(pipeName, isTableModel, pipeTaskInfo);
+        dropPipeProcedure.executeFromValidateTask(env);
+        dropPipeProcedure.executeFromCalculateInfoForTask(env);
+        retainedPipeProcedures.add(dropPipeProcedure);
+      }
+    }
+  }
+
   @Override
   public void executeFromOperateOnConfigNodes(ConfigNodeProcedureEnv env)
       throws SubscriptionException {
     LOGGER.info(
         
ProcedureMessages.ALTERTOPICPROCEDURE_EXECUTEFROMOPERATEONCONFIGNODES_TRY_TO_ALTER_TOPIC);
 
-    TSStatus response;
+    if (!retainedPipeProcedures.isEmpty()) {
+      final List<ConfigPhysicalPlan> dropPipePlans =
+          retainedPipeProcedures.stream()
+              .map(
+                  procedure ->
+                      new DropPipePlanV2(
+                          procedure.getPipeName(), 
updatedTopicMeta.visibleUnderTableModel()))
+              .collect(java.util.stream.Collectors.toList());

Review Comment:
   Mind the import



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