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


##########
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:
   Added the missing java.util.stream.Collectors import in this update.



##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/agent/SubscriptionConsumerAgent.java:
##########
@@ -349,8 +378,25 @@ private void cleanupConsumerGroupSubscriptions(
       final String consumerGroupId,
       final ConsumerGroupMeta consumerGroupMeta,
       final boolean retainConfiguredProgress) {
+    cleanupConsumerGroupSubscriptions(
+        consumerGroupId,
+        consumerGroupMeta,
+        retainConfiguredProgress,
+        java.util.Collections.emptySet());

Review Comment:
   Added the missing java.util.Collections import in this update.



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