You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ro...@apache.org on 2024/07/02 07:03:59 UTC

(iotdb) branch master updated: Subscription: remove restrictions on topic when subscribing to TsFile (#12801)

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

rong pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new dab34768916 Subscription: remove restrictions on topic when subscribing to TsFile (#12801)
dab34768916 is described below

commit dab347689167c27e89457efd467a511dd8ee3490
Author: V_Galaxy <vg...@apache.org>
AuthorDate: Tue Jul 2 15:03:53 2024 +0800

    Subscription: remove restrictions on topic when subscribing to TsFile (#12801)
    
    This commit also includes the following minor changes:
    
    1. Fixed the data insertion logic in the receiver env of the consumer group IT.
    2. Added live/snapshot parameters to the pipe source mode, corresponding to subscribe/query.
    3. Maintenance of current subscription topics information by the consumer and some optimizations.
---
 .../apache/iotdb/SubscriptionSessionExample.java   |  40 ++-
 .../it/dual/IoTDBSubscriptionConsumerGroupIT.java  | 286 +++++++++-------
 .../it/dual/IoTDBSubscriptionTopicIT.java          | 137 +-------
 .../iotdb/rpc/subscription/config/TopicConfig.java |  23 +-
 .../rpc/subscription/config/TopicConstant.java     |   8 +-
 .../payload/poll/SubscriptionCommitContext.java    |   2 +
 .../subscription/payload/poll/TabletsPayload.java  |  10 +-
 .../response/PipeSubscribeSubscribeResp.java       |  32 +-
 .../response/PipeSubscribeUnsubscribeResp.java     |  32 +-
 .../consumer/SubscriptionConsumer.java             | 102 ++++--
 .../consumer/SubscriptionProvider.java             |  10 +-
 .../consumer/SubscriptionPullConsumer.java         |  25 ++
 .../consumer/SubscriptionPushConsumer.java         |  29 +-
 .../db/pipe/agent/task/PipeDataNodeTaskAgent.java  |  44 ++-
 .../evolvable/batch/PipeTabletEventBatch.java      |   4 +-
 .../batch/PipeTabletEventTsFileBatch.java          |   2 +-
 .../tablet/TabletInsertionDataContainer.java       |   6 +-
 .../PipeHistoricalDataRegionTsFileExtractor.java   |  57 ++--
 .../realtime/PipeRealtimeDataRegionExtractor.java  |  43 ++-
 .../agent/SubscriptionConsumerAgent.java           |   2 +-
 .../subscription/agent/SubscriptionTopicAgent.java |  17 +
 .../db/subscription/broker/SubscriptionBroker.java |  19 +-
 .../broker/SubscriptionPrefetchingQueue.java       | 205 ++++++++++--
 .../broker/SubscriptionPrefetchingTabletQueue.java | 190 +++++++++++
 .../SubscriptionPrefetchingTabletsQueue.java       | 265 ---------------
 .../broker/SubscriptionPrefetchingTsFileQueue.java | 371 +++++++++++----------
 .../db/subscription/event/SubscriptionEvent.java   | 292 ++++++++++++++--
 .../event/SubscriptionEventBinaryCache.java        |  51 +--
 .../event/SubscriptionTsFileEvent.java             | 247 --------------
 .../batch/SubscriptionPipeTabletEventBatch.java    | 149 +++++++++
 .../batch/SubscriptionPipeTsFileEventBatch.java    |  61 ++++
 .../event/pipe/SubscriptionPipeEmptyEvent.java     |  41 +++
 .../event/pipe/SubscriptionPipeEvents.java         |  34 ++
 .../pipe/SubscriptionPipeTabletBatchEvents.java    |  53 +++
 .../pipe/SubscriptionPipeTsFileBatchEvents.java    |  82 +++++
 .../pipe/SubscriptionPipeTsFilePlainEvent.java     |  56 ++++
 .../receiver/SubscriptionReceiverV1.java           |  39 ++-
 .../apache/iotdb/commons/conf/CommonConfig.java    |  54 ++-
 .../iotdb/commons/conf/CommonDescriptor.java       |  24 +-
 .../config/constant/PipeExtractorConstant.java     |   6 +-
 .../subscription/config/SubscriptionConfig.java    |  31 +-
 41 files changed, 1950 insertions(+), 1231 deletions(-)

diff --git a/example/session/src/main/java/org/apache/iotdb/SubscriptionSessionExample.java b/example/session/src/main/java/org/apache/iotdb/SubscriptionSessionExample.java
index 3c3ae618ce3..79380b4bc5b 100644
--- a/example/session/src/main/java/org/apache/iotdb/SubscriptionSessionExample.java
+++ b/example/session/src/main/java/org/apache/iotdb/SubscriptionSessionExample.java
@@ -39,12 +39,14 @@ import org.apache.tsfile.read.expression.QueryExpression;
 import org.apache.tsfile.read.query.dataset.QueryDataSet;
 
 import java.io.IOException;
+import java.net.URLEncoder;
 import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.Properties;
+import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.locks.LockSupport;
 
 public class SubscriptionSessionExample {
@@ -63,6 +65,7 @@ public class SubscriptionSessionExample {
   private static final long POLL_TIMEOUT_MS = 10_000L;
   private static final int MAX_RETRY_TIMES = 3;
   private static final int PARALLELISM = 8;
+  private static final long CURRENT_TIME = System.currentTimeMillis();
 
   private static void prepareData() throws Exception {
     // Open session
@@ -77,14 +80,14 @@ public class SubscriptionSessionExample {
     session.open(false);
 
     // Insert some historical data
-    final long currentTime = System.currentTimeMillis();
     for (int i = 0; i < 100; ++i) {
       session.executeNonQueryStatement(
           String.format("insert into root.db.d1(time, s1, s2) values (%s, 1, 2)", i));
       session.executeNonQueryStatement(
-          String.format("insert into root.db.d2(time, s1, s2) values (%s, 3, 4)", currentTime + i));
+          String.format(
+              "insert into root.db.d2(time, s1, s2) values (%s, 3, 4)", CURRENT_TIME + i));
       session.executeNonQueryStatement(
-          String.format("insert into root.sg.d3(time, s1) values (%s, 5)", currentTime + 2 * i));
+          String.format("insert into root.sg.d3(time, s1) values (%s, 5)", CURRENT_TIME + 2 * i));
     }
     session.executeNonQueryStatement("flush");
 
@@ -137,7 +140,6 @@ public class SubscriptionSessionExample {
     consumer1.open();
     consumer1.subscribe(TOPIC_1);
     while (true) {
-      LockSupport.parkNanos(SLEEP_NS); // wait some time
       final List<SubscriptionMessage> messages = consumer1.poll(POLL_TIMEOUT_MS);
       if (messages.isEmpty()) {
         retryCount++;
@@ -173,6 +175,8 @@ public class SubscriptionSessionExample {
     try (final SubscriptionSession subscriptionSession = new SubscriptionSession(HOST, PORT)) {
       subscriptionSession.open();
       final Properties config = new Properties();
+      config.put(TopicConstant.START_TIME_KEY, CURRENT_TIME + 33);
+      config.put(TopicConstant.END_TIME_KEY, CURRENT_TIME + 66);
       config.put(TopicConstant.FORMAT_KEY, TopicConstant.FORMAT_TS_FILE_HANDLER_VALUE);
       subscriptionSession.createTopic(TOPIC_2, config);
     }
@@ -194,7 +198,6 @@ public class SubscriptionSessionExample {
                   consumer2.open();
                   consumer2.subscribe(TOPIC_2);
                   while (true) {
-                    LockSupport.parkNanos(SLEEP_NS); // wait some time
                     final List<SubscriptionMessage> messages =
                         consumer2.poll(Collections.singleton(TOPIC_2), POLL_TIMEOUT_MS);
                     if (messages.isEmpty()) {
@@ -210,7 +213,7 @@ public class SubscriptionSessionExample {
                                 QueryExpression.create(
                                     Arrays.asList(
                                         new Path("root.db.d2", "s2", true),
-                                        new Path("root.db.d3", "s1", true)),
+                                        new Path("root.sg.d3", "s1", true)),
                                     null));
                         while (dataSet.hasNext()) {
                           System.out.println(dataSet.next());
@@ -233,13 +236,13 @@ public class SubscriptionSessionExample {
     }
   }
 
-  /** multi push consumer subscribe topic with tsfile format and query mode */
+  /** multi push consumer subscribe topic with tsfile format and snapshot mode */
   private static void dataSubscription3() throws Exception {
     try (final SubscriptionSession subscriptionSession = new SubscriptionSession(HOST, PORT)) {
       subscriptionSession.open();
       final Properties config = new Properties();
       config.put(TopicConstant.FORMAT_KEY, TopicConstant.FORMAT_TS_FILE_HANDLER_VALUE);
-      config.put(TopicConstant.MODE_KEY, TopicConstant.MODE_QUERY_VALUE);
+      config.put(TopicConstant.MODE_KEY, TopicConstant.MODE_SNAPSHOT_VALUE);
       subscriptionSession.createTopic(TOPIC_3, config);
     }
 
@@ -265,7 +268,7 @@ public class SubscriptionSessionExample {
                         .buildPushConsumer()) {
                   consumer3.open();
                   consumer3.subscribe(TOPIC_3);
-                  while (consumer3.hasMoreData()) {
+                  while (!consumer3.allSnapshotTopicMessagesHaveBeenConsumed()) {
                     LockSupport.parkNanos(SLEEP_NS); // wait some time
                   }
                 }
@@ -279,16 +282,17 @@ public class SubscriptionSessionExample {
     }
   }
 
-  /** multi pull consumer subscribe topic with tsfile format and query mode */
+  /** multi pull consumer subscribe topic with tsfile format and snapshot mode */
   private static void dataSubscription4() throws Exception {
     try (final SubscriptionSession subscriptionSession = new SubscriptionSession(HOST, PORT)) {
       subscriptionSession.open();
       final Properties config = new Properties();
       config.put(TopicConstant.FORMAT_KEY, TopicConstant.FORMAT_TS_FILE_HANDLER_VALUE);
-      config.put(TopicConstant.MODE_KEY, TopicConstant.MODE_QUERY_VALUE);
+      config.put(TopicConstant.MODE_KEY, TopicConstant.MODE_SNAPSHOT_VALUE);
       subscriptionSession.createTopic(TOPIC_4, config);
     }
 
+    final AtomicLong counter = new AtomicLong();
     final List<Thread> threads = new ArrayList<>();
     for (int i = 0; i < PARALLELISM; ++i) {
       final int idx = i;
@@ -305,16 +309,16 @@ public class SubscriptionSessionExample {
                         .buildPullConsumer()) {
                   consumer4.open();
                   consumer4.subscribe(TOPIC_4);
-                  while (true) {
-                    LockSupport.parkNanos(SLEEP_NS); // wait some time
-                    if (!consumer4.hasMoreData()) {
-                      break;
-                    }
+                  while (!consumer4.allSnapshotTopicMessagesHaveBeenConsumed()) {
                     for (final SubscriptionMessage message : consumer4.poll(POLL_TIMEOUT_MS)) {
                       final SubscriptionTsFileHandler handler = message.getTsFileHandler();
                       handler.moveFile(
-                          Paths.get(System.getProperty("user.dir"), "new-subscription-dir")
-                              .resolve(handler.getPath().getFileName()));
+                          Paths.get(System.getProperty("user.dir"), "exported-tsfiles")
+                              .resolve(
+                                  URLEncoder.encode(TOPIC_4)
+                                      + "-"
+                                      + counter.getAndIncrement()
+                                      + ".tsfile"));
                     }
                   }
                 } catch (final IOException e) {
diff --git a/integration-test/src/test/java/org/apache/iotdb/subscription/it/dual/IoTDBSubscriptionConsumerGroupIT.java b/integration-test/src/test/java/org/apache/iotdb/subscription/it/dual/IoTDBSubscriptionConsumerGroupIT.java
index e3325749250..9a0d7865afe 100644
--- a/integration-test/src/test/java/org/apache/iotdb/subscription/it/dual/IoTDBSubscriptionConsumerGroupIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/subscription/it/dual/IoTDBSubscriptionConsumerGroupIT.java
@@ -80,6 +80,11 @@ public class IoTDBSubscriptionConsumerGroupIT extends AbstractSubscriptionDualIT
   private static final Logger LOGGER =
       LoggerFactory.getLogger(IoTDBSubscriptionConsumerGroupIT.class);
 
+  private static final String TOPIC_1 = "topic1";
+  private static final String TOPIC_2 = "topic2";
+  private static final String TOPIC_ALL_WITH_TABLET = "topic_all_with_tablet";
+  private static final String TOPIC_ALL_WITH_TSFILE = "topic_all_with_tsfile";
+
   private static Map<String, String> ASYNC_CONNECTOR_ATTRIBUTES;
   private static Map<String, String> SYNC_CONNECTOR_ATTRIBUTES;
   private static Map<String, String> LEGACY_CONNECTOR_ATTRIBUTES;
@@ -91,8 +96,9 @@ public class IoTDBSubscriptionConsumerGroupIT extends AbstractSubscriptionDualIT
   private static Pair<List<SubscriptionInfo>, Map<String, String>> __3C_3CG_SUBSCRIBE_TWO_TOPIC;
   private static Pair<List<SubscriptionInfo>, Map<String, String>> __4C_2CG_SUBSCRIBE_TWO_TOPIC;
   private static Pair<List<SubscriptionInfo>, Map<String, String>>
-      __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_TS_FILE;
-  private static Pair<List<SubscriptionInfo>, Map<String, String>> __6C_2CG_SUBSCRIBE_TS_FILE_TOPIC;
+      __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_ALL;
+  private static Pair<List<SubscriptionInfo>, Map<String, String>>
+      __6C_2CG_SUBSCRIBE_ONE_TOPIC_WITH_ALL;
 
   static final class SubscriptionInfo {
     final String consumerId;
@@ -152,9 +158,9 @@ public class IoTDBSubscriptionConsumerGroupIT extends AbstractSubscriptionDualIT
     // Setup subscription info list with expected results
     {
       final List<SubscriptionInfo> subscriptionInfoList = new ArrayList<>();
-      subscriptionInfoList.add(new SubscriptionInfo("c1", "cg1", Collections.singleton("topic1")));
-      subscriptionInfoList.add(new SubscriptionInfo("c2", "cg1", Collections.singleton("topic1")));
-      subscriptionInfoList.add(new SubscriptionInfo("c3", "cg1", Collections.singleton("topic1")));
+      subscriptionInfoList.add(new SubscriptionInfo("c1", "cg1", Collections.singleton(TOPIC_1)));
+      subscriptionInfoList.add(new SubscriptionInfo("c2", "cg1", Collections.singleton(TOPIC_1)));
+      subscriptionInfoList.add(new SubscriptionInfo("c3", "cg1", Collections.singleton(TOPIC_1)));
 
       final Map<String, String> expectedHeaderWithResult = new HashMap<>();
       expectedHeaderWithResult.put("count(root.cg1.topic1.s)", "100");
@@ -165,9 +171,9 @@ public class IoTDBSubscriptionConsumerGroupIT extends AbstractSubscriptionDualIT
     }
     {
       final List<SubscriptionInfo> subscriptionInfoList = new ArrayList<>();
-      subscriptionInfoList.add(new SubscriptionInfo("c1", "cg1", Collections.singleton("topic1")));
-      subscriptionInfoList.add(new SubscriptionInfo("c2", "cg2", Collections.singleton("topic1")));
-      subscriptionInfoList.add(new SubscriptionInfo("c3", "cg3", Collections.singleton("topic1")));
+      subscriptionInfoList.add(new SubscriptionInfo("c1", "cg1", Collections.singleton(TOPIC_1)));
+      subscriptionInfoList.add(new SubscriptionInfo("c2", "cg2", Collections.singleton(TOPIC_1)));
+      subscriptionInfoList.add(new SubscriptionInfo("c3", "cg3", Collections.singleton(TOPIC_1)));
 
       final Map<String, String> expectedHeaderWithResult = new HashMap<>();
       expectedHeaderWithResult.put("count(root.cg1.topic1.s)", "100");
@@ -180,10 +186,10 @@ public class IoTDBSubscriptionConsumerGroupIT extends AbstractSubscriptionDualIT
     }
     {
       final List<SubscriptionInfo> subscriptionInfoList = new ArrayList<>();
-      subscriptionInfoList.add(new SubscriptionInfo("c1", "cg1", Collections.singleton("topic1")));
+      subscriptionInfoList.add(new SubscriptionInfo("c1", "cg1", Collections.singleton(TOPIC_1)));
       subscriptionInfoList.add(
-          new SubscriptionInfo("c2", "cg1", new HashSet<>(Arrays.asList("topic1", "topic2"))));
-      subscriptionInfoList.add(new SubscriptionInfo("c3", "cg1", Collections.singleton("topic2")));
+          new SubscriptionInfo("c2", "cg1", new HashSet<>(Arrays.asList(TOPIC_1, TOPIC_2))));
+      subscriptionInfoList.add(new SubscriptionInfo("c3", "cg1", Collections.singleton(TOPIC_2)));
 
       final Map<String, String> expectedHeaderWithResult = new HashMap<>();
       expectedHeaderWithResult.put("count(root.cg1.topic1.s)", "100");
@@ -195,10 +201,10 @@ public class IoTDBSubscriptionConsumerGroupIT extends AbstractSubscriptionDualIT
     }
     {
       final List<SubscriptionInfo> subscriptionInfoList = new ArrayList<>();
-      subscriptionInfoList.add(new SubscriptionInfo("c1", "cg1", Collections.singleton("topic1")));
+      subscriptionInfoList.add(new SubscriptionInfo("c1", "cg1", Collections.singleton(TOPIC_1)));
       subscriptionInfoList.add(
-          new SubscriptionInfo("c2", "cg2", new HashSet<>(Arrays.asList("topic1", "topic2"))));
-      subscriptionInfoList.add(new SubscriptionInfo("c3", "cg3", Collections.singleton("topic2")));
+          new SubscriptionInfo("c2", "cg2", new HashSet<>(Arrays.asList(TOPIC_1, TOPIC_2))));
+      subscriptionInfoList.add(new SubscriptionInfo("c3", "cg3", Collections.singleton(TOPIC_2)));
 
       final Map<String, String> expectedHeaderWithResult = new HashMap<>();
       expectedHeaderWithResult.put("count(root.cg1.topic1.s)", "100");
@@ -212,11 +218,11 @@ public class IoTDBSubscriptionConsumerGroupIT extends AbstractSubscriptionDualIT
     }
     {
       final List<SubscriptionInfo> subscriptionInfoList = new ArrayList<>();
-      subscriptionInfoList.add(new SubscriptionInfo("c1", "cg1", Collections.singleton("topic1")));
+      subscriptionInfoList.add(new SubscriptionInfo("c1", "cg1", Collections.singleton(TOPIC_1)));
       subscriptionInfoList.add(
-          new SubscriptionInfo("c2", "cg2", new HashSet<>(Arrays.asList("topic1", "topic2"))));
-      subscriptionInfoList.add(new SubscriptionInfo("c3", "cg1", Collections.singleton("topic1")));
-      subscriptionInfoList.add(new SubscriptionInfo("c4", "cg2", Collections.singleton("topic2")));
+          new SubscriptionInfo("c2", "cg2", new HashSet<>(Arrays.asList(TOPIC_1, TOPIC_2))));
+      subscriptionInfoList.add(new SubscriptionInfo("c3", "cg1", Collections.singleton(TOPIC_1)));
+      subscriptionInfoList.add(new SubscriptionInfo("c4", "cg2", Collections.singleton(TOPIC_2)));
 
       final Map<String, String> expectedHeaderWithResult = new HashMap<>();
       expectedHeaderWithResult.put("count(root.cg1.topic1.s)", "100");
@@ -229,41 +235,50 @@ public class IoTDBSubscriptionConsumerGroupIT extends AbstractSubscriptionDualIT
     }
     {
       final List<SubscriptionInfo> subscriptionInfoList = new ArrayList<>();
-      subscriptionInfoList.add(new SubscriptionInfo("c1", "cg1", Collections.singleton("all")));
       subscriptionInfoList.add(
-          new SubscriptionInfo("c2", "cg2", new HashSet<>(Arrays.asList("topic1", "topic2"))));
-      subscriptionInfoList.add(new SubscriptionInfo("c3", "cg1", Collections.singleton("all")));
-      subscriptionInfoList.add(new SubscriptionInfo("c4", "cg2", Collections.singleton("topic2")));
+          new SubscriptionInfo("c1", "cg1", Collections.singleton(TOPIC_ALL_WITH_TSFILE)));
+      subscriptionInfoList.add(
+          new SubscriptionInfo("c2", "cg2", new HashSet<>(Arrays.asList(TOPIC_1, TOPIC_2))));
+      subscriptionInfoList.add(
+          new SubscriptionInfo("c3", "cg1", Collections.singleton(TOPIC_ALL_WITH_TSFILE)));
+      subscriptionInfoList.add(new SubscriptionInfo("c4", "cg2", Collections.singleton(TOPIC_2)));
 
       final Map<String, String> expectedHeaderWithResult = new HashMap<>();
-      expectedHeaderWithResult.put("count(root.cg1.topic1.s)", "100");
-      expectedHeaderWithResult.put("count(root.cg1.topic2.s)", "100");
+      expectedHeaderWithResult.put("count(root.cg1.topic1.s)", "200");
+      expectedHeaderWithResult.put("count(root.cg1.topic2.s)", "200");
       expectedHeaderWithResult.put("count(root.cg2.topic1.s)", "100");
       expectedHeaderWithResult.put("count(root.cg2.topic2.s)", "100");
       expectedHeaderWithResult.put("count(root.topic1.s)", "100");
       expectedHeaderWithResult.put("count(root.topic2.s)", "100");
 
-      __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_TS_FILE =
+      __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_ALL =
           new Pair<>(subscriptionInfoList, expectedHeaderWithResult);
     }
     {
       final List<SubscriptionInfo> subscriptionInfoList = new ArrayList<>();
-      subscriptionInfoList.add(new SubscriptionInfo("c1", "cg1", Collections.singleton("all")));
-      subscriptionInfoList.add(new SubscriptionInfo("c2", "cg1", Collections.singleton("all")));
-      subscriptionInfoList.add(new SubscriptionInfo("c3", "cg1", Collections.singleton("all")));
-      subscriptionInfoList.add(new SubscriptionInfo("c4", "cg1", Collections.singleton("all")));
-      subscriptionInfoList.add(new SubscriptionInfo("c5", "cg2", Collections.singleton("all")));
-      subscriptionInfoList.add(new SubscriptionInfo("c6", "cg2", Collections.singleton("all")));
+      subscriptionInfoList.add(
+          new SubscriptionInfo("c1", "cg1", Collections.singleton(TOPIC_ALL_WITH_TABLET)));
+      subscriptionInfoList.add(
+          new SubscriptionInfo("c2", "cg1", Collections.singleton(TOPIC_ALL_WITH_TABLET)));
+      subscriptionInfoList.add(
+          new SubscriptionInfo("c3", "cg1", Collections.singleton(TOPIC_ALL_WITH_TSFILE)));
+      subscriptionInfoList.add(
+          new SubscriptionInfo("c4", "cg1", Collections.singleton(TOPIC_ALL_WITH_TSFILE)));
+      subscriptionInfoList.add(
+          new SubscriptionInfo("c5", "cg2", Collections.singleton(TOPIC_ALL_WITH_TABLET)));
+      subscriptionInfoList.add(
+          new SubscriptionInfo("c6", "cg2", Collections.singleton(TOPIC_ALL_WITH_TSFILE)));
 
       final Map<String, String> expectedHeaderWithResult = new HashMap<>();
-      expectedHeaderWithResult.put("count(root.cg1.topic1.s)", "100");
-      expectedHeaderWithResult.put("count(root.cg1.topic2.s)", "100");
-      expectedHeaderWithResult.put("count(root.cg2.topic1.s)", "100");
-      expectedHeaderWithResult.put("count(root.cg2.topic2.s)", "100");
+      expectedHeaderWithResult.put("count(root.cg1.topic1.s)", "200");
+      expectedHeaderWithResult.put("count(root.cg1.topic2.s)", "200");
+      expectedHeaderWithResult.put("count(root.cg2.topic1.s)", "200");
+      expectedHeaderWithResult.put("count(root.cg2.topic2.s)", "200");
       expectedHeaderWithResult.put("count(root.topic1.s)", "100");
       expectedHeaderWithResult.put("count(root.topic2.s)", "100");
 
-      __6C_2CG_SUBSCRIBE_TS_FILE_TOPIC = new Pair<>(subscriptionInfoList, expectedHeaderWithResult);
+      __6C_2CG_SUBSCRIBE_ONE_TOPIC_WITH_ALL =
+          new Pair<>(subscriptionInfoList, expectedHeaderWithResult);
     }
   }
 
@@ -675,147 +690,144 @@ public class IoTDBSubscriptionConsumerGroupIT extends AbstractSubscriptionDualIT
         __4C_2CG_SUBSCRIBE_TWO_TOPIC.right);
   }
 
-  // ------------------------------------------------------ //
-  // 4 consumers, 2 consumer groups, 2 topics (with tsfile) //
-  // ------------------------------------------------------ //
+  // --------------------------------------------------------- //
+  // 4 consumers, 2 consumer groups, 2 topics (with topic all) //
+  // --------------------------------------------------------- //
 
   @Test
-  public void test4C2CGSubscribeTwoTopicWithTsFileHistoricalDataWithAsyncConnector()
-      throws Exception {
+  public void test4C2CGSubscribeTwoTopicWithAllHistoricalDataWithAsyncConnector() throws Exception {
     testSubscriptionHistoricalDataTemplate(
         ASYNC_CONNECTOR_ATTRIBUTES,
-        __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_TS_FILE.left,
-        __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_TS_FILE.right);
+        __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_ALL.left,
+        __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_ALL.right);
   }
 
   @Test
-  public void test4C2CGSubscribeTwoTopicWithTsFileHistoricalDataWithSyncConnector()
-      throws Exception {
+  public void test4C2CGSubscribeTwoTopicWithAllHistoricalDataWithSyncConnector() throws Exception {
     testSubscriptionHistoricalDataTemplate(
         SYNC_CONNECTOR_ATTRIBUTES,
-        __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_TS_FILE.left,
-        __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_TS_FILE.right);
+        __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_ALL.left,
+        __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_ALL.right);
   }
 
   @Test
-  public void test4C2CGSubscribeTwoTopicWithTsFileHistoricalDataWithLegacyConnector()
+  public void test4C2CGSubscribeTwoTopicWithAllHistoricalDataWithLegacyConnector()
       throws Exception {
     testSubscriptionHistoricalDataTemplate(
         LEGACY_CONNECTOR_ATTRIBUTES,
-        __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_TS_FILE.left,
-        __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_TS_FILE.right);
+        __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_ALL.left,
+        __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_ALL.right);
   }
 
   @Test
-  public void test4C2CGSubscribeTwoTopicWithTsFileHistoricalDataWithAirGapConnector()
+  public void test4C2CGSubscribeTwoTopicWithAllHistoricalDataWithAirGapConnector()
       throws Exception {
     testSubscriptionHistoricalDataTemplate(
         AIR_GAP_CONNECTOR_ATTRIBUTES,
-        __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_TS_FILE.left,
-        __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_TS_FILE.right);
+        __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_ALL.left,
+        __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_ALL.right);
   }
 
   @Test
-  public void test4C2CGSubscribeTwoTopicWithTsFileRealtimeDataWithAsyncConnector()
-      throws Exception {
+  public void test4C2CGSubscribeTwoTopicWithAllRealtimeDataWithAsyncConnector() throws Exception {
     testSubscriptionRealtimeDataTemplate(
         ASYNC_CONNECTOR_ATTRIBUTES,
-        __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_TS_FILE.left,
-        __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_TS_FILE.right);
+        __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_ALL.left,
+        __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_ALL.right);
   }
 
   @Test
-  public void test4C2CGSubscribeTwoTopicWithTsFileRealtimeDataWithSyncConnector() throws Exception {
+  public void test4C2CGSubscribeTwoTopicWithAllRealtimeDataWithSyncConnector() throws Exception {
     testSubscriptionRealtimeDataTemplate(
         SYNC_CONNECTOR_ATTRIBUTES,
-        __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_TS_FILE.left,
-        __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_TS_FILE.right);
+        __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_ALL.left,
+        __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_ALL.right);
   }
 
   @Test
-  public void test4C2CGSubscribeTwoTopicWithTsFileRealtimeDataWithLegacyConnector()
-      throws Exception {
+  public void test4C2CGSubscribeTwoTopicWithAllRealtimeDataWithLegacyConnector() throws Exception {
     testSubscriptionRealtimeDataTemplate(
         LEGACY_CONNECTOR_ATTRIBUTES,
-        __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_TS_FILE.left,
-        __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_TS_FILE.right);
+        __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_ALL.left,
+        __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_ALL.right);
   }
 
   @Test
-  public void test4C2CGSubscribeTwoTopicWithTsFileRealtimeDataWithAirGapConnector()
-      throws Exception {
+  public void test4C2CGSubscribeTwoTopicWithAllRealtimeDataWithAirGapConnector() throws Exception {
     testSubscriptionRealtimeDataTemplate(
         AIR_GAP_CONNECTOR_ATTRIBUTES,
-        __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_TS_FILE.left,
-        __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_TS_FILE.right);
+        __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_ALL.left,
+        __4C_2CG_SUBSCRIBE_TWO_TOPIC_WITH_ALL.right);
   }
 
-  // ------------------------------------------------ //
-  // 6 consumers, 2 consumer groups, 1 topic (tsfile) //
-  // ------------------------------------------------ //
+  // --------------------------------------------------- //
+  // 6 consumers, 2 consumer groups, 1 topic (topic all) //
+  // --------------------------------------------------- //
 
   @Test
-  public void test6C2CGSubscribeOneTsFileTopicHistoricalDataWithAsyncConnector() throws Exception {
+  public void test6C2CGSubscribeOneTopicWithAllHistoricalDataWithAsyncConnector() throws Exception {
     testSubscriptionHistoricalDataTemplate(
         ASYNC_CONNECTOR_ATTRIBUTES,
-        __6C_2CG_SUBSCRIBE_TS_FILE_TOPIC.left,
-        __6C_2CG_SUBSCRIBE_TS_FILE_TOPIC.right);
+        __6C_2CG_SUBSCRIBE_ONE_TOPIC_WITH_ALL.left,
+        __6C_2CG_SUBSCRIBE_ONE_TOPIC_WITH_ALL.right);
   }
 
   @Test
-  public void test6C2CGSubscribeOneTsFileTopicHistoricalDataWithSyncConnector() throws Exception {
+  public void test6C2CGSubscribeOneTopicWithAllHistoricalDataWithSyncConnector() throws Exception {
     testSubscriptionHistoricalDataTemplate(
         SYNC_CONNECTOR_ATTRIBUTES,
-        __6C_2CG_SUBSCRIBE_TS_FILE_TOPIC.left,
-        __6C_2CG_SUBSCRIBE_TS_FILE_TOPIC.right);
+        __6C_2CG_SUBSCRIBE_ONE_TOPIC_WITH_ALL.left,
+        __6C_2CG_SUBSCRIBE_ONE_TOPIC_WITH_ALL.right);
   }
 
   @Test
-  public void test6C2CGSubscribeOneTsFileTopicHistoricalDataWithLegacyConnector() throws Exception {
+  public void test6C2CGSubscribeOneTopicWithAllHistoricalDataWithLegacyConnector()
+      throws Exception {
     testSubscriptionHistoricalDataTemplate(
         LEGACY_CONNECTOR_ATTRIBUTES,
-        __6C_2CG_SUBSCRIBE_TS_FILE_TOPIC.left,
-        __6C_2CG_SUBSCRIBE_TS_FILE_TOPIC.right);
+        __6C_2CG_SUBSCRIBE_ONE_TOPIC_WITH_ALL.left,
+        __6C_2CG_SUBSCRIBE_ONE_TOPIC_WITH_ALL.right);
   }
 
   @Test
-  public void test6C2CGSubscribeOneTsFileTopicHistoricalDataWithAirGapConnector() throws Exception {
+  public void test6C2CGSubscribeOneTopicWithAllHistoricalDataWithAirGapConnector()
+      throws Exception {
     testSubscriptionHistoricalDataTemplate(
         AIR_GAP_CONNECTOR_ATTRIBUTES,
-        __6C_2CG_SUBSCRIBE_TS_FILE_TOPIC.left,
-        __6C_2CG_SUBSCRIBE_TS_FILE_TOPIC.right);
+        __6C_2CG_SUBSCRIBE_ONE_TOPIC_WITH_ALL.left,
+        __6C_2CG_SUBSCRIBE_ONE_TOPIC_WITH_ALL.right);
   }
 
   @Test
-  public void test6C2CGSubscribeOneTsFileTopicRealtimeDataWithAsyncConnector() throws Exception {
+  public void test6C2CGSubscribeOneTopicWithAllRealtimeDataWithAsyncConnector() throws Exception {
     testSubscriptionRealtimeDataTemplate(
         ASYNC_CONNECTOR_ATTRIBUTES,
-        __6C_2CG_SUBSCRIBE_TS_FILE_TOPIC.left,
-        __6C_2CG_SUBSCRIBE_TS_FILE_TOPIC.right);
+        __6C_2CG_SUBSCRIBE_ONE_TOPIC_WITH_ALL.left,
+        __6C_2CG_SUBSCRIBE_ONE_TOPIC_WITH_ALL.right);
   }
 
   @Test
-  public void test6C2CGSubscribeOneTsFileTopicRealtimeDataWithSyncConnector() throws Exception {
+  public void test6C2CGSubscribeOneTopicWithAllRealtimeDataWithSyncConnector() throws Exception {
     testSubscriptionRealtimeDataTemplate(
         SYNC_CONNECTOR_ATTRIBUTES,
-        __6C_2CG_SUBSCRIBE_TS_FILE_TOPIC.left,
-        __6C_2CG_SUBSCRIBE_TS_FILE_TOPIC.right);
+        __6C_2CG_SUBSCRIBE_ONE_TOPIC_WITH_ALL.left,
+        __6C_2CG_SUBSCRIBE_ONE_TOPIC_WITH_ALL.right);
   }
 
   @Test
-  public void test6C2CGSubscribeOneTsFileTopicRealtimeDataWithLegacyConnector() throws Exception {
+  public void test6C2CGSubscribeOneTopicWithAllRealtimeDataWithLegacyConnector() throws Exception {
     testSubscriptionRealtimeDataTemplate(
         LEGACY_CONNECTOR_ATTRIBUTES,
-        __6C_2CG_SUBSCRIBE_TS_FILE_TOPIC.left,
-        __6C_2CG_SUBSCRIBE_TS_FILE_TOPIC.right);
+        __6C_2CG_SUBSCRIBE_ONE_TOPIC_WITH_ALL.left,
+        __6C_2CG_SUBSCRIBE_ONE_TOPIC_WITH_ALL.right);
   }
 
   @Test
-  public void test6C2CGSubscribeOneTsFileTopicRealtimeDataWithAirGapConnector() throws Exception {
+  public void test6C2CGSubscribeOneTopicWithAllRealtimeDataWithAirGapConnector() throws Exception {
     testSubscriptionRealtimeDataTemplate(
         AIR_GAP_CONNECTOR_ATTRIBUTES,
-        __6C_2CG_SUBSCRIBE_TS_FILE_TOPIC.left,
-        __6C_2CG_SUBSCRIBE_TS_FILE_TOPIC.right);
+        __6C_2CG_SUBSCRIBE_ONE_TOPIC_WITH_ALL.left,
+        __6C_2CG_SUBSCRIBE_ONE_TOPIC_WITH_ALL.right);
   }
 
   /////////////////////////////// utility ///////////////////////////////
@@ -828,18 +840,29 @@ public class IoTDBSubscriptionConsumerGroupIT extends AbstractSubscriptionDualIT
       session.open();
       {
         final Properties config = new Properties();
+        config.put(TopicConstant.PATH_KEY, "root.topic1.s");
         config.put(TopicConstant.END_TIME_KEY, currentTime - 1);
-        session.createTopic("topic1", config);
+        config.put(TopicConstant.FORMAT_KEY, TopicConstant.FORMAT_SESSION_DATA_SETS_HANDLER_VALUE);
+        session.createTopic(TOPIC_1, config);
       }
       {
         final Properties config = new Properties();
+        config.put(TopicConstant.PATH_KEY, "root.topic2.s");
         config.put(TopicConstant.START_TIME_KEY, currentTime);
-        session.createTopic("topic2", config);
+        config.put(TopicConstant.FORMAT_KEY, TopicConstant.FORMAT_TS_FILE_HANDLER_VALUE);
+        session.createTopic(TOPIC_2, config);
       }
       {
         final Properties config = new Properties();
+        config.put(TopicConstant.PATH_KEY, "root.*.s");
         config.put(TopicConstant.FORMAT_KEY, TopicConstant.FORMAT_TS_FILE_HANDLER_VALUE);
-        session.createTopic("all", config);
+        session.createTopic(TOPIC_ALL_WITH_TSFILE, config);
+      }
+      {
+        final Properties config = new Properties();
+        config.put(TopicConstant.PATH_KEY, "root.*.s");
+        config.put(TopicConstant.FORMAT_KEY, TopicConstant.FORMAT_SESSION_DATA_SETS_HANDLER_VALUE);
+        session.createTopic(TOPIC_ALL_WITH_TABLET, config);
       }
     } catch (final Exception e) {
       e.printStackTrace();
@@ -852,10 +875,17 @@ public class IoTDBSubscriptionConsumerGroupIT extends AbstractSubscriptionDualIT
     try (final ISession session = senderEnv.getSessionConnection()) {
       for (int i = 0; i < 100; ++i) {
         session.executeNonQueryStatement(
-            String.format("insert into root.topic1(time, s) values (%s, 1)", i)); // topic1
+            String.format("insert into root.topic1(time, s, t) values (%s, 1, 2)", i));
+        session.executeNonQueryStatement(
+            String.format(
+                "insert into root.topic1(time, s, t) values (%s, 1, 2)", currentTime + i));
+      }
+      for (int i = 0; i < 100; ++i) {
+        session.executeNonQueryStatement(
+            String.format("insert into root.topic2(time, s, t) values (%s, 3, 4)", i));
         session.executeNonQueryStatement(
             String.format(
-                "insert into root.topic2(time, s) values (%s, 1)", currentTime + i)); // topic2
+                "insert into root.topic2(time, s, t) values (%s, 3, 4)", currentTime + i));
       }
       session.executeNonQueryStatement("flush");
     } catch (final Exception e) {
@@ -873,6 +903,7 @@ public class IoTDBSubscriptionConsumerGroupIT extends AbstractSubscriptionDualIT
 
       extractorAttributes.put("inclusion", "data.insert");
       extractorAttributes.put("inclusion.exclusion", "data.delete");
+      extractorAttributes.put("path", "root.topic1.s");
       extractorAttributes.put("end-time", String.valueOf(currentTime - 1));
 
       final TSStatus status =
@@ -893,6 +924,7 @@ public class IoTDBSubscriptionConsumerGroupIT extends AbstractSubscriptionDualIT
 
       extractorAttributes.put("inclusion", "data.insert");
       extractorAttributes.put("inclusion.exclusion", "data.delete");
+      extractorAttributes.put("path", "root.topic2.s");
       extractorAttributes.put("start-time", String.valueOf(currentTime));
 
       final TSStatus status =
@@ -954,7 +986,7 @@ public class IoTDBSubscriptionConsumerGroupIT extends AbstractSubscriptionDualIT
                                 while (dataSet.hasNext()) {
                                   final RowRecord record = dataSet.next();
                                   if (!insertRowRecordEnrichedByConsumerGroupId(
-                                      columnNameList, record, consumerGroupId)) {
+                                      columnNameList, record.getTimestamp(), consumerGroupId)) {
                                     receiverCrashed.set(true);
                                     throw new RuntimeException("detect receiver crashed");
                                   }
@@ -975,12 +1007,12 @@ public class IoTDBSubscriptionConsumerGroupIT extends AbstractSubscriptionDualIT
                                             null));
                                 while (dataSet.hasNext()) {
                                   final RowRecord record = dataSet.next();
-                                  if (!insertRowRecordEnrichedByConsumerGroupId(
-                                      dataSet.getPaths().get(0).toString(),
-                                      record,
-                                      consumerGroupId)) {
-                                    receiverCrashed.set(true);
-                                    throw new RuntimeException("detect receiver crashed");
+                                  for (final Path path : dataSet.getPaths()) {
+                                    if (!insertRowRecordEnrichedByConsumerGroupId(
+                                        path.toString(), record.getTimestamp(), consumerGroupId)) {
+                                      receiverCrashed.set(true);
+                                      throw new RuntimeException("detect receiver crashed");
+                                    }
                                   }
                                 }
                               }
@@ -1024,9 +1056,9 @@ public class IoTDBSubscriptionConsumerGroupIT extends AbstractSubscriptionDualIT
               // potential stuck
               if (System.currentTimeMillis() - currentTime[0] > 60_000L) {
                 for (final DataNodeWrapper wrapper : senderEnv.getDataNodeWrapperList()) {
-                  wrapper.executeJstack();
-                  // wrapper.executeJstack(String.format("%s_%s", testName.getMethodName(),
-                  // currentTime[0]));
+                  // wrapper.executeJstack();
+                  wrapper.executeJstack(
+                      String.format("%s_%s", testName.getMethodName(), currentTime[0]));
                 }
                 currentTime[0] = System.currentTimeMillis();
               }
@@ -1050,39 +1082,47 @@ public class IoTDBSubscriptionConsumerGroupIT extends AbstractSubscriptionDualIT
    * @return false -> receiver crashed
    */
   private boolean insertRowRecordEnrichedByConsumerGroupId(
-      final List<String> columnNameList, final RowRecord record, final String consumerGroupId)
+      final List<String> columnNameList, final long timestamp, final String consumerGroupId)
       throws Exception {
-    if (columnNameList.size() != 2) {
+    final int columnSize = columnNameList.size();
+    if (columnSize <= 1) { // only with time column
       LOGGER.warn("unexpected column name list: {}", columnNameList);
       throw new Exception("unexpected column name list");
     }
-    final String columnName = columnNameList.get(1);
-    return insertRowRecordEnrichedByConsumerGroupId(columnName, record, consumerGroupId);
+
+    for (int columnIndex = 1; columnIndex < columnSize; ++columnIndex) {
+      final String columnName = columnNameList.get(columnIndex);
+      if (!insertRowRecordEnrichedByConsumerGroupId(columnName, timestamp, consumerGroupId)) {
+        return false;
+      }
+    }
+
+    return true;
   }
 
   /**
    * @return false -> receiver crashed
    */
   private boolean insertRowRecordEnrichedByConsumerGroupId(
-      final String columnName, final RowRecord record, final String consumerGroupId)
+      final String columnName, final long timestamp, final String consumerGroupId)
       throws Exception {
     if ("root.topic1.s".equals(columnName)) {
       final String sql =
           String.format(
-              "insert into root.%s.topic1(time, s) values (%s, 1)",
-              consumerGroupId, record.getTimestamp());
+              "insert into root.%s.topic1(time, s) values (%s, 1)", consumerGroupId, timestamp);
       LOGGER.info(sql);
       return TestUtils.tryExecuteNonQueryWithRetry(receiverEnv, sql);
-    } else if ("root.topic2.s".equals(columnName)) {
+    }
+
+    if ("root.topic2.s".equals(columnName)) {
       final String sql =
           String.format(
-              "insert into root.%s.topic2(time, s) values (%s, 1)",
-              consumerGroupId, record.getTimestamp());
+              "insert into root.%s.topic2(time, s) values (%s, 3)", consumerGroupId, timestamp);
       LOGGER.info(sql);
       return TestUtils.tryExecuteNonQueryWithRetry(receiverEnv, sql);
-    } else {
-      LOGGER.warn("unexpected column name: {}", columnName);
-      throw new Exception("unexpected column name");
     }
+
+    LOGGER.warn("unexpected column name: {}", columnName);
+    throw new Exception("unexpected column name");
   }
 }
diff --git a/integration-test/src/test/java/org/apache/iotdb/subscription/it/dual/IoTDBSubscriptionTopicIT.java b/integration-test/src/test/java/org/apache/iotdb/subscription/it/dual/IoTDBSubscriptionTopicIT.java
index d4aee45c482..2f9cb124311 100644
--- a/integration-test/src/test/java/org/apache/iotdb/subscription/it/dual/IoTDBSubscriptionTopicIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/subscription/it/dual/IoTDBSubscriptionTopicIT.java
@@ -30,7 +30,6 @@ import org.apache.iotdb.it.framework.IoTDBTestRunner;
 import org.apache.iotdb.itbase.category.MultiClusterIT2Subscription;
 import org.apache.iotdb.rpc.RpcUtils;
 import org.apache.iotdb.rpc.subscription.config.TopicConstant;
-import org.apache.iotdb.rpc.subscription.exception.SubscriptionRuntimeCriticalException;
 import org.apache.iotdb.session.subscription.SubscriptionSession;
 import org.apache.iotdb.session.subscription.consumer.SubscriptionPullConsumer;
 import org.apache.iotdb.session.subscription.payload.SubscriptionMessage;
@@ -75,7 +74,7 @@ public class IoTDBSubscriptionTopicIT extends AbstractSubscriptionDualIT {
   protected void setUpConfig() {
     super.setUpConfig();
 
-    // Shorten heartbeat and sync interval to avoid timeout of query mode test
+    // Shorten heartbeat and sync interval to avoid timeout of snapshot mode test
     senderEnv
         .getConfig()
         .getCommonConfig()
@@ -531,31 +530,7 @@ public class IoTDBSubscriptionTopicIT extends AbstractSubscriptionDualIT {
   }
 
   @Test
-  public void testTopicInvalidPathConfig() throws Exception {
-    // Test invalid path when using tsfile format
-    // NOTE: Delete this test after the restriction "on path/time range/processor when subscribing
-    // to tsfile" is removed.
-    final Properties config = new Properties();
-    config.put(TopicConstant.FORMAT_KEY, TopicConstant.FORMAT_TS_FILE_HANDLER_VALUE);
-    config.put(TopicConstant.PATH_KEY, "root.db.*.s");
-    testTopicInvalidRuntimeConfigTemplate("topic9", config);
-  }
-
-  @Test
-  public void testTopicInvalidProcessorConfig() throws Exception {
-    // Test invalid processor when using tsfile format
-    // NOTE: Delete this test after the restriction "on path/time range/processor when subscribing
-    // to tsfile" is removed.
-    final Properties config = new Properties();
-    config.put(TopicConstant.FORMAT_KEY, TopicConstant.FORMAT_TS_FILE_HANDLER_VALUE);
-    config.put("processor", "tumbling-time-sampling-processor");
-    config.put("processor.tumbling-time.interval-seconds", "1");
-    config.put("processor.down-sampling.split-file", "true");
-    testTopicInvalidRuntimeConfigTemplate("topic10", config);
-  }
-
-  @Test
-  public void testTopicWithQueryMode() throws Exception {
+  public void testTopicWithSnapshotMode() throws Exception {
     // Insert some historical data
     try (final ISession session = senderEnv.getSessionConnection()) {
       for (int i = 0; i < 100; ++i) {
@@ -576,7 +551,7 @@ public class IoTDBSubscriptionTopicIT extends AbstractSubscriptionDualIT {
       session.open();
       final Properties config = new Properties();
       config.put(TopicConstant.FORMAT_KEY, TopicConstant.FORMAT_TS_FILE_HANDLER_VALUE);
-      config.put(TopicConstant.MODE_KEY, TopicConstant.MODE_QUERY_VALUE);
+      config.put(TopicConstant.MODE_KEY, TopicConstant.MODE_SNAPSHOT_VALUE);
       session.createTopic(topicName, config);
     } catch (final Exception e) {
       e.printStackTrace();
@@ -680,7 +655,7 @@ public class IoTDBSubscriptionTopicIT extends AbstractSubscriptionDualIT {
     try (final SubscriptionSession session = new SubscriptionSession(host, port)) {
       session.open();
       final Properties config = new Properties();
-      config.put(TopicConstant.LOOSE_RANGE_KEY, TopicConstant.LOOSE_RANGE_TIME_AND_PATH_VALUE);
+      config.put(TopicConstant.LOOSE_RANGE_KEY, TopicConstant.LOOSE_RANGE_ALL_VALUE);
       config.put(TopicConstant.PATH_KEY, "root.db.d1.at1");
       config.put(TopicConstant.START_TIME_KEY, "1500");
       config.put(TopicConstant.END_TIME_KEY, "2500");
@@ -693,7 +668,7 @@ public class IoTDBSubscriptionTopicIT extends AbstractSubscriptionDualIT {
 
     final AtomicBoolean dataPrepared = new AtomicBoolean(false);
     final AtomicBoolean topicSubscribed = new AtomicBoolean(false);
-    final AtomicBoolean result = new AtomicBoolean(false);
+    final AtomicBoolean finished = new AtomicBoolean(false);
     final List<Thread> threads = new ArrayList<>();
 
     // Subscribe on sender
@@ -712,7 +687,7 @@ public class IoTDBSubscriptionTopicIT extends AbstractSubscriptionDualIT {
                 consumer.open();
                 consumer.subscribe(topicName);
                 topicSubscribed.set(true);
-                while (!result.get()) {
+                while (!finished.get()) {
                   LockSupport.parkNanos(IoTDBSubscriptionITConstant.SLEEP_NS); // wait some time
                   if (dataPrepared.get()) {
                     final List<SubscriptionMessage> messages =
@@ -781,105 +756,7 @@ public class IoTDBSubscriptionTopicIT extends AbstractSubscriptionDualIT {
                   }));
     }
 
-    result.set(true);
-    for (final Thread thread : threads) {
-      thread.join();
-    }
-  }
-
-  private void testTopicInvalidRuntimeConfigTemplate(
-      final String topicName, final Properties config) throws Exception {
-    // Create topic
-    final String host = senderEnv.getIP();
-    final int port = Integer.parseInt(senderEnv.getPort());
-    try (final SubscriptionSession session = new SubscriptionSession(host, port)) {
-      session.open();
-      session.createTopic(topicName, config);
-    } catch (final Exception e) {
-      e.printStackTrace();
-      fail(e.getMessage());
-    }
-    assertTopicCount(1);
-
-    final AtomicBoolean dataPrepared = new AtomicBoolean(false);
-    final AtomicBoolean topicSubscribed = new AtomicBoolean(false);
-    final AtomicBoolean result = new AtomicBoolean(false);
-    final List<Thread> threads = new ArrayList<>();
-
-    // Subscribe on sender
-    threads.add(
-        new Thread(
-            () -> {
-              final AtomicInteger retryCount = new AtomicInteger();
-              final int maxRetryTimes = 32;
-              try (final SubscriptionPullConsumer consumer =
-                  new SubscriptionPullConsumer.Builder()
-                      .host(host)
-                      .port(port)
-                      .consumerId("c1")
-                      .consumerGroupId("cg1")
-                      .autoCommit(false)
-                      .fileSaveDir(System.getProperty("java.io.tmpdir")) // hack for license check
-                      .buildPullConsumer()) {
-                consumer.open();
-                consumer.subscribe(topicName);
-                topicSubscribed.set(true);
-                while (retryCount.getAndIncrement() < maxRetryTimes) {
-                  LockSupport.parkNanos(IoTDBSubscriptionITConstant.SLEEP_NS); // wait some time
-                  if (dataPrepared.get()) {
-                    final List<SubscriptionMessage> messages =
-                        consumer.poll(IoTDBSubscriptionITConstant.POLL_TIMEOUT_MS);
-                    consumer.commitSync(messages);
-                  }
-                }
-                consumer.unsubscribe(topicName);
-              } catch (final SubscriptionRuntimeCriticalException e) {
-                result.set(true);
-              } catch (final Exception e) {
-                e.printStackTrace();
-                // Avoid failure
-              } finally {
-                LOGGER.info("consumer exiting...");
-              }
-            },
-            String.format("%s - consumer", testName.getMethodName())));
-
-    // Insert some realtime data on sender
-    threads.add(
-        new Thread(
-            () -> {
-              while (!topicSubscribed.get()) {
-                LockSupport.parkNanos(IoTDBSubscriptionITConstant.SLEEP_NS); // wait some time
-              }
-              try (final ISession session = senderEnv.getSessionConnection()) {
-                for (int i = 0; i < 100; ++i) {
-                  session.executeNonQueryStatement(
-                      String.format("insert into root.db.d1(time, s) values (%s, 1)", i));
-                }
-                for (int i = 0; i < 100; ++i) {
-                  session.executeNonQueryStatement(
-                      String.format("insert into root.db.d2(time, s) values (%s, 1)", i));
-                }
-                for (int i = 0; i < 100; ++i) {
-                  session.executeNonQueryStatement(
-                      String.format("insert into root.db.d3(time, t) values (%s, 1)", i));
-                }
-                session.executeNonQueryStatement("flush");
-              } catch (final Exception e) {
-                e.printStackTrace();
-                fail(e.getMessage());
-              }
-              dataPrepared.set(true);
-            },
-            String.format("%s - data inserter", testName.getMethodName())));
-
-    for (final Thread thread : threads) {
-      thread.start();
-    }
-
-    // The expected SubscriptionRuntimeCriticalException was not thrown if result is false
-    AWAIT.untilTrue(result);
-
+    finished.set(true);
     for (final Thread thread : threads) {
       thread.join();
     }
diff --git a/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/subscription/config/TopicConfig.java b/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/subscription/config/TopicConfig.java
index 6dc42ed634a..2509213446e 100644
--- a/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/subscription/config/TopicConfig.java
+++ b/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/subscription/config/TopicConfig.java
@@ -33,6 +33,9 @@ import java.util.Map;
 import java.util.Set;
 import java.util.stream.Collectors;
 
+import static org.apache.iotdb.rpc.subscription.config.TopicConstant.MODE_LIVE_VALUE;
+import static org.apache.iotdb.rpc.subscription.config.TopicConstant.MODE_SNAPSHOT_VALUE;
+
 public class TopicConfig extends PipeParameters {
 
   public TopicConfig() {
@@ -48,10 +51,10 @@ public class TopicConfig extends PipeParameters {
   private static final Map<String, String> REALTIME_STREAM_MODE_CONFIG =
       Collections.singletonMap("realtime.mode", "stream");
 
-  private static final Map<String, String> QUERY_MODE_CONFIG =
-      Collections.singletonMap("mode", "query");
-  private static final Map<String, String> SUBSCRIBE_MODE_CONFIG =
-      Collections.singletonMap("mode", "subscribe");
+  private static final Map<String, String> SNAPSHOT_MODE_CONFIG =
+      Collections.singletonMap("mode", MODE_SNAPSHOT_VALUE);
+  private static final Map<String, String> LIVE_MODE_CONFIG =
+      Collections.singletonMap("mode", MODE_LIVE_VALUE);
 
   private static final Set<String> LOOSE_RANGE_KEY_SET =
       Collections.unmodifiableSet(
@@ -91,7 +94,7 @@ public class TopicConfig extends PipeParameters {
     // parse start time
     final String startTime =
         attributes.getOrDefault(TopicConstant.START_TIME_KEY, String.valueOf(Long.MIN_VALUE));
-    if (TopicConstant.NOW_TIME_VALUE.equals(startTime)) {
+    if (TopicConstant.NOW_TIME_VALUE.equalsIgnoreCase(startTime)) {
       attributesWithTimeRange.put(TopicConstant.START_TIME_KEY, String.valueOf(creationTime));
     } else {
       attributesWithTimeRange.put(TopicConstant.START_TIME_KEY, startTime);
@@ -100,7 +103,7 @@ public class TopicConfig extends PipeParameters {
     // parse end time
     final String endTime =
         attributes.getOrDefault(TopicConstant.END_TIME_KEY, String.valueOf(Long.MAX_VALUE));
-    if (TopicConstant.NOW_TIME_VALUE.equals(endTime)) {
+    if (TopicConstant.NOW_TIME_VALUE.equalsIgnoreCase(endTime)) {
       attributesWithTimeRange.put(TopicConstant.END_TIME_KEY, String.valueOf(creationTime));
     } else {
       attributesWithTimeRange.put(TopicConstant.END_TIME_KEY, endTime);
@@ -110,17 +113,17 @@ public class TopicConfig extends PipeParameters {
   }
 
   public Map<String, String> getAttributesWithRealtimeMode() {
-    return TopicConstant.FORMAT_TS_FILE_HANDLER_VALUE.equals(
+    return TopicConstant.FORMAT_TS_FILE_HANDLER_VALUE.equalsIgnoreCase(
             attributes.getOrDefault(TopicConstant.FORMAT_KEY, TopicConstant.FORMAT_DEFAULT_VALUE))
         ? REALTIME_BATCH_MODE_CONFIG
         : REALTIME_STREAM_MODE_CONFIG;
   }
 
   public Map<String, String> getAttributesWithSourceMode() {
-    return TopicConstant.MODE_QUERY_VALUE.equals(
+    return MODE_SNAPSHOT_VALUE.equalsIgnoreCase(
             attributes.getOrDefault(TopicConstant.MODE_KEY, TopicConstant.MODE_DEFAULT_VALUE))
-        ? QUERY_MODE_CONFIG
-        : SUBSCRIBE_MODE_CONFIG;
+        ? SNAPSHOT_MODE_CONFIG
+        : LIVE_MODE_CONFIG;
   }
 
   public Map<String, String> getAttributesWithSourceLooseRange() {
diff --git a/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/subscription/config/TopicConstant.java b/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/subscription/config/TopicConstant.java
index a3226c1d640..d159df2983c 100644
--- a/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/subscription/config/TopicConstant.java
+++ b/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/subscription/config/TopicConstant.java
@@ -31,9 +31,9 @@ public class TopicConstant {
   public static final String NOW_TIME_VALUE = "now";
 
   public static final String MODE_KEY = "mode";
-  public static final String MODE_SUBSCRIBE_VALUE = "subscribe";
-  public static final String MODE_QUERY_VALUE = "query";
-  public static final String MODE_DEFAULT_VALUE = MODE_SUBSCRIBE_VALUE;
+  public static final String MODE_LIVE_VALUE = "live";
+  public static final String MODE_SNAPSHOT_VALUE = "snapshot";
+  public static final String MODE_DEFAULT_VALUE = MODE_LIVE_VALUE;
 
   public static final String FORMAT_KEY = "format";
   public static final String FORMAT_SESSION_DATA_SETS_HANDLER_VALUE = "SessionDataSetsHandler";
@@ -43,7 +43,7 @@ public class TopicConstant {
   public static final String LOOSE_RANGE_KEY = "loose-range";
   public static final String LOOSE_RANGE_TIME_VALUE = "time";
   public static final String LOOSE_RANGE_PATH_VALUE = "path";
-  public static final String LOOSE_RANGE_TIME_AND_PATH_VALUE = "time,path";
+  public static final String LOOSE_RANGE_ALL_VALUE = "all";
   public static final String LOOSE_RANGE_DEFAULT_VALUE = "";
 
   private TopicConstant() {
diff --git a/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/subscription/payload/poll/SubscriptionCommitContext.java b/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/subscription/payload/poll/SubscriptionCommitContext.java
index 72292bf66b7..e2bf809d32c 100644
--- a/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/subscription/payload/poll/SubscriptionCommitContext.java
+++ b/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/subscription/payload/poll/SubscriptionCommitContext.java
@@ -40,6 +40,8 @@ public class SubscriptionCommitContext implements Comparable<SubscriptionCommitC
 
   private final long commitId;
 
+  public static final long INVALID_COMMIT_ID = -1;
+
   public SubscriptionCommitContext(
       final int dataNodeId,
       final int rebootTimes,
diff --git a/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/subscription/payload/poll/TabletsPayload.java b/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/subscription/payload/poll/TabletsPayload.java
index c0087fd3679..5b5bb8ade91 100644
--- a/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/subscription/payload/poll/TabletsPayload.java
+++ b/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/subscription/payload/poll/TabletsPayload.java
@@ -33,14 +33,10 @@ public class TabletsPayload implements SubscriptionPollPayload {
 
   protected transient List<Tablet> tablets = new ArrayList<>();
 
-  // Pure in-memory object, not involved in serialization and deserialization.
-  protected transient long calculatedTabletsSizeInBytes;
-
   public TabletsPayload() {}
 
-  public TabletsPayload(final List<Tablet> tablets, final long calculatedTabletsSizeInBytes) {
+  public TabletsPayload(final List<Tablet> tablets) {
     this.tablets = tablets;
-    this.calculatedTabletsSizeInBytes = calculatedTabletsSizeInBytes;
   }
 
   public List<Tablet> getTablets() {
@@ -85,8 +81,6 @@ public class TabletsPayload implements SubscriptionPollPayload {
 
   @Override
   public String toString() {
-    return "TabletsPayload{calculatedTabletsSizeInBytes="
-        + (calculatedTabletsSizeInBytes == 0 ? "<unknown>" : calculatedTabletsSizeInBytes)
-        + "}";
+    return "TabletsPayload{size of tablets=" + tablets.size() + "}";
   }
 }
diff --git a/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/subscription/payload/response/PipeSubscribeSubscribeResp.java b/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/subscription/payload/response/PipeSubscribeSubscribeResp.java
index 1d1571b0122..e12d350bda1 100644
--- a/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/subscription/payload/response/PipeSubscribeSubscribeResp.java
+++ b/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/subscription/payload/response/PipeSubscribeSubscribeResp.java
@@ -20,6 +20,7 @@
 package org.apache.iotdb.rpc.subscription.payload.response;
 
 import org.apache.iotdb.common.rpc.thrift.TSStatus;
+import org.apache.iotdb.rpc.subscription.config.TopicConfig;
 import org.apache.iotdb.service.rpc.thrift.TPipeSubscribeResp;
 
 import org.apache.tsfile.utils.PublicBAOS;
@@ -29,16 +30,16 @@ import java.io.DataOutputStream;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.Collections;
-import java.util.HashSet;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Objects;
-import java.util.Set;
 
 public class PipeSubscribeSubscribeResp extends TPipeSubscribeResp {
 
-  private transient Set<String> topicNames = new HashSet<>(); // subscribed topic names
+  private transient Map<String, TopicConfig> topics = new HashMap<>(); // subscribed topics
 
-  public Set<String> getTopicNames() {
-    return topicNames;
+  public Map<String, TopicConfig> getTopics() {
+    return topics;
   }
 
   /////////////////////////////// Thrift ///////////////////////////////
@@ -60,7 +61,7 @@ public class PipeSubscribeSubscribeResp extends TPipeSubscribeResp {
    * server.
    */
   public static PipeSubscribeSubscribeResp toTPipeSubscribeResp(
-      final TSStatus status, final Set<String> topicNames) throws IOException {
+      final TSStatus status, final Map<String, TopicConfig> topics) throws IOException {
     final PipeSubscribeSubscribeResp resp = new PipeSubscribeSubscribeResp();
 
     resp.status = status;
@@ -69,7 +70,11 @@ public class PipeSubscribeSubscribeResp extends TPipeSubscribeResp {
 
     try (final PublicBAOS byteArrayOutputStream = new PublicBAOS();
         final DataOutputStream outputStream = new DataOutputStream(byteArrayOutputStream)) {
-      ReadWriteIOUtils.writeObjectSet(topicNames, outputStream);
+      ReadWriteIOUtils.write(topics.size(), outputStream);
+      for (final Map.Entry<String, TopicConfig> entry : topics.entrySet()) {
+        ReadWriteIOUtils.write(entry.getKey(), outputStream);
+        entry.getValue().serialize(outputStream);
+      }
       resp.body =
           Collections.singletonList(
               ByteBuffer.wrap(byteArrayOutputStream.getBuf(), 0, byteArrayOutputStream.size()));
@@ -86,7 +91,14 @@ public class PipeSubscribeSubscribeResp extends TPipeSubscribeResp {
     if (Objects.nonNull(subscribeResp.body)) {
       for (final ByteBuffer byteBuffer : subscribeResp.body) {
         if (Objects.nonNull(byteBuffer) && byteBuffer.hasRemaining()) {
-          resp.topicNames = ReadWriteIOUtils.readObjectSet(byteBuffer);
+          final int size = ReadWriteIOUtils.readInt(byteBuffer);
+          final Map<String, TopicConfig> topics = new HashMap<>();
+          for (int i = 0; i < size; i++) {
+            final String topicName = ReadWriteIOUtils.readString(byteBuffer);
+            final TopicConfig topicConfig = TopicConfig.deserialize(byteBuffer);
+            topics.put(topicName, topicConfig);
+          }
+          resp.topics = topics;
           break;
         }
       }
@@ -110,7 +122,7 @@ public class PipeSubscribeSubscribeResp extends TPipeSubscribeResp {
       return false;
     }
     final PipeSubscribeSubscribeResp that = (PipeSubscribeSubscribeResp) obj;
-    return Objects.equals(this.topicNames, that.topicNames)
+    return Objects.equals(this.topics, that.topics)
         && Objects.equals(this.status, that.status)
         && this.version == that.version
         && this.type == that.type
@@ -119,6 +131,6 @@ public class PipeSubscribeSubscribeResp extends TPipeSubscribeResp {
 
   @Override
   public int hashCode() {
-    return Objects.hash(topicNames, status, version, type, body);
+    return Objects.hash(topics, status, version, type, body);
   }
 }
diff --git a/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/subscription/payload/response/PipeSubscribeUnsubscribeResp.java b/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/subscription/payload/response/PipeSubscribeUnsubscribeResp.java
index e5d8ccf69cf..a6add300611 100644
--- a/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/subscription/payload/response/PipeSubscribeUnsubscribeResp.java
+++ b/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/subscription/payload/response/PipeSubscribeUnsubscribeResp.java
@@ -20,6 +20,7 @@
 package org.apache.iotdb.rpc.subscription.payload.response;
 
 import org.apache.iotdb.common.rpc.thrift.TSStatus;
+import org.apache.iotdb.rpc.subscription.config.TopicConfig;
 import org.apache.iotdb.service.rpc.thrift.TPipeSubscribeResp;
 
 import org.apache.tsfile.utils.PublicBAOS;
@@ -29,16 +30,16 @@ import java.io.DataOutputStream;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.Collections;
-import java.util.HashSet;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Objects;
-import java.util.Set;
 
 public class PipeSubscribeUnsubscribeResp extends TPipeSubscribeResp {
 
-  private transient Set<String> topicNames = new HashSet<>(); // subscribed topic names
+  private transient Map<String, TopicConfig> topics = new HashMap<>(); // subscribed topics
 
-  public Set<String> getTopicNames() {
-    return topicNames;
+  public Map<String, TopicConfig> getTopics() {
+    return topics;
   }
 
   /////////////////////////////// Thrift ///////////////////////////////
@@ -60,7 +61,7 @@ public class PipeSubscribeUnsubscribeResp extends TPipeSubscribeResp {
    * subscription server.
    */
   public static PipeSubscribeUnsubscribeResp toTPipeSubscribeResp(
-      final TSStatus status, final Set<String> topicNames) throws IOException {
+      final TSStatus status, final Map<String, TopicConfig> topics) throws IOException {
     final PipeSubscribeUnsubscribeResp resp = new PipeSubscribeUnsubscribeResp();
 
     resp.status = status;
@@ -69,7 +70,11 @@ public class PipeSubscribeUnsubscribeResp extends TPipeSubscribeResp {
 
     try (final PublicBAOS byteArrayOutputStream = new PublicBAOS();
         final DataOutputStream outputStream = new DataOutputStream(byteArrayOutputStream)) {
-      ReadWriteIOUtils.writeObjectSet(topicNames, outputStream);
+      ReadWriteIOUtils.write(topics.size(), outputStream);
+      for (final Map.Entry<String, TopicConfig> entry : topics.entrySet()) {
+        ReadWriteIOUtils.write(entry.getKey(), outputStream);
+        entry.getValue().serialize(outputStream);
+      }
       resp.body =
           Collections.singletonList(
               ByteBuffer.wrap(byteArrayOutputStream.getBuf(), 0, byteArrayOutputStream.size()));
@@ -86,7 +91,14 @@ public class PipeSubscribeUnsubscribeResp extends TPipeSubscribeResp {
     if (Objects.nonNull(unsubscribeResp.body)) {
       for (final ByteBuffer byteBuffer : unsubscribeResp.body) {
         if (Objects.nonNull(byteBuffer) && byteBuffer.hasRemaining()) {
-          resp.topicNames = ReadWriteIOUtils.readObjectSet(byteBuffer);
+          final int size = ReadWriteIOUtils.readInt(byteBuffer);
+          final Map<String, TopicConfig> topics = new HashMap<>();
+          for (int i = 0; i < size; i++) {
+            final String topicName = ReadWriteIOUtils.readString(byteBuffer);
+            final TopicConfig topicConfig = TopicConfig.deserialize(byteBuffer);
+            topics.put(topicName, topicConfig);
+          }
+          resp.topics = topics;
           break;
         }
       }
@@ -110,7 +122,7 @@ public class PipeSubscribeUnsubscribeResp extends TPipeSubscribeResp {
       return false;
     }
     final PipeSubscribeUnsubscribeResp that = (PipeSubscribeUnsubscribeResp) obj;
-    return Objects.equals(this.topicNames, that.topicNames)
+    return Objects.equals(this.topics, that.topics)
         && Objects.equals(this.status, that.status)
         && this.version == that.version
         && this.type == that.type
@@ -119,6 +131,6 @@ public class PipeSubscribeUnsubscribeResp extends TPipeSubscribeResp {
 
   @Override
   public int hashCode() {
-    return Objects.hash(topicNames, status, version, type, body);
+    return Objects.hash(topics, status, version, type, body);
   }
 }
diff --git a/iotdb-client/session/src/main/java/org/apache/iotdb/session/subscription/consumer/SubscriptionConsumer.java b/iotdb-client/session/src/main/java/org/apache/iotdb/session/subscription/consumer/SubscriptionConsumer.java
index 410348c991b..d54ed406774 100644
--- a/iotdb-client/session/src/main/java/org/apache/iotdb/session/subscription/consumer/SubscriptionConsumer.java
+++ b/iotdb-client/session/src/main/java/org/apache/iotdb/session/subscription/consumer/SubscriptionConsumer.java
@@ -22,6 +22,7 @@ package org.apache.iotdb.session.subscription.consumer;
 import org.apache.iotdb.common.rpc.thrift.TEndPoint;
 import org.apache.iotdb.isession.SessionConfig;
 import org.apache.iotdb.rpc.subscription.config.ConsumerConstant;
+import org.apache.iotdb.rpc.subscription.config.TopicConfig;
 import org.apache.iotdb.rpc.subscription.exception.SubscriptionConnectionException;
 import org.apache.iotdb.rpc.subscription.exception.SubscriptionException;
 import org.apache.iotdb.rpc.subscription.exception.SubscriptionRuntimeCriticalException;
@@ -74,6 +75,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.locks.LockSupport;
 import java.util.stream.Collectors;
 
+import static org.apache.iotdb.rpc.subscription.config.TopicConstant.MODE_SNAPSHOT_VALUE;
+
 abstract class SubscriptionConsumer implements AutoCloseable {
 
   private static final Logger LOGGER = LoggerFactory.getLogger(SubscriptionConsumer.class);
@@ -92,11 +95,19 @@ abstract class SubscriptionConsumer implements AutoCloseable {
   private final SubscriptionProviders providers;
 
   private final AtomicBoolean isClosed = new AtomicBoolean(true);
+  // This variable indicates whether the consumer has ever been closed.
+  private final AtomicBoolean isReleased = new AtomicBoolean(false);
 
   private final String fileSaveDir;
   private final boolean fileSaveFsync;
 
-  protected volatile Set<String> subscribedTopicNames = new HashSet<>();
+  protected volatile Map<String, TopicConfig> subscribedTopics = new HashMap<>();
+
+  public boolean allSnapshotTopicMessagesHaveBeenConsumed() {
+    return subscribedTopics.values().stream()
+        .noneMatch(
+            (config) -> config.getAttributesWithSourceMode().containsValue(MODE_SNAPSHOT_VALUE));
+  }
 
   /////////////////////////////// getter ///////////////////////////////
 
@@ -108,14 +119,6 @@ abstract class SubscriptionConsumer implements AutoCloseable {
     return consumerGroupId;
   }
 
-  /**
-   * @return When <b>only</b> subscribing to the query mode topics, if there is no new data to
-   *     process, return {@code false}; otherwise, return {@code true}.
-   */
-  public boolean hasMoreData() {
-    return !subscribedTopicNames.isEmpty();
-  }
-
   /////////////////////////////// ctor ///////////////////////////////
 
   protected SubscriptionConsumer(final Builder builder) {
@@ -186,7 +189,26 @@ abstract class SubscriptionConsumer implements AutoCloseable {
 
   /////////////////////////////// open & close ///////////////////////////////
 
+  private void checkIfHasBeenClosed() throws SubscriptionException {
+    if (isReleased.get()) {
+      final String errorMessage =
+          String.format("%s has ever been closed, unsupported operation after closing.", this);
+      LOGGER.error(errorMessage);
+      throw new SubscriptionException(errorMessage);
+    }
+  }
+
+  private void checkIfOpened() throws SubscriptionException {
+    if (isClosed.get()) {
+      final String errorMessage =
+          String.format("%s is not yet open, please open the subscription consumer first.", this);
+      LOGGER.error(errorMessage);
+      throw new SubscriptionException(errorMessage);
+    }
+  }
+
   public synchronized void open() throws SubscriptionException {
+    checkIfHasBeenClosed();
     if (!isClosed.get()) {
       return;
     }
@@ -220,6 +242,9 @@ abstract class SubscriptionConsumer implements AutoCloseable {
     providers.releaseWriteLock();
 
     isClosed.set(true);
+
+    // mark is released to avoid reopening after closing
+    isReleased.set(true);
   }
 
   boolean isClosed() {
@@ -243,6 +268,8 @@ abstract class SubscriptionConsumer implements AutoCloseable {
 
   private void subscribe(Set<String> topicNames, final boolean needParse)
       throws SubscriptionException {
+    checkIfOpened();
+
     if (needParse) {
       topicNames =
           topicNames.stream().map(IdentifierUtils::parseIdentifier).collect(Collectors.toSet());
@@ -271,6 +298,8 @@ abstract class SubscriptionConsumer implements AutoCloseable {
 
   private void unsubscribe(Set<String> topicNames, final boolean needParse)
       throws SubscriptionException {
+    checkIfOpened();
+
     if (needParse) {
       topicNames =
           topicNames.stream().map(IdentifierUtils::parseIdentifier).collect(Collectors.toSet());
@@ -355,18 +384,23 @@ abstract class SubscriptionConsumer implements AutoCloseable {
   protected List<SubscriptionMessage> poll(
       /* @NotNull */ final Set<String> topicNames, final long timeoutMs)
       throws SubscriptionException {
-    final List<SubscriptionMessage> messages = new ArrayList<>();
-    final SubscriptionPollTimer timer =
-        new SubscriptionPollTimer(System.currentTimeMillis(), timeoutMs);
-
     // check topic names
+    if (subscribedTopics.isEmpty()) {
+      LOGGER.info("SubscriptionConsumer {} has not subscribed to any topics yet", this);
+      return Collections.emptyList();
+    }
+
     topicNames.stream()
-        .filter(topicName -> !subscribedTopicNames.contains(topicName))
+        .filter(topicName -> !subscribedTopics.containsKey(topicName))
         .forEach(
             topicName ->
                 LOGGER.warn(
                     "SubscriptionConsumer {} does not subscribe to topic {}", this, topicName));
 
+    final List<SubscriptionMessage> messages = new ArrayList<>();
+    final SubscriptionPollTimer timer =
+        new SubscriptionPollTimer(System.currentTimeMillis(), timeoutMs);
+
     do {
       try {
         // poll tablets or file
@@ -843,7 +877,7 @@ abstract class SubscriptionConsumer implements AutoCloseable {
     }
     for (final SubscriptionProvider provider : providers) {
       try {
-        subscribedTopicNames = provider.subscribe(topicNames);
+        subscribedTopics = provider.subscribe(topicNames);
         return;
       } catch (final Exception e) {
         LOGGER.warn(
@@ -873,7 +907,7 @@ abstract class SubscriptionConsumer implements AutoCloseable {
     }
     for (final SubscriptionProvider provider : providers) {
       try {
-        subscribedTopicNames = provider.unsubscribe(topicNames);
+        subscribedTopics = provider.unsubscribe(topicNames);
         return;
       } catch (final Exception e) {
         LOGGER.warn(
@@ -1001,14 +1035,34 @@ abstract class SubscriptionConsumer implements AutoCloseable {
     public abstract SubscriptionPushConsumer buildPushConsumer();
   }
 
-  /////////////////////////////// object ///////////////////////////////
+  /////////////////////////////// stringify ///////////////////////////////
 
-  @Override
-  public String toString() {
-    return "SubscriptionConsumer{consumerId="
-        + consumerId
-        + ", consumerGroupId="
-        + consumerGroupId
-        + "}";
+  protected Map<String, String> coreReportMessage() {
+    return new HashMap<String, String>() {
+      {
+        put("consumerId", consumerId);
+        put("consumerGroupId", consumerGroupId);
+        put("isClosed", isClosed.toString());
+        put("fileSaveDir", fileSaveDir);
+        put("subscribedTopicNames", subscribedTopics.keySet().toString());
+      }
+    };
+  }
+
+  protected Map<String, String> allReportMessage() {
+    return new HashMap<String, String>() {
+      {
+        put("consumerId", consumerId);
+        put("consumerGroupId", consumerGroupId);
+        put("heartbeatIntervalMs", String.valueOf(heartbeatIntervalMs));
+        put("endpointsSyncIntervalMs", String.valueOf(endpointsSyncIntervalMs));
+        put("providers", providers.toString());
+        put("isClosed", isClosed.toString());
+        put("isReleased", isReleased.toString());
+        put("fileSaveDir", fileSaveDir);
+        put("fileSaveFsync", String.valueOf(fileSaveFsync));
+        put("subscribedTopics", subscribedTopics.toString());
+      }
+    };
   }
 }
diff --git a/iotdb-client/session/src/main/java/org/apache/iotdb/session/subscription/consumer/SubscriptionProvider.java b/iotdb-client/session/src/main/java/org/apache/iotdb/session/subscription/consumer/SubscriptionProvider.java
index 9bce0d6774f..ba99774590b 100644
--- a/iotdb-client/session/src/main/java/org/apache/iotdb/session/subscription/consumer/SubscriptionProvider.java
+++ b/iotdb-client/session/src/main/java/org/apache/iotdb/session/subscription/consumer/SubscriptionProvider.java
@@ -24,6 +24,7 @@ import org.apache.iotdb.common.rpc.thrift.TSStatus;
 import org.apache.iotdb.rpc.IoTDBConnectionException;
 import org.apache.iotdb.rpc.subscription.config.ConsumerConfig;
 import org.apache.iotdb.rpc.subscription.config.ConsumerConstant;
+import org.apache.iotdb.rpc.subscription.config.TopicConfig;
 import org.apache.iotdb.rpc.subscription.exception.SubscriptionConnectionException;
 import org.apache.iotdb.rpc.subscription.exception.SubscriptionException;
 import org.apache.iotdb.rpc.subscription.exception.SubscriptionRuntimeCriticalException;
@@ -124,6 +125,7 @@ final class SubscriptionProvider extends SubscriptionSession {
 
     super.open(); // throw IoTDBConnectionException
 
+    // TODO: pass the complete consumer parameter configuration to the server
     final Map<String, String> consumerAttributes = new HashMap<>();
     consumerAttributes.put(ConsumerConstant.CONSUMER_GROUP_ID_KEY, consumerGroupId);
     consumerAttributes.put(ConsumerConstant.CONSUMER_ID_KEY, consumerId);
@@ -217,7 +219,7 @@ final class SubscriptionProvider extends SubscriptionSession {
     verifyPipeSubscribeSuccess(resp.status);
   }
 
-  Set<String> subscribe(final Set<String> topicNames) throws SubscriptionException {
+  Map<String, TopicConfig> subscribe(final Set<String> topicNames) throws SubscriptionException {
     final PipeSubscribeSubscribeReq req;
     try {
       req = PipeSubscribeSubscribeReq.toTPipeSubscribeReq(topicNames);
@@ -245,10 +247,10 @@ final class SubscriptionProvider extends SubscriptionSession {
     verifyPipeSubscribeSuccess(resp.status);
     final PipeSubscribeSubscribeResp subscribeResp =
         PipeSubscribeSubscribeResp.fromTPipeSubscribeResp(resp);
-    return subscribeResp.getTopicNames();
+    return subscribeResp.getTopics();
   }
 
-  Set<String> unsubscribe(final Set<String> topicNames) throws SubscriptionException {
+  Map<String, TopicConfig> unsubscribe(final Set<String> topicNames) throws SubscriptionException {
     final PipeSubscribeUnsubscribeReq req;
     try {
       req = PipeSubscribeUnsubscribeReq.toTPipeSubscribeReq(topicNames);
@@ -276,7 +278,7 @@ final class SubscriptionProvider extends SubscriptionSession {
     verifyPipeSubscribeSuccess(resp.status);
     final PipeSubscribeUnsubscribeResp unsubscribeResp =
         PipeSubscribeUnsubscribeResp.fromTPipeSubscribeResp(resp);
-    return unsubscribeResp.getTopicNames();
+    return unsubscribeResp.getTopics();
   }
 
   List<SubscriptionPollResponse> poll(final SubscriptionPollRequest pollMessage)
diff --git a/iotdb-client/session/src/main/java/org/apache/iotdb/session/subscription/consumer/SubscriptionPullConsumer.java b/iotdb-client/session/src/main/java/org/apache/iotdb/session/subscription/consumer/SubscriptionPullConsumer.java
index 38dfc530ee3..31148dc09fc 100644
--- a/iotdb-client/session/src/main/java/org/apache/iotdb/session/subscription/consumer/SubscriptionPullConsumer.java
+++ b/iotdb-client/session/src/main/java/org/apache/iotdb/session/subscription/consumer/SubscriptionPullConsumer.java
@@ -353,4 +353,29 @@ public class SubscriptionPullConsumer extends SubscriptionConsumer {
           "SubscriptionPullConsumer.Builder do not support build push consumer.");
     }
   }
+
+  /////////////////////////////// stringify ///////////////////////////////
+
+  @Override
+  public String toString() {
+    return "SubscriptionPullConsumer" + this.coreReportMessage();
+  }
+
+  @Override
+  protected Map<String, String> coreReportMessage() {
+    final Map<String, String> coreReportMessage = super.coreReportMessage();
+    coreReportMessage.put("autoCommit", String.valueOf(autoCommit));
+    return coreReportMessage;
+  }
+
+  @Override
+  protected Map<String, String> allReportMessage() {
+    final Map<String, String> allReportMessage = super.allReportMessage();
+    allReportMessage.put("autoCommit", String.valueOf(autoCommit));
+    allReportMessage.put("autoCommitIntervalMs", String.valueOf(autoCommitIntervalMs));
+    if (autoCommit) {
+      allReportMessage.put("uncommittedMessages", uncommittedMessages.toString());
+    }
+    return allReportMessage;
+  }
 }
diff --git a/iotdb-client/session/src/main/java/org/apache/iotdb/session/subscription/consumer/SubscriptionPushConsumer.java b/iotdb-client/session/src/main/java/org/apache/iotdb/session/subscription/consumer/SubscriptionPushConsumer.java
index 7323473552c..e28cf3b7c7e 100644
--- a/iotdb-client/session/src/main/java/org/apache/iotdb/session/subscription/consumer/SubscriptionPushConsumer.java
+++ b/iotdb-client/session/src/main/java/org/apache/iotdb/session/subscription/consumer/SubscriptionPushConsumer.java
@@ -28,6 +28,7 @@ import org.slf4j.LoggerFactory;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 import java.util.Objects;
 import java.util.Properties;
 import java.util.concurrent.ScheduledFuture;
@@ -161,12 +162,13 @@ public class SubscriptionPushConsumer extends SubscriptionConsumer {
         return;
       }
 
-      if (subscribedTopicNames.isEmpty()) {
+      if (subscribedTopics.isEmpty()) {
         return;
       }
 
       try {
-        final List<SubscriptionMessage> messages = poll(subscribedTopicNames, autoPollTimeoutMs);
+        final List<SubscriptionMessage> messages =
+            poll(subscribedTopics.keySet(), autoPollTimeoutMs);
 
         if (ackStrategy.equals(AckStrategy.BEFORE_CONSUME)) {
           ack(messages);
@@ -310,4 +312,27 @@ public class SubscriptionPushConsumer extends SubscriptionConsumer {
       return new SubscriptionPushConsumer(this);
     }
   }
+
+  /////////////////////////////// stringify ///////////////////////////////
+
+  @Override
+  public String toString() {
+    return "SubscriptionPushConsumer" + this.coreReportMessage();
+  }
+
+  @Override
+  protected Map<String, String> coreReportMessage() {
+    final Map<String, String> coreReportMessage = super.coreReportMessage();
+    coreReportMessage.put("ackStrategy", ackStrategy.toString());
+    return coreReportMessage;
+  }
+
+  @Override
+  protected Map<String, String> allReportMessage() {
+    final Map<String, String> allReportMessage = super.allReportMessage();
+    allReportMessage.put("ackStrategy", ackStrategy.toString());
+    allReportMessage.put("autoPollIntervalMs", String.valueOf(autoPollIntervalMs));
+    allReportMessage.put("autoPollTimeoutMs", String.valueOf(autoPollTimeoutMs));
+    return allReportMessage;
+  }
 }
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/agent/task/PipeDataNodeTaskAgent.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/agent/task/PipeDataNodeTaskAgent.java
index 8fce2188dc7..56d41da1d15 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/agent/task/PipeDataNodeTaskAgent.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/agent/task/PipeDataNodeTaskAgent.java
@@ -339,19 +339,23 @@ public class PipeDataNodeTaskAgent extends PipeTaskAgent {
                 || pipeTaskMap.entrySet().stream()
                     .filter(entry -> dataRegionIds.contains(entry.getKey()))
                     .allMatch(entry -> ((PipeDataNodeTask) entry.getValue()).isCompleted());
+        final String extractorModeValue =
+            pipeMeta
+                .getStaticMeta()
+                .getExtractorParameters()
+                .getStringOrDefault(
+                    Arrays.asList(
+                        PipeExtractorConstant.EXTRACTOR_MODE_KEY,
+                        PipeExtractorConstant.SOURCE_MODE_KEY),
+                    PipeExtractorConstant.EXTRACTOR_MODE_DEFAULT_VALUE);
         final boolean includeDataAndNeedDrop =
             DataRegionListeningFilter.parseInsertionDeletionListeningOptionPair(
                         pipeMeta.getStaticMeta().getExtractorParameters())
                     .getLeft()
-                && pipeMeta
-                    .getStaticMeta()
-                    .getExtractorParameters()
-                    .getStringOrDefault(
-                        Arrays.asList(
-                            PipeExtractorConstant.EXTRACTOR_MODE_KEY,
-                            PipeExtractorConstant.SOURCE_MODE_KEY),
-                        PipeExtractorConstant.EXTRACTOR_MODE_DEFAULT_VALUE)
-                    .equalsIgnoreCase(PipeExtractorConstant.EXTRACTOR_MODE_QUERY_VALUE);
+                && (extractorModeValue.equalsIgnoreCase(
+                        PipeExtractorConstant.EXTRACTOR_MODE_QUERY_VALUE)
+                    || extractorModeValue.equalsIgnoreCase(
+                        PipeExtractorConstant.EXTRACTOR_MODE_SNAPSHOT_VALUE));
 
         final boolean isCompleted = isAllDataRegionCompleted && includeDataAndNeedDrop;
         final Pair<Long, Double> remainingEventAndTime =
@@ -418,19 +422,23 @@ public class PipeDataNodeTaskAgent extends PipeTaskAgent {
                 || pipeTaskMap.entrySet().stream()
                     .filter(entry -> dataRegionIds.contains(entry.getKey()))
                     .allMatch(entry -> ((PipeDataNodeTask) entry.getValue()).isCompleted());
+        final String extractorModeValue =
+            pipeMeta
+                .getStaticMeta()
+                .getExtractorParameters()
+                .getStringOrDefault(
+                    Arrays.asList(
+                        PipeExtractorConstant.EXTRACTOR_MODE_KEY,
+                        PipeExtractorConstant.SOURCE_MODE_KEY),
+                    PipeExtractorConstant.EXTRACTOR_MODE_DEFAULT_VALUE);
         final boolean includeDataAndNeedDrop =
             DataRegionListeningFilter.parseInsertionDeletionListeningOptionPair(
                         pipeMeta.getStaticMeta().getExtractorParameters())
                     .getLeft()
-                && pipeMeta
-                    .getStaticMeta()
-                    .getExtractorParameters()
-                    .getStringOrDefault(
-                        Arrays.asList(
-                            PipeExtractorConstant.EXTRACTOR_MODE_KEY,
-                            PipeExtractorConstant.SOURCE_MODE_KEY),
-                        PipeExtractorConstant.EXTRACTOR_MODE_DEFAULT_VALUE)
-                    .equalsIgnoreCase(PipeExtractorConstant.EXTRACTOR_MODE_QUERY_VALUE);
+                && (extractorModeValue.equalsIgnoreCase(
+                        PipeExtractorConstant.EXTRACTOR_MODE_QUERY_VALUE)
+                    || extractorModeValue.equalsIgnoreCase(
+                        PipeExtractorConstant.EXTRACTOR_MODE_SNAPSHOT_VALUE));
 
         final boolean isCompleted = isAllDataRegionCompleted && includeDataAndNeedDrop;
         final Pair<Long, Double> remainingEventAndTime =
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/connector/payload/evolvable/batch/PipeTabletEventBatch.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/connector/payload/evolvable/batch/PipeTabletEventBatch.java
index 1f4123c6cc2..db5ba85d7ba 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/connector/payload/evolvable/batch/PipeTabletEventBatch.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/connector/payload/evolvable/batch/PipeTabletEventBatch.java
@@ -52,7 +52,7 @@ public abstract class PipeTabletEventBatch implements AutoCloseable {
    * @param event the given {@link Event}
    * @return {@code true} if the batch can be transferred
    */
-  synchronized boolean onEvent(final TabletInsertionEvent event)
+  public synchronized boolean onEvent(final TabletInsertionEvent event)
       throws WALPipeException, IOException, WriteProcessException {
     if (isClosed || !(event instanceof EnrichedEvent)) {
       return false;
@@ -92,7 +92,7 @@ public abstract class PipeTabletEventBatch implements AutoCloseable {
   protected abstract boolean constructBatch(final TabletInsertionEvent event)
       throws WALPipeException, IOException, WriteProcessException;
 
-  private boolean shouldEmit() {
+  public boolean shouldEmit() {
     return totalBufferSize >= getMaxBatchSizeInBytes()
         || System.currentTimeMillis() - firstEventProcessingTime >= maxDelayInMs;
   }
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/connector/payload/evolvable/batch/PipeTabletEventTsFileBatch.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/connector/payload/evolvable/batch/PipeTabletEventTsFileBatch.java
index 4864a124668..e02f2d7bbb0 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/connector/payload/evolvable/batch/PipeTabletEventTsFileBatch.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/connector/payload/evolvable/batch/PipeTabletEventTsFileBatch.java
@@ -79,7 +79,7 @@ public class PipeTabletEventTsFileBatch extends PipeTabletEventBatch {
 
   private volatile TsFileWriter fileWriter;
 
-  PipeTabletEventTsFileBatch(final int maxDelayInMs, final long requestMaxBatchSizeInBytes) {
+  public PipeTabletEventTsFileBatch(final int maxDelayInMs, final long requestMaxBatchSizeInBytes) {
     super(maxDelayInMs);
 
     this.maxSizeInBytes = requestMaxBatchSizeInBytes;
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/event/common/tablet/TabletInsertionDataContainer.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/event/common/tablet/TabletInsertionDataContainer.java
index 26ae666ed23..45485411554 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/event/common/tablet/TabletInsertionDataContainer.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/event/common/tablet/TabletInsertionDataContainer.java
@@ -81,11 +81,11 @@ public class TabletInsertionDataContainer {
   private boolean shouldReport = false;
 
   private static final Integer CACHED_FULL_ROW_INDEX_LIST_ROW_COUNT_UPPER = 16;
-  private static final Map<Integer, List<Integer>> cachedFullRowIndexList = new HashMap<>();
+  private static final Map<Integer, List<Integer>> CACHED_FULL_ROW_INDEX_LIST = new HashMap<>();
 
   static {
     for (int rowCount = 0; rowCount <= CACHED_FULL_ROW_INDEX_LIST_ROW_COUNT_UPPER; ++rowCount) {
-      cachedFullRowIndexList.put(
+      CACHED_FULL_ROW_INDEX_LIST.put(
           rowCount, IntStream.range(0, rowCount).boxed().collect(Collectors.toList()));
     }
   }
@@ -435,7 +435,7 @@ public class TabletInsertionDataContainer {
 
   private static List<Integer> generateFullRowIndexList(final int rowCount) {
     if (rowCount <= CACHED_FULL_ROW_INDEX_LIST_ROW_COUNT_UPPER) {
-      return cachedFullRowIndexList.get(rowCount);
+      return CACHED_FULL_ROW_INDEX_LIST.get(rowCount);
     }
     return IntStream.range(0, rowCount).boxed().collect(Collectors.toList());
   }
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/extractor/dataregion/historical/PipeHistoricalDataRegionTsFileExtractor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/extractor/dataregion/historical/PipeHistoricalDataRegionTsFileExtractor.java
index 765c48536ab..f89d85f0d97 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/extractor/dataregion/historical/PipeHistoricalDataRegionTsFileExtractor.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/extractor/dataregion/historical/PipeHistoricalDataRegionTsFileExtractor.java
@@ -69,6 +69,7 @@ import static org.apache.iotdb.commons.pipe.config.constant.PipeExtractorConstan
 import static org.apache.iotdb.commons.pipe.config.constant.PipeExtractorConstant.EXTRACTOR_HISTORY_ENABLE_DEFAULT_VALUE;
 import static org.apache.iotdb.commons.pipe.config.constant.PipeExtractorConstant.EXTRACTOR_HISTORY_ENABLE_KEY;
 import static org.apache.iotdb.commons.pipe.config.constant.PipeExtractorConstant.EXTRACTOR_HISTORY_END_TIME_KEY;
+import static org.apache.iotdb.commons.pipe.config.constant.PipeExtractorConstant.EXTRACTOR_HISTORY_LOOSE_RANGE_ALL_VALUE;
 import static org.apache.iotdb.commons.pipe.config.constant.PipeExtractorConstant.EXTRACTOR_HISTORY_LOOSE_RANGE_DEFAULT_VALUE;
 import static org.apache.iotdb.commons.pipe.config.constant.PipeExtractorConstant.EXTRACTOR_HISTORY_LOOSE_RANGE_KEY;
 import static org.apache.iotdb.commons.pipe.config.constant.PipeExtractorConstant.EXTRACTOR_HISTORY_LOOSE_RANGE_PATH_VALUE;
@@ -133,24 +134,29 @@ public class PipeHistoricalDataRegionTsFileExtractor implements PipeHistoricalDa
       throw new PipeParameterNotValidException(e.getMessage());
     }
 
-    final Set<String> sloppyOptionSet =
-        Arrays.stream(
-                parameters
-                    .getStringOrDefault(
-                        Arrays.asList(
-                            EXTRACTOR_HISTORY_LOOSE_RANGE_KEY, SOURCE_HISTORY_LOOSE_RANGE_KEY),
-                        EXTRACTOR_HISTORY_LOOSE_RANGE_DEFAULT_VALUE)
-                    .split(","))
-            .map(String::trim)
-            .filter(s -> !s.isEmpty())
-            .map(String::toLowerCase)
-            .collect(Collectors.toSet());
-    sloppyTimeRange = sloppyOptionSet.remove(EXTRACTOR_HISTORY_LOOSE_RANGE_TIME_VALUE);
-    sloppyPattern = sloppyOptionSet.remove(EXTRACTOR_HISTORY_LOOSE_RANGE_PATH_VALUE);
-    if (!sloppyOptionSet.isEmpty()) {
-      throw new PipeParameterNotValidException(
-          String.format(
-              "Parameters in set %s are not allowed in 'history.loose-range'", sloppyOptionSet));
+    final String extractorHistoryLooseRangeValue =
+        parameters
+            .getStringOrDefault(
+                Arrays.asList(EXTRACTOR_HISTORY_LOOSE_RANGE_KEY, SOURCE_HISTORY_LOOSE_RANGE_KEY),
+                EXTRACTOR_HISTORY_LOOSE_RANGE_DEFAULT_VALUE)
+            .trim();
+    if (EXTRACTOR_HISTORY_LOOSE_RANGE_ALL_VALUE.equalsIgnoreCase(extractorHistoryLooseRangeValue)) {
+      sloppyTimeRange = true;
+      sloppyPattern = true;
+    } else {
+      final Set<String> sloppyOptionSet =
+          Arrays.stream(extractorHistoryLooseRangeValue.split(","))
+              .map(String::trim)
+              .filter(s -> !s.isEmpty())
+              .map(String::toLowerCase)
+              .collect(Collectors.toSet());
+      sloppyTimeRange = sloppyOptionSet.remove(EXTRACTOR_HISTORY_LOOSE_RANGE_TIME_VALUE);
+      sloppyPattern = sloppyOptionSet.remove(EXTRACTOR_HISTORY_LOOSE_RANGE_PATH_VALUE);
+      if (!sloppyOptionSet.isEmpty()) {
+        throw new PipeParameterNotValidException(
+            String.format(
+                "Parameters in set %s are not allowed in 'history.loose-range'", sloppyOptionSet));
+      }
     }
 
     if (parameters.hasAnyAttributes(
@@ -320,14 +326,15 @@ public class PipeHistoricalDataRegionTsFileExtractor implements PipeHistoricalDa
                 || // Should extract deletion
                 listeningOptionPair.getRight());
 
+    final String extractorModeValue =
+        parameters.getStringOrDefault(
+            Arrays.asList(
+                PipeExtractorConstant.EXTRACTOR_MODE_KEY, PipeExtractorConstant.SOURCE_MODE_KEY),
+            PipeExtractorConstant.EXTRACTOR_MODE_DEFAULT_VALUE);
     shouldTerminatePipeOnAllHistoricalEventsConsumed =
-        parameters
-            .getStringOrDefault(
-                Arrays.asList(
-                    PipeExtractorConstant.EXTRACTOR_MODE_KEY,
-                    PipeExtractorConstant.SOURCE_MODE_KEY),
-                PipeExtractorConstant.EXTRACTOR_MODE_DEFAULT_VALUE)
-            .equalsIgnoreCase(PipeExtractorConstant.EXTRACTOR_MODE_QUERY_VALUE);
+        extractorModeValue.equalsIgnoreCase(PipeExtractorConstant.EXTRACTOR_MODE_QUERY_VALUE)
+            || extractorModeValue.equalsIgnoreCase(
+                PipeExtractorConstant.EXTRACTOR_MODE_SNAPSHOT_VALUE);
 
     if (LOGGER.isInfoEnabled()) {
       LOGGER.info(
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/extractor/dataregion/realtime/PipeRealtimeDataRegionExtractor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/extractor/dataregion/realtime/PipeRealtimeDataRegionExtractor.java
index 5c976b41a7b..138947af18d 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/extractor/dataregion/realtime/PipeRealtimeDataRegionExtractor.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/extractor/dataregion/realtime/PipeRealtimeDataRegionExtractor.java
@@ -62,6 +62,7 @@ import java.util.stream.Collectors;
 import static org.apache.iotdb.commons.pipe.config.constant.PipeExtractorConstant.EXTRACTOR_END_TIME_KEY;
 import static org.apache.iotdb.commons.pipe.config.constant.PipeExtractorConstant.EXTRACTOR_MODS_ENABLE_DEFAULT_VALUE;
 import static org.apache.iotdb.commons.pipe.config.constant.PipeExtractorConstant.EXTRACTOR_MODS_ENABLE_KEY;
+import static org.apache.iotdb.commons.pipe.config.constant.PipeExtractorConstant.EXTRACTOR_REALTIME_LOOSE_RANGE_ALL_VALUE;
 import static org.apache.iotdb.commons.pipe.config.constant.PipeExtractorConstant.EXTRACTOR_REALTIME_LOOSE_RANGE_DEFAULT_VALUE;
 import static org.apache.iotdb.commons.pipe.config.constant.PipeExtractorConstant.EXTRACTOR_REALTIME_LOOSE_RANGE_KEY;
 import static org.apache.iotdb.commons.pipe.config.constant.PipeExtractorConstant.EXTRACTOR_REALTIME_LOOSE_RANGE_PATH_VALUE;
@@ -154,24 +155,30 @@ public abstract class PipeRealtimeDataRegionExtractor implements PipeExtractor {
       throw new PipeParameterNotValidException(e.getMessage());
     }
 
-    final Set<String> sloppyOptionSet =
-        Arrays.stream(
-                parameters
-                    .getStringOrDefault(
-                        Arrays.asList(
-                            EXTRACTOR_REALTIME_LOOSE_RANGE_KEY, SOURCE_REALTIME_LOOSE_RANGE_KEY),
-                        EXTRACTOR_REALTIME_LOOSE_RANGE_DEFAULT_VALUE)
-                    .split(","))
-            .map(String::trim)
-            .filter(s -> !s.isEmpty())
-            .map(String::toLowerCase)
-            .collect(Collectors.toSet());
-    sloppyTimeRange = sloppyOptionSet.remove(EXTRACTOR_REALTIME_LOOSE_RANGE_TIME_VALUE);
-    sloppyPattern = sloppyOptionSet.remove(EXTRACTOR_REALTIME_LOOSE_RANGE_PATH_VALUE);
-    if (!sloppyOptionSet.isEmpty()) {
-      throw new PipeParameterNotValidException(
-          String.format(
-              "Parameters in set %s are not allowed in 'realtime.loose-range'", sloppyOptionSet));
+    final String extractorRealtimeLooseRangeValue =
+        parameters
+            .getStringOrDefault(
+                Arrays.asList(EXTRACTOR_REALTIME_LOOSE_RANGE_KEY, SOURCE_REALTIME_LOOSE_RANGE_KEY),
+                EXTRACTOR_REALTIME_LOOSE_RANGE_DEFAULT_VALUE)
+            .trim();
+    if (EXTRACTOR_REALTIME_LOOSE_RANGE_ALL_VALUE.equalsIgnoreCase(
+        extractorRealtimeLooseRangeValue)) {
+      sloppyTimeRange = true;
+      sloppyPattern = true;
+    } else {
+      final Set<String> sloppyOptionSet =
+          Arrays.stream(extractorRealtimeLooseRangeValue.split(","))
+              .map(String::trim)
+              .filter(s -> !s.isEmpty())
+              .map(String::toLowerCase)
+              .collect(Collectors.toSet());
+      sloppyTimeRange = sloppyOptionSet.remove(EXTRACTOR_REALTIME_LOOSE_RANGE_TIME_VALUE);
+      sloppyPattern = sloppyOptionSet.remove(EXTRACTOR_REALTIME_LOOSE_RANGE_PATH_VALUE);
+      if (!sloppyOptionSet.isEmpty()) {
+        throw new PipeParameterNotValidException(
+            String.format(
+                "Parameters in set %s are not allowed in 'realtime.loose-range'", sloppyOptionSet));
+      }
     }
   }
 
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/agent/SubscriptionConsumerAgent.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/agent/SubscriptionConsumerAgent.java
index 983abb03642..6d96decbe69 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/agent/SubscriptionConsumerAgent.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/agent/SubscriptionConsumerAgent.java
@@ -199,7 +199,7 @@ public class SubscriptionConsumerAgent {
     }
   }
 
-  public Set<String> getTopicsSubscribedByConsumer(
+  public Set<String> getTopicNamesSubscribedByConsumer(
       final String consumerGroupId, final String consumerId) {
     acquireReadLock();
     try {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/agent/SubscriptionTopicAgent.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/agent/SubscriptionTopicAgent.java
index bc174170422..9bde571aa34 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/agent/SubscriptionTopicAgent.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/agent/SubscriptionTopicAgent.java
@@ -22,12 +22,16 @@ package org.apache.iotdb.db.subscription.agent;
 import org.apache.iotdb.commons.subscription.meta.topic.TopicMeta;
 import org.apache.iotdb.commons.subscription.meta.topic.TopicMetaKeeper;
 import org.apache.iotdb.mpp.rpc.thrift.TPushTopicMetaRespExceptionMessage;
+import org.apache.iotdb.rpc.subscription.config.TopicConfig;
 import org.apache.iotdb.rpc.subscription.config.TopicConstant;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
 
 public class SubscriptionTopicAgent {
 
@@ -161,4 +165,17 @@ public class SubscriptionTopicAgent {
       releaseReadLock();
     }
   }
+
+  public Map<String, TopicConfig> getTopicConfigs(final Set<String> topicNames) {
+    acquireReadLock();
+    try {
+      return topicNames.stream()
+          .collect(
+              Collectors.toMap(
+                  topicName -> topicName,
+                  topicName -> topicMetaKeeper.getTopicMeta(topicName).getConfig()));
+    } finally {
+      releaseReadLock();
+    }
+  }
 }
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/broker/SubscriptionBroker.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/broker/SubscriptionBroker.java
index f3bd0371fdd..b4b95895840 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/broker/SubscriptionBroker.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/broker/SubscriptionBroker.java
@@ -169,7 +169,7 @@ public class SubscriptionBroker {
       topicNameToPrefetchingQueue.put(topicName, queue);
     } else {
       final SubscriptionPrefetchingQueue queue =
-          new SubscriptionPrefetchingTabletsQueue(brokerId, topicName, inputPendingQueue);
+          new SubscriptionPrefetchingTabletQueue(brokerId, topicName, inputPendingQueue);
       SubscriptionPrefetchingQueueMetrics.getInstance().register(queue);
       topicNameToPrefetchingQueue.put(topicName, queue);
     }
@@ -186,18 +186,23 @@ public class SubscriptionBroker {
     // mark prefetching queue closed first
     prefetchingQueue.markClosed();
 
-    // clean up events in prefetching queue, this operation is idempotent
-    prefetchingQueue.cleanup();
-
-    // mark prefetching queue completed only for topic of query mode
-    if (SubscriptionAgent.topic().getTopicMode(topicName).equals(TopicConstant.MODE_QUERY_VALUE)) {
+    // mark prefetching queue completed only for topic of snapshot mode
+    if (SubscriptionAgent.topic()
+        .getTopicMode(topicName)
+        .equals(TopicConstant.MODE_SNAPSHOT_VALUE)) {
       prefetchingQueue.markCompleted();
     }
 
     if (doRemove) {
-      topicNameToPrefetchingQueue.remove(topicName);
+      // clean up events in prefetching queue
+      prefetchingQueue.cleanup();
+
+      // deregister metrics
       SubscriptionPrefetchingQueueMetrics.getInstance()
           .deregister(prefetchingQueue.getPrefetchingQueueId());
+
+      // remove prefetching queue
+      topicNameToPrefetchingQueue.remove(topicName);
     }
   }
 
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/broker/SubscriptionPrefetchingQueue.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/broker/SubscriptionPrefetchingQueue.java
index 09e076653ea..df06665f162 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/broker/SubscriptionPrefetchingQueue.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/broker/SubscriptionPrefetchingQueue.java
@@ -19,12 +19,18 @@
 
 package org.apache.iotdb.db.subscription.broker;
 
+import org.apache.iotdb.commons.pipe.event.EnrichedEvent;
 import org.apache.iotdb.commons.pipe.task.connection.UnboundedBlockingPendingQueue;
+import org.apache.iotdb.commons.subscription.config.SubscriptionConfig;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.pipe.agent.PipeDataNodeAgent;
+import org.apache.iotdb.db.pipe.event.UserDefinedEnrichedEvent;
+import org.apache.iotdb.db.pipe.event.common.terminate.PipeTerminateEvent;
+import org.apache.iotdb.db.pipe.event.common.tsfile.PipeTsFileInsertionEvent;
 import org.apache.iotdb.db.subscription.event.SubscriptionEvent;
-import org.apache.iotdb.db.subscription.event.SubscriptionEventBinaryCache;
+import org.apache.iotdb.db.subscription.event.pipe.SubscriptionPipeEmptyEvent;
 import org.apache.iotdb.pipe.api.event.Event;
+import org.apache.iotdb.pipe.api.event.dml.insertion.TabletInsertionEvent;
 import org.apache.iotdb.rpc.subscription.payload.poll.ErrorPayload;
 import org.apache.iotdb.rpc.subscription.payload.poll.SubscriptionCommitContext;
 import org.apache.iotdb.rpc.subscription.payload.poll.SubscriptionPollResponse;
@@ -34,12 +40,16 @@ import org.apache.iotdb.rpc.subscription.payload.poll.TerminationPayload;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.Collections;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.Objects;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
 
+import static org.apache.iotdb.rpc.subscription.payload.poll.SubscriptionCommitContext.INVALID_COMMIT_ID;
+
 public abstract class SubscriptionPrefetchingQueue {
 
   private static final Logger LOGGER = LoggerFactory.getLogger(SubscriptionPrefetchingQueue.class);
@@ -47,6 +57,7 @@ public abstract class SubscriptionPrefetchingQueue {
   protected final String brokerId; // consumer group id
   protected final String topicName;
   protected final UnboundedBlockingPendingQueue<Event> inputPendingQueue;
+  protected final LinkedBlockingQueue<SubscriptionEvent> prefetchingQueue;
 
   protected final Map<SubscriptionCommitContext, SubscriptionEvent> uncommittedEvents;
   private final AtomicLong subscriptionCommitIdGenerator = new AtomicLong(0);
@@ -62,21 +73,132 @@ public abstract class SubscriptionPrefetchingQueue {
     this.topicName = topicName;
     this.inputPendingQueue = inputPendingQueue;
 
+    this.prefetchingQueue = new LinkedBlockingQueue<>();
     this.uncommittedEvents = new ConcurrentHashMap<>();
   }
 
-  public abstract SubscriptionEvent poll(final String consumerId);
+  public SubscriptionEvent poll(final String consumerId) {
+    if (prefetchingQueue.isEmpty()) {
+      tryPrefetch();
+    }
+
+    final long size = prefetchingQueue.size();
+    long count = 0;
+
+    SubscriptionEvent event;
+    try {
+      while (count++ < size // limit control
+          && Objects.nonNull(
+              event =
+                  prefetchingQueue.poll(
+                      SubscriptionConfig.getInstance().getSubscriptionPollMaxBlockingTimeMs(),
+                      TimeUnit.MILLISECONDS))) {
+        if (event.isCommitted()) {
+          event.cleanup();
+          continue;
+        }
+        if (!event.pollable()) {
+          // Re-enqueue the uncommitted event at the end of the queue.
+          prefetchingQueue.add(event);
+          continue;
+        }
+        event.recordLastPolledConsumerId(consumerId);
+        event.recordLastPolledTimestamp();
+        // Re-enqueue the uncommitted event at the end of the queue.
+        // This operation should be performed after recordLastPolledTimestamp to prevent multiple
+        // consumers from consuming the same event.
+        prefetchingQueue.add(event);
+        return event;
+      }
+    } catch (final InterruptedException e) {
+      Thread.currentThread().interrupt();
+      LOGGER.warn(
+          "Subscription: SubscriptionPrefetchingQueue {} interrupted while polling events.",
+          this,
+          e);
+    }
+
+    return null;
+  }
+
+  /**
+   * @return {@code true} if a new event has been prefetched.
+   */
+  protected abstract boolean onEvent(final TabletInsertionEvent event);
+
+  /**
+   * @return {@code true} if a new event has been prefetched.
+   */
+  protected abstract boolean onEvent(final PipeTsFileInsertionEvent event);
+
+  /**
+   * @return {@code true} if a new event has been prefetched.
+   */
+  protected abstract boolean trySealBatch();
+
+  /**
+   * prefetch at most one subscription event from {@link
+   * SubscriptionPrefetchingQueue#inputPendingQueue} to {@link
+   * SubscriptionPrefetchingQueue#prefetchingQueue}
+   */
+  protected void tryPrefetch() {
+    Event event;
+    while (Objects.nonNull(
+        event = UserDefinedEnrichedEvent.maybeOf(inputPendingQueue.waitedPoll()))) {
+      if (!(event instanceof EnrichedEvent)) {
+        LOGGER.warn(
+            "Subscription: SubscriptionPrefetchingQueue {} only support prefetch EnrichedEvent. Ignore {}.",
+            this,
+            event);
+        continue;
+      }
+
+      if (event instanceof PipeTerminateEvent) {
+        LOGGER.info(
+            "Subscription: SubscriptionPrefetchingQueue {} commit PipeTerminateEvent {}",
+            this,
+            event);
+        // commit directly
+        ((PipeTerminateEvent) event)
+            .decreaseReferenceCount(SubscriptionPrefetchingQueue.class.getName(), true);
+        continue;
+      }
+
+      if (event instanceof TabletInsertionEvent) {
+        if (onEvent((TabletInsertionEvent) event)) {
+          break;
+        }
+      } else if (event instanceof PipeTsFileInsertionEvent) {
+        if (onEvent((PipeTsFileInsertionEvent) event)) {
+          break;
+        }
+      } else {
+        // TODO:
+        //  - PipeHeartbeatEvent: ignored? (may affect pipe metrics)
+        //  - UserDefinedEnrichedEvent: ignored?
+        //  - Others: events related to meta sync, safe to ignore
+        LOGGER.info(
+            "Subscription: SubscriptionPrefetchingQueue {} ignore EnrichedEvent {} when prefetching.",
+            this,
+            event);
+        if (trySealBatch()) {
+          break;
+        }
+      }
+    }
+  }
 
   public abstract void executePrefetch();
 
   public void cleanup() {
     // clean up uncommitted events
-    for (final SubscriptionEvent event : uncommittedEvents.values()) {
-      event.clearReferenceCount();
-      SubscriptionEventBinaryCache.getInstance().resetByteBuffer(event, true);
-    }
+    uncommittedEvents.values().forEach(SubscriptionEvent::cleanup);
     uncommittedEvents.clear();
 
+    // no need to clean up events in prefetchingQueue, since all events in prefetchingQueue are also
+    // in uncommittedEvents
+    prefetchingQueue.clear();
+
     // no need to clean up events in inputPendingQueue, see
     // org.apache.iotdb.db.pipe.task.subtask.connector.PipeConnectorSubtask.close
   }
@@ -90,14 +212,34 @@ public abstract class SubscriptionPrefetchingQueue {
     final SubscriptionEvent event = uncommittedEvents.get(commitContext);
     if (Objects.isNull(event)) {
       LOGGER.warn(
-          "Subscription: subscription commit context [{}] does not exist, it may have been committed or something unexpected happened, prefetching queue: {}",
+          "Subscription: subscription commit context {} does not exist, it may have been committed or something unexpected happened, prefetching queue: {}",
+          commitContext,
+          this);
+      return false;
+    }
+
+    if (event.isCommitted()) {
+      LOGGER.warn(
+          "Subscription: subscription event {} is committed, subscription commit context {}, prefetching queue: {}",
+          event,
+          commitContext,
+          this);
+      return false;
+    }
+
+    if (!event.isCommittable()) {
+      LOGGER.warn(
+          "Subscription: subscription event {} is not committable, subscription commit context {}, prefetching queue: {}",
+          event,
           commitContext,
           this);
       return false;
     }
-    event.decreaseReferenceCount();
+
+    event.ack();
+    event.cleanup();
+
     event.recordCommittedTimestamp();
-    SubscriptionEventBinaryCache.getInstance().resetByteBuffer(event, true);
     uncommittedEvents.remove(commitContext);
     return true;
   }
@@ -135,14 +277,7 @@ public abstract class SubscriptionPrefetchingQueue {
         PipeDataNodeAgent.runtime().getRebootTimes(),
         topicName,
         brokerId,
-        -1);
-  }
-
-  /////////////////////////////// object ///////////////////////////////
-
-  @Override
-  public String toString() {
-    return "SubscriptionPrefetchingQueue{brokerId=" + brokerId + ", topicName=" + topicName + "}";
+        INVALID_COMMIT_ID);
   }
 
   //////////////////////////// APIs provided for metric framework ////////////////////////////
@@ -184,7 +319,7 @@ public abstract class SubscriptionPrefetchingQueue {
 
   public SubscriptionEvent generateSubscriptionPollTerminationResponse() {
     return new SubscriptionEvent(
-        Collections.emptyList(),
+        new SubscriptionPipeEmptyEvent(),
         new SubscriptionPollResponse(
             SubscriptionPollResponseType.TERMINATION.getType(),
             new TerminationPayload(),
@@ -194,10 +329,40 @@ public abstract class SubscriptionPrefetchingQueue {
   public SubscriptionEvent generateSubscriptionPollErrorResponse(
       final String errorMessage, final boolean critical) {
     return new SubscriptionEvent(
-        Collections.emptyList(),
+        new SubscriptionPipeEmptyEvent(),
         new SubscriptionPollResponse(
             SubscriptionPollResponseType.ERROR.getType(),
             new ErrorPayload(errorMessage, critical),
             generateInvalidSubscriptionCommitContext()));
   }
+
+  /////////////////////////////// stringify ///////////////////////////////
+
+  protected Map<String, String> coreReportMessage() {
+    return new HashMap<String, String>() {
+      {
+        put("brokerId", brokerId);
+        put("topicName", topicName);
+        put("size of uncommittedEvents", String.valueOf(uncommittedEvents.size()));
+        put("subscriptionCommitIdGenerator", subscriptionCommitIdGenerator.toString());
+        put("isCompleted", String.valueOf(isCompleted));
+        put("isClosed", String.valueOf(isClosed));
+      }
+    };
+  }
+
+  protected Map<String, String> allReportMessage() {
+    return new HashMap<String, String>() {
+      {
+        put("brokerId", brokerId);
+        put("topicName", topicName);
+        put("size of inputPendingQueue", String.valueOf(inputPendingQueue.size()));
+        put("size of prefetchingQueue", String.valueOf(prefetchingQueue.size()));
+        put("uncommittedEvents", uncommittedEvents.toString());
+        put("subscriptionCommitIdGenerator", subscriptionCommitIdGenerator.toString());
+        put("isCompleted", String.valueOf(isCompleted));
+        put("isClosed", String.valueOf(isClosed));
+      }
+    };
+  }
 }
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/broker/SubscriptionPrefetchingTabletQueue.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/broker/SubscriptionPrefetchingTabletQueue.java
new file mode 100644
index 00000000000..7bd42904d15
--- /dev/null
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/broker/SubscriptionPrefetchingTabletQueue.java
@@ -0,0 +1,190 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.subscription.broker;
+
+import org.apache.iotdb.commons.pipe.event.EnrichedEvent;
+import org.apache.iotdb.commons.pipe.task.connection.UnboundedBlockingPendingQueue;
+import org.apache.iotdb.commons.subscription.config.SubscriptionConfig;
+import org.apache.iotdb.db.pipe.event.common.tsfile.PipeTsFileInsertionEvent;
+import org.apache.iotdb.db.subscription.event.SubscriptionEvent;
+import org.apache.iotdb.db.subscription.event.batch.SubscriptionPipeTabletEventBatch;
+import org.apache.iotdb.db.subscription.event.pipe.SubscriptionPipeTabletBatchEvents;
+import org.apache.iotdb.pipe.api.event.Event;
+import org.apache.iotdb.pipe.api.event.dml.insertion.TabletInsertionEvent;
+import org.apache.iotdb.rpc.subscription.payload.poll.SubscriptionCommitContext;
+import org.apache.iotdb.rpc.subscription.payload.poll.SubscriptionPollResponse;
+import org.apache.iotdb.rpc.subscription.payload.poll.SubscriptionPollResponseType;
+import org.apache.iotdb.rpc.subscription.payload.poll.TabletsPayload;
+
+import org.apache.tsfile.write.record.Tablet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class SubscriptionPrefetchingTabletQueue extends SubscriptionPrefetchingQueue {
+
+  private static final Logger LOGGER =
+      LoggerFactory.getLogger(SubscriptionPrefetchingTabletQueue.class);
+
+  private static final int BATCH_MAX_DELAY_IN_MS =
+      SubscriptionConfig.getInstance().getSubscriptionPrefetchTabletBatchMaxDelayInMs();
+  private static final long BATCH_MAX_SIZE_IN_BYTES =
+      SubscriptionConfig.getInstance().getSubscriptionPrefetchTabletBatchMaxSizeInBytes();
+
+  private final AtomicReference<SubscriptionPipeTabletEventBatch> currentBatchRef =
+      new AtomicReference<>();
+
+  public SubscriptionPrefetchingTabletQueue(
+      final String brokerId,
+      final String topicName,
+      final UnboundedBlockingPendingQueue<Event> inputPendingQueue) {
+    super(brokerId, topicName, inputPendingQueue);
+
+    this.currentBatchRef.set(
+        new SubscriptionPipeTabletEventBatch(BATCH_MAX_DELAY_IN_MS, BATCH_MAX_SIZE_IN_BYTES));
+  }
+
+  @Override
+  public void cleanup() {
+    super.cleanup();
+
+    // clean up batch
+    currentBatchRef.getAndUpdate(
+        (batch) -> {
+          if (Objects.nonNull(batch)) {
+            batch.cleanup();
+          }
+          return null;
+        });
+  }
+
+  @Override
+  public void executePrefetch() {
+    tryPrefetch();
+    serializeEventsInQueue();
+  }
+
+  @Override
+  protected boolean onEvent(final TabletInsertionEvent event) {
+    return onEventInternal((EnrichedEvent) event);
+  }
+
+  @Override
+  protected boolean onEvent(final PipeTsFileInsertionEvent event) {
+    return onEventInternal(event);
+  }
+
+  private boolean onEventInternal(final EnrichedEvent event) {
+    final AtomicBoolean result = new AtomicBoolean(false);
+    currentBatchRef.getAndUpdate(
+        (batch) -> {
+          if (batch.onEvent(event)) {
+            sealBatch(batch);
+            result.set(true);
+            return new SubscriptionPipeTabletEventBatch(
+                BATCH_MAX_DELAY_IN_MS, BATCH_MAX_SIZE_IN_BYTES);
+          }
+          return batch;
+        });
+    return result.get();
+  }
+
+  @Override
+  protected boolean trySealBatch() {
+    currentBatchRef.getAndUpdate(
+        (batch) -> {
+          sealBatch(batch);
+          return new SubscriptionPipeTabletEventBatch(
+              BATCH_MAX_DELAY_IN_MS, BATCH_MAX_SIZE_IN_BYTES);
+        });
+    return true;
+  }
+
+  private void sealBatch(final SubscriptionPipeTabletEventBatch batch) {
+    final List<Tablet> tablets = batch.sealTablets();
+    final SubscriptionCommitContext commitContext = generateSubscriptionCommitContext();
+    final SubscriptionEvent subscriptionEvent =
+        new SubscriptionEvent(
+            new SubscriptionPipeTabletBatchEvents(batch),
+            new SubscriptionPollResponse(
+                SubscriptionPollResponseType.TABLETS.getType(),
+                new TabletsPayload(tablets),
+                commitContext));
+    uncommittedEvents.put(commitContext, subscriptionEvent); // before enqueuing the event
+    prefetchingQueue.add(subscriptionEvent);
+  }
+
+  /**
+   * serialize uncommitted and pollable events in {@link
+   * SubscriptionPrefetchingQueue#prefetchingQueue}
+   */
+  private void serializeEventsInQueue() {
+    final long size = prefetchingQueue.size();
+    long count = 0;
+
+    SubscriptionEvent event;
+    try {
+      while (count++ < size // limit control
+          && Objects.nonNull(
+              event =
+                  prefetchingQueue.poll(
+                      SubscriptionConfig.getInstance().getSubscriptionSerializeMaxBlockingTimeMs(),
+                      TimeUnit.MILLISECONDS))) {
+        if (event.isCommitted()) {
+          event.cleanup();
+          continue;
+        }
+        // Serialize the uncommitted and pollable event.
+        if (event.pollable()) {
+          // No need to concern whether serialization is successful.
+          event.trySerializeCurrentResponse();
+        }
+        // Re-enqueue the uncommitted event at the end of the queue.
+        prefetchingQueue.add(event);
+      }
+    } catch (final InterruptedException e) {
+      Thread.currentThread().interrupt();
+      LOGGER.warn(
+          "Subscription: SubscriptionPrefetchingTabletQueue {} interrupted while serializing events.",
+          this,
+          e);
+    }
+  }
+
+  /////////////////////////////// stringify ///////////////////////////////
+
+  @Override
+  public String toString() {
+    return "SubscriptionPrefetchingTabletQueue" + this.coreReportMessage();
+  }
+
+  @Override
+  protected Map<String, String> allReportMessage() {
+    final Map<String, String> allReportMessage = super.allReportMessage();
+    allReportMessage.put("currentBatch", currentBatchRef.toString());
+    return allReportMessage;
+  }
+}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/broker/SubscriptionPrefetchingTabletsQueue.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/broker/SubscriptionPrefetchingTabletsQueue.java
deleted file mode 100644
index 67b78e6a046..00000000000
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/broker/SubscriptionPrefetchingTabletsQueue.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.subscription.broker;
-
-import org.apache.iotdb.commons.pipe.event.EnrichedEvent;
-import org.apache.iotdb.commons.pipe.task.connection.UnboundedBlockingPendingQueue;
-import org.apache.iotdb.commons.subscription.config.SubscriptionConfig;
-import org.apache.iotdb.db.pipe.event.UserDefinedEnrichedEvent;
-import org.apache.iotdb.db.pipe.event.common.tablet.PipeInsertNodeTabletInsertionEvent;
-import org.apache.iotdb.db.pipe.event.common.tablet.PipeRawTabletInsertionEvent;
-import org.apache.iotdb.db.pipe.event.common.terminate.PipeTerminateEvent;
-import org.apache.iotdb.db.pipe.event.common.tsfile.PipeTsFileInsertionEvent;
-import org.apache.iotdb.db.pipe.resource.memory.PipeMemoryWeightUtil;
-import org.apache.iotdb.db.subscription.event.SubscriptionEvent;
-import org.apache.iotdb.db.subscription.event.SubscriptionEventBinaryCache;
-import org.apache.iotdb.pipe.api.event.Event;
-import org.apache.iotdb.pipe.api.event.dml.insertion.TabletInsertionEvent;
-import org.apache.iotdb.rpc.subscription.payload.poll.SubscriptionCommitContext;
-import org.apache.iotdb.rpc.subscription.payload.poll.SubscriptionPollResponse;
-import org.apache.iotdb.rpc.subscription.payload.poll.SubscriptionPollResponseType;
-import org.apache.iotdb.rpc.subscription.payload.poll.TabletsPayload;
-
-import org.apache.tsfile.write.record.Tablet;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Objects;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
-
-public class SubscriptionPrefetchingTabletsQueue extends SubscriptionPrefetchingQueue {
-
-  private static final Logger LOGGER =
-      LoggerFactory.getLogger(SubscriptionPrefetchingTabletsQueue.class);
-
-  private final LinkedBlockingQueue<SubscriptionEvent> prefetchingQueue;
-
-  public SubscriptionPrefetchingTabletsQueue(
-      final String brokerId,
-      final String topicName,
-      final UnboundedBlockingPendingQueue<Event> inputPendingQueue) {
-    super(brokerId, topicName, inputPendingQueue);
-
-    this.prefetchingQueue = new LinkedBlockingQueue<>();
-  }
-
-  @Override
-  public void cleanup() {
-    super.cleanup();
-
-    // no need to clean up events in prefetchingQueue, since all events in prefetchingQueue are also
-    // in uncommittedEvents
-    prefetchingQueue.clear();
-  }
-
-  @Override
-  public SubscriptionEvent poll(final String consumerId) {
-    if (prefetchingQueue.isEmpty()) {
-      prefetchOnce();
-    }
-
-    final long size = prefetchingQueue.size();
-    long count = 0;
-
-    SubscriptionEvent currentEvent;
-    try {
-      while (count++ < size // limit control
-          && Objects.nonNull(
-              currentEvent =
-                  prefetchingQueue.poll(
-                      SubscriptionConfig.getInstance().getSubscriptionPollMaxBlockingTimeMs(),
-                      TimeUnit.MILLISECONDS))) {
-        if (currentEvent.isCommitted()) {
-          continue;
-        }
-        if (!currentEvent.pollable()) {
-          // Re-enqueue the uncommitted event at the end of the queue.
-          prefetchingQueue.add(currentEvent);
-          continue;
-        }
-        currentEvent.recordLastPolledConsumerId(consumerId);
-        currentEvent.recordLastPolledTimestamp();
-        // Re-enqueue the uncommitted event at the end of the queue.
-        // This operation should be performed after recordLastPolledTimestamp to prevent multiple
-        // consumers from consuming the same event.
-        prefetchingQueue.add(currentEvent);
-        return currentEvent;
-      }
-    } catch (final InterruptedException e) {
-      Thread.currentThread().interrupt();
-      LOGGER.warn(
-          "Subscription: SubscriptionPrefetchingTabletsQueue {} interrupted while polling events.",
-          this,
-          e);
-    }
-
-    return null;
-  }
-
-  @Override
-  public void executePrefetch() {
-    prefetchOnce();
-    serializeOnce();
-  }
-
-  private void prefetchOnce() {
-    final List<Tablet> tablets = new ArrayList<>();
-    final List<EnrichedEvent> enrichedEvents = new ArrayList<>();
-    long calculatedTabletsSizeInBytes = 0;
-
-    Event event;
-    while (Objects.nonNull(
-        event = UserDefinedEnrichedEvent.maybeOf(inputPendingQueue.waitedPoll()))) {
-      if (!(event instanceof EnrichedEvent)) {
-        LOGGER.warn(
-            "Subscription: SubscriptionPrefetchingTabletsQueue {} only support prefetch EnrichedEvent. Ignore {}.",
-            this,
-            event);
-        continue;
-      }
-
-      if (event instanceof PipeTerminateEvent) {
-        LOGGER.info(
-            "Subscription: SubscriptionPrefetchingTabletsQueue {} commit PipeTerminateEvent {}",
-            this,
-            event);
-        // commit directly
-        ((PipeTerminateEvent) event)
-            .decreaseReferenceCount(SubscriptionPrefetchingTsFileQueue.class.getName(), true);
-        continue;
-      }
-
-      if (event instanceof TabletInsertionEvent) {
-        final List<Tablet> currentTablets = convertToTablets((TabletInsertionEvent) event);
-        if (currentTablets.isEmpty()) {
-          continue;
-        }
-        tablets.addAll(currentTablets);
-        calculatedTabletsSizeInBytes +=
-            currentTablets.stream()
-                .map((PipeMemoryWeightUtil::calculateTabletSizeInBytes))
-                .reduce(Long::sum)
-                .orElse(0L);
-        enrichedEvents.add((EnrichedEvent) event);
-      } else if (event instanceof PipeTsFileInsertionEvent) {
-        for (final TabletInsertionEvent tabletInsertionEvent :
-            ((PipeTsFileInsertionEvent) event).toTabletInsertionEvents()) {
-          final List<Tablet> currentTablets = convertToTablets(tabletInsertionEvent);
-          if (Objects.isNull(currentTablets)) {
-            continue;
-          }
-          tablets.addAll(currentTablets);
-          calculatedTabletsSizeInBytes +=
-              currentTablets.stream()
-                  .map((PipeMemoryWeightUtil::calculateTabletSizeInBytes))
-                  .reduce(Long::sum)
-                  .orElse(0L);
-        }
-        enrichedEvents.add((EnrichedEvent) event);
-      } else {
-        // TODO:
-        //  - PipeHeartbeatEvent: ignored? (may affect pipe metrics)
-        //  - UserDefinedEnrichedEvent: ignored?
-        //  - Others: events related to meta sync, safe to ignore
-        LOGGER.warn(
-            "Subscription: SubscriptionPrefetchingTabletsQueue {} ignore EnrichedEvent {} when prefetching.",
-            this,
-            event);
-      }
-
-      if (tablets.size()
-          >= SubscriptionConfig.getInstance().getSubscriptionMaxTabletsPerPrefetching()) {
-        break;
-      }
-
-      if (calculatedTabletsSizeInBytes
-          >= SubscriptionConfig.getInstance()
-              .getSubscriptionMaxTabletsSizeInBytesPerPrefetching()) {
-        break;
-      }
-    }
-
-    if (!tablets.isEmpty()) {
-      final SubscriptionCommitContext commitContext = generateSubscriptionCommitContext();
-      final SubscriptionEvent subscriptionEvent =
-          new SubscriptionEvent(
-              enrichedEvents,
-              new SubscriptionPollResponse(
-                  SubscriptionPollResponseType.TABLETS.getType(),
-                  new TabletsPayload(tablets, calculatedTabletsSizeInBytes),
-                  commitContext));
-      uncommittedEvents.put(commitContext, subscriptionEvent); // before enqueuing the event
-      prefetchingQueue.add(subscriptionEvent);
-    }
-  }
-
-  private void serializeOnce() {
-    final long size = prefetchingQueue.size();
-    long count = 0;
-
-    SubscriptionEvent currentEvent;
-    try {
-      while (count++ < size // limit control
-          && Objects.nonNull(
-              currentEvent =
-                  prefetchingQueue.poll(
-                      SubscriptionConfig.getInstance().getSubscriptionSerializeMaxBlockingTimeMs(),
-                      TimeUnit.MILLISECONDS))) {
-        if (currentEvent.isCommitted()) {
-          continue;
-        }
-        // Serialize the uncommitted and pollable event.
-        if (currentEvent.pollable()) {
-          // No need to concern whether serialization is successful.
-          SubscriptionEventBinaryCache.getInstance().trySerialize(currentEvent);
-        }
-        // Re-enqueue the uncommitted event at the end of the queue.
-        prefetchingQueue.add(currentEvent);
-      }
-    } catch (final InterruptedException e) {
-      Thread.currentThread().interrupt();
-      LOGGER.warn(
-          "Subscription: SubscriptionPrefetchingTabletsQueue {} interrupted while serializing events.",
-          this,
-          e);
-    }
-  }
-
-  /////////////////////////////// utility ///////////////////////////////
-
-  private List<Tablet> convertToTablets(final TabletInsertionEvent tabletInsertionEvent) {
-    if (tabletInsertionEvent instanceof PipeInsertNodeTabletInsertionEvent) {
-      return ((PipeInsertNodeTabletInsertionEvent) tabletInsertionEvent).convertToTablets();
-    } else if (tabletInsertionEvent instanceof PipeRawTabletInsertionEvent) {
-      return Collections.singletonList(
-          ((PipeRawTabletInsertionEvent) tabletInsertionEvent).convertToTablet());
-    }
-
-    LOGGER.warn(
-        "Subscription: SubscriptionPrefetchingTabletsQueue {} only support convert PipeInsertNodeTabletInsertionEvent or PipeRawTabletInsertionEvent to tablet. Ignore {}.",
-        this,
-        tabletInsertionEvent);
-    return Collections.emptyList();
-  }
-}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/broker/SubscriptionPrefetchingTsFileQueue.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/broker/SubscriptionPrefetchingTsFileQueue.java
index dbb68809681..43aab7f8189 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/broker/SubscriptionPrefetchingTsFileQueue.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/broker/SubscriptionPrefetchingTsFileQueue.java
@@ -19,41 +19,50 @@
 
 package org.apache.iotdb.db.subscription.broker;
 
-import org.apache.iotdb.commons.pipe.event.EnrichedEvent;
 import org.apache.iotdb.commons.pipe.task.connection.UnboundedBlockingPendingQueue;
-import org.apache.iotdb.db.pipe.event.UserDefinedEnrichedEvent;
-import org.apache.iotdb.db.pipe.event.common.terminate.PipeTerminateEvent;
+import org.apache.iotdb.commons.subscription.config.SubscriptionConfig;
 import org.apache.iotdb.db.pipe.event.common.tsfile.PipeTsFileInsertionEvent;
 import org.apache.iotdb.db.subscription.event.SubscriptionEvent;
-import org.apache.iotdb.db.subscription.event.SubscriptionEventBinaryCache;
-import org.apache.iotdb.db.subscription.event.SubscriptionTsFileEvent;
+import org.apache.iotdb.db.subscription.event.batch.SubscriptionPipeTsFileEventBatch;
+import org.apache.iotdb.db.subscription.event.pipe.SubscriptionPipeTsFileBatchEvents;
+import org.apache.iotdb.db.subscription.event.pipe.SubscriptionPipeTsFilePlainEvent;
 import org.apache.iotdb.pipe.api.event.Event;
 import org.apache.iotdb.pipe.api.event.dml.insertion.TabletInsertionEvent;
 import org.apache.iotdb.rpc.subscription.payload.poll.FileInitPayload;
 import org.apache.iotdb.rpc.subscription.payload.poll.FilePiecePayload;
-import org.apache.iotdb.rpc.subscription.payload.poll.FileSealPayload;
 import org.apache.iotdb.rpc.subscription.payload.poll.SubscriptionCommitContext;
 import org.apache.iotdb.rpc.subscription.payload.poll.SubscriptionPollPayload;
 import org.apache.iotdb.rpc.subscription.payload.poll.SubscriptionPollResponse;
 import org.apache.iotdb.rpc.subscription.payload.poll.SubscriptionPollResponseType;
 
-import org.apache.tsfile.utils.Pair;
 import org.checkerframework.checker.nullness.qual.NonNull;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.File;
 import java.io.IOException;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
 
 public class SubscriptionPrefetchingTsFileQueue extends SubscriptionPrefetchingQueue {
 
   private static final Logger LOGGER =
       LoggerFactory.getLogger(SubscriptionPrefetchingTsFileQueue.class);
 
-  private final Map<String, SubscriptionTsFileEvent> consumerIdToCurrentEventMap;
+  private static final int BATCH_MAX_DELAY_IN_MS =
+      SubscriptionConfig.getInstance().getSubscriptionPrefetchTsFileBatchMaxDelayInMs();
+  private static final long BATCH_MAX_SIZE_IN_BYTES =
+      SubscriptionConfig.getInstance().getSubscriptionPrefetchTsFileBatchMaxSizeInBytes();
+
+  private final Map<String, SubscriptionEvent> consumerIdToSubscriptionEventMap;
+
+  private final AtomicReference<SubscriptionPipeTsFileEventBatch> currentBatchRef =
+      new AtomicReference<>();
 
   public SubscriptionPrefetchingTsFileQueue(
       final String brokerId,
@@ -61,7 +70,9 @@ public class SubscriptionPrefetchingTsFileQueue extends SubscriptionPrefetchingQ
       final UnboundedBlockingPendingQueue<Event> inputPendingQueue) {
     super(brokerId, topicName, inputPendingQueue);
 
-    this.consumerIdToCurrentEventMap = new ConcurrentHashMap<>();
+    this.consumerIdToSubscriptionEventMap = new ConcurrentHashMap<>();
+    this.currentBatchRef.set(
+        new SubscriptionPipeTsFileEventBatch(BATCH_MAX_DELAY_IN_MS, BATCH_MAX_SIZE_IN_BYTES));
   }
 
   @Override
@@ -69,14 +80,17 @@ public class SubscriptionPrefetchingTsFileQueue extends SubscriptionPrefetchingQ
     super.cleanup();
 
     // clean up events in consumerIdToCurrentEventMap
-    consumerIdToCurrentEventMap
-        .values()
-        .forEach(
-            (event) -> {
-              event.clearReferenceCount();
-              SubscriptionEventBinaryCache.getInstance().resetByteBuffer(event, true);
-            });
-    consumerIdToCurrentEventMap.clear();
+    consumerIdToSubscriptionEventMap.values().forEach(SubscriptionEvent::cleanup);
+    consumerIdToSubscriptionEventMap.clear();
+
+    // clean up batch
+    currentBatchRef.getAndUpdate(
+        (batch) -> {
+          if (Objects.nonNull(batch)) {
+            batch.cleanup();
+          }
+          return null;
+        });
   }
 
   @Override
@@ -85,72 +99,24 @@ public class SubscriptionPrefetchingTsFileQueue extends SubscriptionPrefetchingQ
       return null;
     }
 
-    final SubscriptionTsFileEvent pollableEvent =
-        getPollableOnTheFlySubscriptionTsFileEvent(consumerId);
+    final SubscriptionEvent pollableEvent = getPollableOnTheFlySubscriptionTsFileEvent(consumerId);
     if (Objects.nonNull(pollableEvent)) {
       return pollableEvent;
     }
 
-    Event event;
-    while (Objects.nonNull(
-        event = UserDefinedEnrichedEvent.maybeOf(inputPendingQueue.waitedPoll()))) {
-      if (!(event instanceof EnrichedEvent)) {
-        LOGGER.warn(
-            "Subscription: SubscriptionPrefetchingTsFileQueue {} only support poll EnrichedEvent. Ignore {}.",
-            this,
-            event);
-        continue;
-      }
-
-      if (event instanceof PipeTerminateEvent) {
-        LOGGER.info(
-            "Subscription: SubscriptionPrefetchingTsFileQueue {} commit PipeTerminateEvent {}",
-            this,
-            event);
-        // commit directly
-        ((PipeTerminateEvent) event)
-            .decreaseReferenceCount(SubscriptionPrefetchingTsFileQueue.class.getName(), true);
-        continue;
-      }
-
-      if (event instanceof TabletInsertionEvent) {
-        final String errorMessage =
-            String.format(
-                "A TabletInsertionEvent was pulled from topic %s which is formatted as TsFile by SubscriptionPrefetchingTsFileQueue %s. This event %s will be ignored. Please check the topic configuration.",
-                topicName, this, event);
-        LOGGER.warn(errorMessage);
-        return generateSubscriptionPollErrorResponse(errorMessage, true);
-      }
-
-      if (!(event instanceof PipeTsFileInsertionEvent)) {
-        LOGGER.warn(
-            "Subscription: SubscriptionPrefetchingTsFileQueue {} only support poll PipeTsFileInsertionEvent. Ignore {}.",
-            this,
-            event);
-        continue;
-      }
-
-      final PipeTsFileInsertionEvent tsFileInsertionEvent = (PipeTsFileInsertionEvent) event;
-      final SubscriptionCommitContext commitContext = generateSubscriptionCommitContext();
-
-      // update current event
-      final SubscriptionTsFileEvent subscriptionEvent =
-          SubscriptionTsFileEvent.generateSubscriptionTsFileEventWithInitPayload(
-              tsFileInsertionEvent, commitContext);
-      consumerIdToCurrentEventMap.put(consumerId, subscriptionEvent);
-
-      subscriptionEvent.recordLastPolledConsumerId(consumerId);
-      subscriptionEvent.recordLastPolledTimestamp();
-      return subscriptionEvent;
+    // At this point, the event that might be polled should not have been polled by any consumer.
+    final SubscriptionEvent event = super.poll(consumerId);
+    if (Objects.nonNull(event)) {
+      consumerIdToSubscriptionEventMap.put(consumerId, event);
     }
 
-    return null;
+    return event;
   }
 
   public synchronized @NonNull SubscriptionEvent pollTsFile(
       final String consumerId, final String fileName, final long writingOffset) {
     // 1. Extract current event and check it
-    final SubscriptionTsFileEvent event = consumerIdToCurrentEventMap.get(consumerId);
+    final SubscriptionEvent event = consumerIdToSubscriptionEventMap.get(consumerId);
     if (Objects.isNull(event)) {
       final String errorMessage =
           String.format(
@@ -161,7 +127,8 @@ public class SubscriptionPrefetchingTsFileQueue extends SubscriptionPrefetchingQ
     }
 
     if (event.isCommitted()) {
-      consumerIdToCurrentEventMap.remove(consumerId);
+      event.cleanup();
+      consumerIdToSubscriptionEventMap.remove(consumerId);
       final String errorMessage =
           String.format(
               "SubscriptionEvent %s related to TsFile is committed, consumer: %s, writing offset: %s, prefetching queue: %s",
@@ -180,25 +147,19 @@ public class SubscriptionPrefetchingTsFileQueue extends SubscriptionPrefetchingQ
       return generateSubscriptionPollErrorResponse(errorMessage);
     }
 
-    final List<EnrichedEvent> enrichedEvents = event.getEnrichedEvents();
-    final PipeTsFileInsertionEvent tsFileInsertionEvent =
-        (PipeTsFileInsertionEvent) enrichedEvents.get(0);
+    final File tsFile = event.getTsFile();
 
     // check file name
-    if (!fileName.startsWith(tsFileInsertionEvent.getTsFile().getName())) {
+    if (!fileName.startsWith(tsFile.getName())) {
       final String errorMessage =
           String.format(
               "inconsistent file name, current: %s, incoming: %s, consumer: %s, writing offset: %s, prefetching queue: %s",
-              tsFileInsertionEvent.getTsFile().getName(),
-              fileName,
-              consumerId,
-              writingOffset,
-              this);
+              tsFile.getName(), fileName, consumerId, writingOffset, this);
       LOGGER.warn(errorMessage);
       return generateSubscriptionPollErrorResponse(errorMessage);
     }
 
-    final SubscriptionPollResponse response = event.getResponse();
+    final SubscriptionPollResponse response = event.getCurrentResponse();
     final SubscriptionPollPayload payload = response.getPayload();
 
     // 2. Check previous response type, file name and offset
@@ -226,12 +187,12 @@ public class SubscriptionPrefetchingTsFileQueue extends SubscriptionPrefetchingQ
         }
         // check offset
         if (writingOffset != 0) {
-          LOGGER.warn(
-              "SubscriptionPrefetchingTsFileQueue {} set TsFile (with event {}) writing offset to {} for consumer {}",
-              this,
-              event,
-              writingOffset,
-              consumerId);
+          final String errorMessage =
+              String.format(
+                  "inconsistent offset, current: %s, incoming: %s, consumer: %s, file name: %s, prefetching queue: %s",
+                  0, writingOffset, consumerId, fileName, this);
+          LOGGER.warn(errorMessage);
+          return generateSubscriptionPollErrorResponse(errorMessage);
         }
         break;
       case FILE_PIECE:
@@ -250,99 +211,158 @@ public class SubscriptionPrefetchingTsFileQueue extends SubscriptionPrefetchingQ
         }
         // check offset
         if (writingOffset != ((FilePiecePayload) payload).getNextWritingOffset()) {
-          LOGGER.warn(
-              "SubscriptionPrefetchingTsFileQueue {} set TsFile (with event {}) writing offset to {} for consumer {}",
-              this,
-              event,
-              writingOffset,
-              consumerId);
-        }
-        break;
-      case FILE_SEAL:
-        // check file name
-        if (!fileName.startsWith(((FileSealPayload) payload).getFileName())) {
           final String errorMessage =
               String.format(
-                  "inconsistent file name, current: %s, incoming: %s, consumer: %s, writing offset: %s, prefetching queue: %s",
-                  ((FileSealPayload) payload).getFileName(),
-                  fileName,
-                  consumerId,
+                  "inconsistent offset, current: %s, incoming: %s, consumer: %s, file name: %s, prefetching queue: %s",
+                  ((FilePiecePayload) payload).getNextWritingOffset(),
                   writingOffset,
+                  consumerId,
+                  fileName,
                   this);
           LOGGER.warn(errorMessage);
           return generateSubscriptionPollErrorResponse(errorMessage);
         }
-
-        LOGGER.warn(
-            "SubscriptionPrefetchingTsFileQueue {} set TsFile (with event {}) writing offset to {} after transferring seal signal to consumer {}",
-            this,
-            event,
-            writingOffset,
-            consumerId);
-        // mark uncommittable
-        uncommittedEvents.remove(response.getCommitContext());
         break;
+      case FILE_SEAL:
+        {
+          final String errorMessage =
+              String.format(
+                  "poll after sealing, consumer: %s, file name: %s, writing offset: %s, prefetching queue: %s",
+                  consumerId, fileName, writingOffset, this);
+          LOGGER.warn(errorMessage);
+          return generateSubscriptionPollErrorResponse(errorMessage);
+        }
       default:
-        final String errorMessage = String.format("unexpected response type: %s", responseType);
-        LOGGER.warn(errorMessage);
-        return generateSubscriptionPollErrorResponse(errorMessage);
+        {
+          final String errorMessage = String.format("unexpected response type: %s", responseType);
+          LOGGER.warn(errorMessage);
+          return generateSubscriptionPollErrorResponse(errorMessage);
+        }
     }
 
     // 3. Poll tsfile piece or tsfile seal
-    return pollTsFile(consumerId, writingOffset, event);
+    try {
+      event.fetchNextResponse();
+    } catch (final Exception e) {
+      final String errorMessage =
+          String.format(
+              "Exception occurred when SubscriptionPrefetchingTsFileQueue %s transferring TsFile (with event %s) to consumer %s: %s",
+              this, event, consumerId, e);
+      LOGGER.warn(errorMessage);
+      return generateSubscriptionPollErrorResponse(errorMessage);
+    }
+
+    event.recordLastPolledConsumerId(consumerId);
+    event.recordLastPolledTimestamp();
+    return event;
   }
 
-  private synchronized @NonNull SubscriptionEvent pollTsFile(
-      final String consumerId, final long writingOffset, final SubscriptionTsFileEvent event) {
-    Pair<SubscriptionTsFileEvent, Boolean> newEventWithCommittable =
-        event.matchOrResetNext(writingOffset);
-    if (Objects.isNull(newEventWithCommittable)) {
-      try {
-        newEventWithCommittable =
-            event.generateSubscriptionTsFileEventWithPieceOrSealPayload(writingOffset);
-      } catch (final IOException e) {
-        final String errorMessage =
-            String.format(
-                "IOException occurred when SubscriptionPrefetchingTsFileQueue %s transferring TsFile (with event %s) to consumer %s: %s",
-                this, event, consumerId, e);
-        LOGGER.warn(errorMessage);
-        return generateSubscriptionPollErrorResponse(errorMessage);
-      }
-    }
+  @Override
+  protected boolean onEvent(final TabletInsertionEvent event) {
+    final AtomicBoolean result = new AtomicBoolean(false);
+    currentBatchRef.getAndUpdate(
+        (batch) -> {
+          try {
+            if (batch.onEvent(event)) {
+              sealBatch(batch);
+              result.set(true);
+              return new SubscriptionPipeTsFileEventBatch(
+                  BATCH_MAX_DELAY_IN_MS, BATCH_MAX_SIZE_IN_BYTES);
+            }
+            return batch;
+          } catch (final Exception e) {
+            LOGGER.warn(
+                "Exception occurred when SubscriptionPrefetchingTsFileQueue {} sealing tsFiles from batch",
+                this,
+                e);
+            return batch;
+          }
+        });
+    return result.get();
+  }
+
+  @Override
+  protected boolean onEvent(final PipeTsFileInsertionEvent event) {
+    final SubscriptionCommitContext commitContext = generateSubscriptionCommitContext();
+    final SubscriptionEvent subscriptionEvent =
+        new SubscriptionEvent(
+            new SubscriptionPipeTsFilePlainEvent(event),
+            new SubscriptionPollResponse(
+                SubscriptionPollResponseType.FILE_INIT.getType(),
+                new FileInitPayload(event.getTsFile().getName()),
+                commitContext));
+    uncommittedEvents.put(commitContext, subscriptionEvent); // before enqueuing the event
+    prefetchingQueue.add(subscriptionEvent);
+    return true;
+  }
 
-    // remove outdated event
-    consumerIdToCurrentEventMap.remove(consumerId);
+  @Override
+  protected boolean trySealBatch() {
+    final AtomicBoolean result = new AtomicBoolean(false);
+    currentBatchRef.getAndUpdate(
+        (batch) -> {
+          try {
+            if (batch.shouldEmit()) {
+              sealBatch(batch);
+              result.set(true);
+              return new SubscriptionPipeTsFileEventBatch(
+                  BATCH_MAX_DELAY_IN_MS, BATCH_MAX_SIZE_IN_BYTES);
+            }
+            return batch;
+          } catch (final Exception e) {
+            LOGGER.warn(
+                "Exception occurred when SubscriptionPrefetchingTsFileQueue {} sealing TsFile from batch",
+                this,
+                e);
+            return batch;
+          }
+        });
+    return result.get();
+  }
 
-    // update current event
-    final SubscriptionTsFileEvent newEvent = newEventWithCommittable.getLeft();
-    consumerIdToCurrentEventMap.put(consumerId, newEvent);
-    if (newEventWithCommittable.getRight()) {
-      // mark committable
-      uncommittedEvents.put(newEvent.getResponse().getCommitContext(), newEvent);
+  private void sealBatch(final SubscriptionPipeTsFileEventBatch batch) throws Exception {
+    final List<File> tsFiles = batch.sealTsFiles();
+    final AtomicInteger referenceCount = new AtomicInteger(tsFiles.size());
+    for (final File tsFile : tsFiles) {
+      final SubscriptionCommitContext commitContext = generateSubscriptionCommitContext();
+      final SubscriptionEvent subscriptionEvent =
+          new SubscriptionEvent(
+              new SubscriptionPipeTsFileBatchEvents(batch, tsFile, referenceCount),
+              new SubscriptionPollResponse(
+                  SubscriptionPollResponseType.FILE_INIT.getType(),
+                  new FileInitPayload(tsFile.getName()),
+                  commitContext));
+      uncommittedEvents.put(commitContext, subscriptionEvent); // before enqueuing the event
+      prefetchingQueue.add(subscriptionEvent);
     }
-
-    newEvent.recordLastPolledConsumerId(consumerId);
-    newEvent.recordLastPolledTimestamp();
-    return newEvent;
   }
 
   @Override
   public synchronized void executePrefetch() {
-    consumerIdToCurrentEventMap.values().forEach(SubscriptionTsFileEvent::prefetchNext);
-    consumerIdToCurrentEventMap.values().forEach(SubscriptionTsFileEvent::serializeNext);
+    tryPrefetch();
+
+    // prefetch remaining subscription events based on {@link consumerIdToSubscriptionEventMap}
+    for (final SubscriptionEvent event : consumerIdToSubscriptionEventMap.values()) {
+      try {
+        event.prefetchRemainingResponses();
+        event.trySerializeRemainingResponses();
+      } catch (final IOException ignored) {
+      }
+    }
   }
 
   /////////////////////////////// utility ///////////////////////////////
 
   private synchronized boolean hasUnPollableOnTheFlySubscriptionTsFileEvent(
       final String consumerId) {
-    final SubscriptionTsFileEvent event = consumerIdToCurrentEventMap.get(consumerId);
+    final SubscriptionEvent event = consumerIdToSubscriptionEventMap.get(consumerId);
     if (Objects.isNull(event)) {
       return false;
     }
 
     if (event.isCommitted()) {
-      consumerIdToCurrentEventMap.remove(consumerId);
+      event.cleanup();
+      consumerIdToSubscriptionEventMap.remove(consumerId);
       return false;
     }
 
@@ -358,38 +378,31 @@ public class SubscriptionPrefetchingTsFileQueue extends SubscriptionPrefetchingQ
     return false;
   }
 
-  private synchronized SubscriptionTsFileEvent getPollableOnTheFlySubscriptionTsFileEvent(
+  private synchronized SubscriptionEvent getPollableOnTheFlySubscriptionTsFileEvent(
       final String consumerId) {
-    for (final Map.Entry<String, SubscriptionTsFileEvent> entry :
-        consumerIdToCurrentEventMap.entrySet()) {
-      final SubscriptionTsFileEvent currentEvent = entry.getValue();
-      if (currentEvent.isCommitted()) {
-        consumerIdToCurrentEventMap.remove(entry.getKey());
+    for (final Map.Entry<String, SubscriptionEvent> entry :
+        consumerIdToSubscriptionEventMap.entrySet()) {
+      final SubscriptionEvent event = entry.getValue();
+      if (event.isCommitted()) {
+        event.cleanup();
+        consumerIdToSubscriptionEventMap.remove(entry.getKey());
         continue;
       }
 
-      if (!currentEvent.pollable()) {
-        LOGGER.info(
-            "SubscriptionPrefetchingTsFileQueue {} is currently transferring TsFile (with event {}) to consumer {}",
-            this,
-            currentEvent,
-            entry.getKey());
+      if (!event.pollable()) {
         continue;
       }
 
       // uncommitted and pollable event
 
-      // remove outdated event
-      consumerIdToCurrentEventMap.remove(entry.getKey());
+      consumerIdToSubscriptionEventMap.remove(entry.getKey());
 
-      // update current event
-      final SubscriptionTsFileEvent newEvent =
-          currentEvent.generateSubscriptionTsFileEventWithInitPayload();
-      consumerIdToCurrentEventMap.put(consumerId, newEvent);
+      event.resetCurrentResponseIndex();
+      consumerIdToSubscriptionEventMap.put(consumerId, event);
 
-      newEvent.recordLastPolledConsumerId(consumerId);
-      newEvent.recordLastPolledTimestamp();
-      return newEvent;
+      event.recordLastPolledConsumerId(consumerId);
+      event.recordLastPolledTimestamp();
+      return event;
     }
 
     return null;
@@ -399,4 +412,20 @@ public class SubscriptionPrefetchingTsFileQueue extends SubscriptionPrefetchingQ
     // consider non-critical by default, meaning the client can retry
     return super.generateSubscriptionPollErrorResponse(errorMessage, false);
   }
+
+  /////////////////////////////// stringify ///////////////////////////////
+
+  @Override
+  public String toString() {
+    return "SubscriptionPrefetchingTsFileQueue" + this.coreReportMessage();
+  }
+
+  @Override
+  protected Map<String, String> allReportMessage() {
+    final Map<String, String> allReportMessage = super.allReportMessage();
+    allReportMessage.put(
+        "consumerIdToSubscriptionEventMap", consumerIdToSubscriptionEventMap.toString());
+    allReportMessage.put("currentBatch", currentBatchRef.toString());
+    return allReportMessage;
+  }
 }
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/SubscriptionEvent.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/SubscriptionEvent.java
index 0f7feb08e95..c4cfac361c7 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/SubscriptionEvent.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/SubscriptionEvent.java
@@ -19,45 +19,99 @@
 
 package org.apache.iotdb.db.subscription.event;
 
-import org.apache.iotdb.commons.pipe.event.EnrichedEvent;
 import org.apache.iotdb.commons.subscription.config.SubscriptionConfig;
+import org.apache.iotdb.db.subscription.event.pipe.SubscriptionPipeEvents;
+import org.apache.iotdb.rpc.subscription.payload.poll.FilePiecePayload;
+import org.apache.iotdb.rpc.subscription.payload.poll.FileSealPayload;
+import org.apache.iotdb.rpc.subscription.payload.poll.SubscriptionCommitContext;
+import org.apache.iotdb.rpc.subscription.payload.poll.SubscriptionPollPayload;
 import org.apache.iotdb.rpc.subscription.payload.poll.SubscriptionPollResponse;
+import org.apache.iotdb.rpc.subscription.payload.poll.SubscriptionPollResponseType;
 
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
 import java.io.IOException;
+import java.io.RandomAccessFile;
 import java.nio.ByteBuffer;
-import java.util.List;
+import java.util.Arrays;
 import java.util.Objects;
+import java.util.Optional;
 import java.util.stream.Collectors;
 
+import static org.apache.iotdb.rpc.subscription.payload.poll.SubscriptionCommitContext.INVALID_COMMIT_ID;
+
 public class SubscriptionEvent {
 
+  private static final Logger LOGGER = LoggerFactory.getLogger(SubscriptionEvent.class);
+
   private static final long INVALID_TIMESTAMP = -1;
 
-  protected final List<EnrichedEvent> enrichedEvents;
-  protected final SubscriptionPollResponse response;
+  private final SubscriptionPipeEvents pipeEvents;
+
+  private final SubscriptionPollResponse[] responses;
+  private int currentResponseIndex;
+
+  private final ByteBuffer[] byteBuffers; // serialized responses
+  private final SubscriptionCommitContext
+      commitContext; // all responses have the same commit context
 
   private String lastPolledConsumerId;
   private long lastPolledTimestamp;
   private long committedTimestamp;
 
-  protected ByteBuffer byteBuffer; // serialized SubscriptionPollResponse
-
   public SubscriptionEvent(
-      final List<EnrichedEvent> enrichedEvents, final SubscriptionPollResponse response) {
-    this.enrichedEvents = enrichedEvents;
-    this.response = response;
+      final SubscriptionPipeEvents pipeEvents, final SubscriptionPollResponse initialResponse) {
+    this.pipeEvents = pipeEvents;
+
+    final int responseLength = getResponseLength(initialResponse.getResponseType());
+    this.responses = new SubscriptionPollResponse[responseLength];
+    this.responses[0] = initialResponse;
+    this.currentResponseIndex = 0;
+
+    this.byteBuffers = new ByteBuffer[responseLength];
+    this.commitContext = initialResponse.getCommitContext();
 
     this.lastPolledConsumerId = null;
     this.lastPolledTimestamp = INVALID_TIMESTAMP;
     this.committedTimestamp = INVALID_TIMESTAMP;
   }
 
-  public List<EnrichedEvent> getEnrichedEvents() {
-    return enrichedEvents;
+  private int getResponseLength(final short responseType) {
+    if (!SubscriptionPollResponseType.isValidatedResponseType(responseType)) {
+      LOGGER.warn("unexpected response type: {}", responseType);
+      return 1;
+    }
+    switch (SubscriptionPollResponseType.valueOf(responseType)) {
+      case FILE_INIT:
+        final long tsFileLength = pipeEvents.getTsFile().length();
+        final long readFileBufferSize =
+            SubscriptionConfig.getInstance().getSubscriptionReadFileBufferSize();
+        final int length = (int) (tsFileLength / readFileBufferSize);
+        // add for init, last piece and seal
+        return (tsFileLength % readFileBufferSize != 0) ? length + 3 : length + 2;
+      case TABLETS:
+      case ERROR:
+      case TERMINATION:
+        return 1;
+      default:
+        LOGGER.warn("unexpected response type: {}", responseType);
+        return 1;
+    }
+  }
+
+  public SubscriptionPollResponse getCurrentResponse() {
+    return getResponse(currentResponseIndex);
+  }
+
+  public SubscriptionPollResponse getResponse(final int index) {
+    return responses[index];
   }
 
-  public SubscriptionPollResponse getResponse() {
-    return response;
+  public void resetCurrentResponseIndex() {
+    currentResponseIndex = 0;
   }
 
   //////////////////////////// commit ////////////////////////////
@@ -67,19 +121,31 @@ public class SubscriptionEvent {
   }
 
   public boolean isCommitted() {
+    if (commitContext.getCommitId() == INVALID_COMMIT_ID) {
+      // event with invalid commit id is committed
+      return true;
+    }
     return committedTimestamp != INVALID_TIMESTAMP;
   }
 
-  public void decreaseReferenceCount() {
-    for (final EnrichedEvent enrichedEvent : enrichedEvents) {
-      enrichedEvent.decreaseReferenceCount(this.getClass().getName(), true);
+  public boolean isCommittable() {
+    if (commitContext.getCommitId() == INVALID_COMMIT_ID) {
+      // event with invalid commit id is uncommittable
+      return false;
     }
+    return currentResponseIndex >= responses.length - 1;
   }
 
-  public void clearReferenceCount() {
-    for (final EnrichedEvent enrichedEvent : enrichedEvents) {
-      enrichedEvent.clearReferenceCount(this.getClass().getName());
-    }
+  public void ack() {
+    pipeEvents.ack();
+  }
+
+  public void cleanup() {
+    // reset serialized responses
+    resetResponseByteBuffer(true);
+
+    // clean up pipe events
+    pipeEvents.cleanup();
   }
 
   //////////////////////////// pollable ////////////////////////////
@@ -90,6 +156,7 @@ public class SubscriptionEvent {
 
   public boolean pollable() {
     if (isCommitted()) {
+      cleanup();
       return false;
     }
     if (lastPolledTimestamp == INVALID_TIMESTAMP) {
@@ -114,41 +181,192 @@ public class SubscriptionEvent {
     return lastPolledConsumerId;
   }
 
+  //////////////////////////// prefetch & fetch ////////////////////////////
+
+  /**
+   * @param index the index of response to be prefetched
+   */
+  private void prefetchResponse(final int index) throws IOException {
+    if (index >= responses.length || index <= 0) {
+      return;
+    }
+
+    if (Objects.nonNull(responses[index])) {
+      return;
+    }
+
+    final SubscriptionPollResponse previousResponse = this.getResponse(index - 1);
+    final short responseType = previousResponse.getResponseType();
+    final SubscriptionPollPayload payload = previousResponse.getPayload();
+    if (!SubscriptionPollResponseType.isValidatedResponseType(responseType)) {
+      LOGGER.warn("unexpected response type: {}", responseType);
+      return;
+    }
+
+    switch (SubscriptionPollResponseType.valueOf(responseType)) {
+      case FILE_INIT:
+        responses[index] = generateSubscriptionPollResponseWithPieceOrSealPayload(0);
+        break;
+      case FILE_PIECE:
+        responses[index] =
+            generateSubscriptionPollResponseWithPieceOrSealPayload(
+                ((FilePiecePayload) payload).getNextWritingOffset());
+        break;
+      case FILE_SEAL:
+        // not need to prefetch
+        return;
+      default:
+        LOGGER.warn("unexpected message type: {}", responseType);
+    }
+  }
+
+  public void prefetchRemainingResponses() throws IOException {
+    for (int currentIndex = currentResponseIndex;
+        currentIndex < responses.length - 1;
+        currentIndex++) {
+      if (Objects.isNull(responses[currentIndex + 1])) {
+        prefetchResponse(currentIndex + 1);
+        return;
+      }
+    }
+  }
+
+  public void fetchNextResponse() throws IOException {
+    if (currentResponseIndex >= responses.length - 1) {
+      LOGGER.warn("No more responses when fetching next response for {}, do nothing.", this);
+      return;
+    }
+    if (Objects.isNull(responses[currentResponseIndex + 1])) {
+      prefetchRemainingResponses();
+    }
+    currentResponseIndex++;
+  }
+
   //////////////////////////// byte buffer ////////////////////////////
 
-  public ByteBuffer serialize() throws IOException {
-    if (Objects.nonNull(byteBuffer)) {
-      return byteBuffer;
+  public void trySerializeRemainingResponses() {
+    for (int currentIndex = currentResponseIndex;
+        currentIndex < responses.length - 1;
+        currentIndex++) {
+      if (Objects.nonNull(responses[currentIndex + 1]) && trySerializeResponse(currentIndex + 1)) {
+        break;
+      }
     }
-    return SubscriptionPollResponse.serialize(response);
   }
 
-  public ByteBuffer getByteBuffer() {
-    return byteBuffer;
+  public boolean trySerializeCurrentResponse() {
+    return trySerializeResponse(currentResponseIndex);
+  }
+
+  /**
+   * @param index the index of response to be serialized
+   * @return {@code true} if a serialization operation was actually performed
+   */
+  public boolean trySerializeResponse(final int index) {
+    if (index >= responses.length) {
+      return false;
+    }
+
+    if (Objects.isNull(responses[index])) {
+      return false;
+    }
+
+    if (Objects.nonNull(byteBuffers[index])) {
+      return false;
+    }
+
+    final Optional<ByteBuffer> optionalByteBuffer =
+        SubscriptionEventBinaryCache.getInstance().trySerialize(responses[index]);
+    if (optionalByteBuffer.isPresent()) {
+      byteBuffers[index] = optionalByteBuffer.get();
+      return true;
+    }
+
+    return false;
+  }
+
+  public ByteBuffer getCurrentResponseByteBuffer() throws IOException {
+    if (Objects.nonNull(byteBuffers[currentResponseIndex])) {
+      return byteBuffers[currentResponseIndex];
+    }
+
+    return byteBuffers[currentResponseIndex] =
+        SubscriptionEventBinaryCache.getInstance().serialize(getCurrentResponse());
+  }
+
+  public void resetResponseByteBuffer(final boolean resetAll) {
+    if (resetAll) {
+      SubscriptionEventBinaryCache.getInstance().invalidateAll(Arrays.asList(responses));
+      // maybe friendly for gc
+      Arrays.fill(byteBuffers, null);
+    } else {
+      SubscriptionEventBinaryCache.getInstance().invalidate(responses[currentResponseIndex]);
+      // maybe friendly for gc
+      byteBuffers[currentResponseIndex] = null;
+    }
+  }
+
+  /////////////////////////////// tsfile ///////////////////////////////
+
+  public @NonNull SubscriptionPollResponse generateSubscriptionPollResponseWithPieceOrSealPayload(
+      final long writingOffset) throws IOException {
+    final File tsFile = pipeEvents.getTsFile();
+
+    final long readFileBufferSize =
+        SubscriptionConfig.getInstance().getSubscriptionReadFileBufferSize();
+    final byte[] readBuffer = new byte[(int) readFileBufferSize];
+    try (final RandomAccessFile reader = new RandomAccessFile(tsFile, "r")) {
+      while (true) {
+        reader.seek(writingOffset);
+        final int readLength = reader.read(readBuffer);
+        if (readLength == -1) {
+          break;
+        }
+
+        final byte[] filePiece =
+            readLength == readFileBufferSize
+                ? readBuffer
+                : Arrays.copyOfRange(readBuffer, 0, readLength);
+
+        // generate subscription poll response with piece payload
+        return new SubscriptionPollResponse(
+            SubscriptionPollResponseType.FILE_PIECE.getType(),
+            new FilePiecePayload(tsFile.getName(), writingOffset + readLength, filePiece),
+            commitContext);
+      }
+
+      // generate subscription poll response with seal payload
+      return new SubscriptionPollResponse(
+          SubscriptionPollResponseType.FILE_SEAL.getType(),
+          new FileSealPayload(tsFile.getName(), tsFile.length()),
+          commitContext);
+    }
   }
 
-  public void resetByteBuffer(final boolean recursive) {
-    // maybe friendly for gc
-    byteBuffer = null;
+  public File getTsFile() {
+    return pipeEvents.getTsFile();
   }
 
   /////////////////////////////// object ///////////////////////////////
 
   @Override
   public String toString() {
-    return "SubscriptionEvent{enrichedEvents="
-        + enrichedEvents.stream().map(EnrichedEvent::coreReportMessage).collect(Collectors.toList())
-        + ", response="
-        + response
+    return "SubscriptionEvent{pipeEvents="
+        + pipeEvents.toString()
+        + ", responses="
+        + Arrays.toString(responses)
+        + ", responses' byte buffer size="
+        + Arrays.stream(byteBuffers)
+            .map(byteBuffer -> Objects.isNull(byteBuffer) ? "<unknown>" : byteBuffer.limit())
+            .collect(Collectors.toList())
+        + ", currentResponseIndex="
+        + currentResponseIndex
         + ", lastPolledConsumerId="
         + lastPolledConsumerId
         + ", lastPolledTimestamp="
         + lastPolledTimestamp
         + ", committedTimestamp="
         + committedTimestamp
-        + "}"
-        + "(response event byte buffer size: "
-        + (Objects.nonNull(byteBuffer) ? byteBuffer.limit() : "<unknown>")
-        + ")";
+        + "}";
   }
 }
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/SubscriptionEventBinaryCache.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/SubscriptionEventBinaryCache.java
index b8bf26723c8..e2468f1281b 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/SubscriptionEventBinaryCache.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/SubscriptionEventBinaryCache.java
@@ -22,6 +22,7 @@ package org.apache.iotdb.db.subscription.event;
 import org.apache.iotdb.commons.pipe.config.PipeConfig;
 import org.apache.iotdb.db.pipe.resource.PipeDataNodeResourceManager;
 import org.apache.iotdb.db.pipe.resource.memory.PipeMemoryBlock;
+import org.apache.iotdb.rpc.subscription.payload.poll.SubscriptionPollResponse;
 
 import com.github.benmanes.caffeine.cache.Caffeine;
 import com.github.benmanes.caffeine.cache.LoadingCache;
@@ -32,48 +33,47 @@ import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.nio.ByteBuffer;
+import java.util.Optional;
 
-public class SubscriptionEventBinaryCache {
+/** This class is used to cache {@link SubscriptionPollResponse} in {@link SubscriptionEvent}. */
+class SubscriptionEventBinaryCache {
 
   private static final Logger LOGGER = LoggerFactory.getLogger(SubscriptionEventBinaryCache.class);
 
-  private final PipeMemoryBlock allocatedMemoryBlock;
-
   private final AtomicDouble memoryUsageCheatFactor = new AtomicDouble(1);
 
-  private final LoadingCache<SubscriptionEvent, ByteBuffer> cache;
+  private final LoadingCache<SubscriptionPollResponse, ByteBuffer> cache;
 
-  public ByteBuffer serialize(final SubscriptionEvent event) throws IOException {
+  ByteBuffer serialize(final SubscriptionPollResponse response) throws IOException {
     try {
-      return this.cache.get(event);
+      return this.cache.get(response);
     } catch (final Exception e) {
       LOGGER.warn(
-          "SubscriptionEventBinaryCache raised an exception while serializing SubscriptionEvent: {}",
-          event,
+          "SubscriptionEventBinaryCache raised an exception while serializing SubscriptionPollResponse: {}",
+          response,
           e);
       throw new IOException(e);
     }
   }
 
-  /**
-   * @return true -> byte buffer is not null
-   */
-  public boolean trySerialize(final SubscriptionEvent event) {
+  Optional<ByteBuffer> trySerialize(final SubscriptionPollResponse response) {
     try {
-      serialize(event);
-      return true;
+      return Optional.of(serialize(response));
     } catch (final IOException e) {
       LOGGER.warn(
-          "Subscription: something unexpected happened when serializing SubscriptionEvent: {}",
-          event,
+          "Subscription: something unexpected happened when serializing SubscriptionPollResponse: {}",
+          response,
           e);
-      return false;
+      return Optional.empty();
     }
   }
 
-  public void resetByteBuffer(final SubscriptionEvent message, final boolean recursive) {
-    message.resetByteBuffer(recursive);
-    this.cache.invalidate(message);
+  void invalidate(final SubscriptionPollResponse response) {
+    this.cache.invalidate(response);
+  }
+
+  void invalidateAll(final Iterable<SubscriptionPollResponse> responses) {
+    this.cache.invalidateAll(responses);
   }
 
   //////////////////////////// singleton ////////////////////////////
@@ -87,7 +87,7 @@ public class SubscriptionEventBinaryCache {
     }
   }
 
-  public static SubscriptionEventBinaryCache getInstance() {
+  static SubscriptionEventBinaryCache getInstance() {
     return SubscriptionEventBinaryCache.SubscriptionEventBinaryCacheHolder.INSTANCE;
   }
 
@@ -100,7 +100,7 @@ public class SubscriptionEventBinaryCache {
                 * PipeConfig.getInstance().getSubscriptionCacheMemoryUsagePercentage());
 
     // properties required by pipe memory control framework
-    this.allocatedMemoryBlock =
+    final PipeMemoryBlock allocatedMemoryBlock =
         PipeDataNodeResourceManager.memory()
             .tryAllocate(initMemorySizeInBytes)
             .setShrinkMethod(oldMemory -> Math.max(oldMemory / 2, 1))
@@ -127,14 +127,15 @@ public class SubscriptionEventBinaryCache {
 
     this.cache =
         Caffeine.newBuilder()
-            .maximumWeight(this.allocatedMemoryBlock.getMemoryUsageInBytes())
+            .maximumWeight(allocatedMemoryBlock.getMemoryUsageInBytes())
             .weigher(
-                (Weigher<SubscriptionEvent, ByteBuffer>)
+                (Weigher<SubscriptionPollResponse, ByteBuffer>)
                     (message, buffer) -> {
                       // TODO: overflow
                       return (int) (buffer.limit() * memoryUsageCheatFactor.get());
                     })
             .recordStats() // TODO: metrics
-            .build(SubscriptionEvent::serialize);
+            // NOTE: lambda CAN NOT be replaced with method reference
+            .build(response -> SubscriptionPollResponse.serialize(response));
   }
 }
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/SubscriptionTsFileEvent.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/SubscriptionTsFileEvent.java
deleted file mode 100644
index 222231fee04..00000000000
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/SubscriptionTsFileEvent.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.db.subscription.event;
-
-import org.apache.iotdb.commons.pipe.event.EnrichedEvent;
-import org.apache.iotdb.commons.subscription.config.SubscriptionConfig;
-import org.apache.iotdb.db.pipe.event.common.tsfile.PipeTsFileInsertionEvent;
-import org.apache.iotdb.rpc.subscription.payload.poll.FileInitPayload;
-import org.apache.iotdb.rpc.subscription.payload.poll.FilePiecePayload;
-import org.apache.iotdb.rpc.subscription.payload.poll.FileSealPayload;
-import org.apache.iotdb.rpc.subscription.payload.poll.SubscriptionCommitContext;
-import org.apache.iotdb.rpc.subscription.payload.poll.SubscriptionPollPayload;
-import org.apache.iotdb.rpc.subscription.payload.poll.SubscriptionPollResponse;
-import org.apache.iotdb.rpc.subscription.payload.poll.SubscriptionPollResponseType;
-
-import org.apache.tsfile.utils.Pair;
-import org.checkerframework.checker.nullness.qual.NonNull;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Objects;
-import java.util.concurrent.atomic.AtomicReference;
-
-public class SubscriptionTsFileEvent extends SubscriptionEvent {
-
-  private static final Logger LOGGER = LoggerFactory.getLogger(SubscriptionTsFileEvent.class);
-
-  private final AtomicReference<Pair<SubscriptionTsFileEvent, Boolean>> nextEventWithCommittableRef;
-
-  public SubscriptionTsFileEvent(
-      final List<EnrichedEvent> enrichedEvents, final SubscriptionPollResponse response) {
-    super(enrichedEvents, response);
-
-    this.nextEventWithCommittableRef = new AtomicReference<>();
-  }
-
-  public void prefetchNext() {
-    nextEventWithCommittableRef.getAndUpdate(
-        (nextEventWithCommittable) -> {
-          if (Objects.nonNull(nextEventWithCommittable)) {
-            // prefetch recursively
-            nextEventWithCommittable.getLeft().prefetchNext();
-            return nextEventWithCommittable;
-          }
-
-          final SubscriptionPollResponse polledMessage = this.getResponse();
-          final short responseType = polledMessage.getResponseType();
-          final SubscriptionPollPayload eventPayload = polledMessage.getPayload();
-          if (!SubscriptionPollResponseType.isValidatedResponseType(responseType)) {
-            LOGGER.warn("unexpected response type: {}", responseType);
-            return null;
-          }
-
-          switch (SubscriptionPollResponseType.valueOf(responseType)) {
-            case FILE_INIT:
-              try {
-                return generateSubscriptionTsFileEventWithPieceOrSealPayload(0);
-              } catch (final IOException e) {
-                LOGGER.warn(
-                    "IOException occurred when prefetching next SubscriptionTsFileEvent, current SubscriptionTsFileEvent: {}",
-                    this,
-                    e);
-                return null;
-              }
-            case FILE_PIECE:
-              try {
-                return generateSubscriptionTsFileEventWithPieceOrSealPayload(
-                    ((FilePiecePayload) eventPayload).getNextWritingOffset());
-              } catch (final IOException e) {
-                LOGGER.warn(
-                    "IOException occurred when prefetching next SubscriptionTsFileEvent, current SubscriptionTsFileEvent: {}",
-                    this,
-                    e);
-                return null;
-              }
-            case FILE_SEAL:
-              // not need to prefetch
-              return null;
-            default:
-              LOGGER.warn("unexpected message type: {}", responseType);
-              return null;
-          }
-        });
-  }
-
-  public void serializeNext() {
-    nextEventWithCommittableRef.getAndUpdate(
-        (nextEventWithCommittable) -> {
-          if (Objects.nonNull(nextEventWithCommittable)) {
-            SubscriptionEventBinaryCache.getInstance()
-                .trySerialize(nextEventWithCommittable.getLeft());
-            // serialize recursively
-            nextEventWithCommittable.getLeft().serializeNext();
-            return nextEventWithCommittable;
-          }
-
-          return null;
-        });
-  }
-
-  public Pair<@NonNull SubscriptionTsFileEvent, Boolean> matchOrResetNext(
-      final long writingOffset) {
-    return nextEventWithCommittableRef.getAndUpdate(
-        (nextEventWithCommittable) -> {
-          if (Objects.isNull(nextEventWithCommittable)) {
-            return null;
-          }
-
-          final SubscriptionPollResponse polledMessage = this.getResponse();
-          final short responseType = polledMessage.getResponseType();
-          final SubscriptionPollPayload eventPayload = polledMessage.getPayload();
-          if (!SubscriptionPollResponseType.isValidatedResponseType(responseType)) {
-            LOGGER.warn("unexpected response type: {}", responseType);
-            return null;
-          }
-
-          switch (SubscriptionPollResponseType.valueOf(responseType)) {
-            case FILE_INIT:
-              if (Objects.equals(writingOffset, 0)) {
-                return nextEventWithCommittable;
-              }
-              // reset next SubscriptionTsFileEvent
-              return null;
-            case FILE_PIECE:
-              if (Objects.equals(
-                  writingOffset, ((FilePiecePayload) eventPayload).getNextWritingOffset())) {
-                return nextEventWithCommittable;
-              }
-              // reset next SubscriptionTsFileEvent
-              return null;
-            case FILE_SEAL:
-              return null;
-            default:
-              LOGGER.warn("unexpected message type: {}", responseType);
-              return null;
-          }
-        });
-  }
-
-  public static SubscriptionTsFileEvent generateSubscriptionTsFileEventWithInitPayload(
-      final PipeTsFileInsertionEvent tsFileInsertionEvent,
-      final SubscriptionCommitContext commitContext) {
-    return new SubscriptionTsFileEvent(
-        Collections.singletonList(tsFileInsertionEvent),
-        new SubscriptionPollResponse(
-            SubscriptionPollResponseType.FILE_INIT.getType(),
-            new FileInitPayload(tsFileInsertionEvent.getTsFile().getName()),
-            commitContext));
-  }
-
-  public SubscriptionTsFileEvent generateSubscriptionTsFileEventWithInitPayload() {
-    return generateSubscriptionTsFileEventWithInitPayload(
-        (PipeTsFileInsertionEvent) this.getEnrichedEvents().get(0),
-        this.getResponse().getCommitContext());
-  }
-
-  public @NonNull Pair<@NonNull SubscriptionTsFileEvent, Boolean>
-      generateSubscriptionTsFileEventWithPieceOrSealPayload(final long writingOffset)
-          throws IOException {
-    final PipeTsFileInsertionEvent tsFileInsertionEvent =
-        (PipeTsFileInsertionEvent) this.getEnrichedEvents().get(0);
-    final SubscriptionCommitContext commitContext = this.getResponse().getCommitContext();
-
-    final int readFileBufferSize =
-        SubscriptionConfig.getInstance().getSubscriptionReadFileBufferSize();
-    final byte[] readBuffer = new byte[readFileBufferSize];
-    try (final RandomAccessFile reader =
-        new RandomAccessFile(tsFileInsertionEvent.getTsFile(), "r")) {
-      while (true) {
-        reader.seek(writingOffset);
-        final int readLength = reader.read(readBuffer);
-        if (readLength == -1) {
-          break;
-        }
-
-        final byte[] filePiece =
-            readLength == readFileBufferSize
-                ? readBuffer
-                : Arrays.copyOfRange(readBuffer, 0, readLength);
-
-        // generate subscription tsfile event with piece payload
-        return new Pair<>(
-            new SubscriptionTsFileEvent(
-                Collections.singletonList(tsFileInsertionEvent),
-                new SubscriptionPollResponse(
-                    SubscriptionPollResponseType.FILE_PIECE.getType(),
-                    new FilePiecePayload(
-                        tsFileInsertionEvent.getTsFile().getName(),
-                        writingOffset + readLength,
-                        filePiece),
-                    commitContext)),
-            false);
-      }
-
-      // generate subscription tsfile event with seal payload
-      return new Pair<>(
-          new SubscriptionTsFileEvent(
-              Collections.singletonList(tsFileInsertionEvent),
-              new SubscriptionPollResponse(
-                  SubscriptionPollResponseType.FILE_SEAL.getType(),
-                  new FileSealPayload(
-                      tsFileInsertionEvent.getTsFile().getName(),
-                      tsFileInsertionEvent.getTsFile().length()),
-                  commitContext)),
-          true);
-    }
-  }
-
-  @Override
-  public void resetByteBuffer(final boolean recursive) {
-    super.resetByteBuffer(recursive);
-    if (recursive) {
-      nextEventWithCommittableRef.getAndUpdate(
-          (nextEventWithCommittable) -> {
-            if (Objects.isNull(nextEventWithCommittable)) {
-              return null;
-            }
-            // reset recursively
-            SubscriptionEventBinaryCache.getInstance()
-                .resetByteBuffer(nextEventWithCommittable.getLeft(), true);
-            return nextEventWithCommittable;
-          });
-    }
-  }
-}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/batch/SubscriptionPipeTabletEventBatch.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/batch/SubscriptionPipeTabletEventBatch.java
new file mode 100644
index 00000000000..e9ea7f423e0
--- /dev/null
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/batch/SubscriptionPipeTabletEventBatch.java
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.subscription.event.batch;
+
+import org.apache.iotdb.commons.pipe.event.EnrichedEvent;
+import org.apache.iotdb.db.pipe.event.common.tablet.PipeInsertNodeTabletInsertionEvent;
+import org.apache.iotdb.db.pipe.event.common.tablet.PipeRawTabletInsertionEvent;
+import org.apache.iotdb.db.pipe.event.common.tsfile.PipeTsFileInsertionEvent;
+import org.apache.iotdb.db.pipe.resource.memory.PipeMemoryWeightUtil;
+import org.apache.iotdb.pipe.api.event.dml.insertion.TabletInsertionEvent;
+
+import org.apache.tsfile.write.record.Tablet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+public class SubscriptionPipeTabletEventBatch {
+
+  private static final Logger LOGGER =
+      LoggerFactory.getLogger(SubscriptionPipeTabletEventBatch.class);
+
+  private final List<EnrichedEvent> enrichedEvents = new ArrayList<>();
+  private final List<Tablet> tablets = new ArrayList<>();
+
+  private final int maxDelayInMs;
+  private long firstEventProcessingTime = Long.MIN_VALUE;
+
+  private final long maxBatchSizeInBytes;
+  private long totalBufferSize = 0;
+
+  public SubscriptionPipeTabletEventBatch(final int maxDelayInMs, final long maxBatchSizeInBytes) {
+    this.maxDelayInMs = maxDelayInMs;
+    this.maxBatchSizeInBytes = maxBatchSizeInBytes;
+  }
+
+  public synchronized List<Tablet> sealTablets() {
+    return tablets;
+  }
+
+  public synchronized boolean shouldEmit() {
+    return totalBufferSize >= maxBatchSizeInBytes
+        || System.currentTimeMillis() - firstEventProcessingTime >= maxDelayInMs;
+  }
+
+  public synchronized boolean onEvent(final EnrichedEvent event) {
+    if (event instanceof TabletInsertionEvent) {
+      final List<Tablet> currentTablets = convertToTablets((TabletInsertionEvent) event);
+      if (currentTablets.isEmpty()) {
+        return shouldEmit();
+      }
+      tablets.addAll(currentTablets);
+      totalBufferSize +=
+          currentTablets.stream()
+              .map((PipeMemoryWeightUtil::calculateTabletSizeInBytes))
+              .reduce(Long::sum)
+              .orElse(0L);
+      enrichedEvents.add(event);
+      if (firstEventProcessingTime == Long.MIN_VALUE) {
+        firstEventProcessingTime = System.currentTimeMillis();
+      }
+    } else if (event instanceof PipeTsFileInsertionEvent) {
+      for (final TabletInsertionEvent tabletInsertionEvent :
+          ((PipeTsFileInsertionEvent) event).toTabletInsertionEvents()) {
+        final List<Tablet> currentTablets = convertToTablets(tabletInsertionEvent);
+        if (Objects.isNull(currentTablets)) {
+          continue;
+        }
+        tablets.addAll(currentTablets);
+        totalBufferSize +=
+            currentTablets.stream()
+                .map((PipeMemoryWeightUtil::calculateTabletSizeInBytes))
+                .reduce(Long::sum)
+                .orElse(0L);
+      }
+      enrichedEvents.add(event);
+      if (firstEventProcessingTime == Long.MIN_VALUE) {
+        firstEventProcessingTime = System.currentTimeMillis();
+      }
+    }
+
+    return shouldEmit();
+  }
+
+  public void ack() {
+    for (final EnrichedEvent enrichedEvent : enrichedEvents) {
+      enrichedEvent.decreaseReferenceCount(this.getClass().getName(), true);
+    }
+  }
+
+  public synchronized void cleanup() {
+    // clear the reference count of events
+    for (final EnrichedEvent enrichedEvent : enrichedEvents) {
+      enrichedEvent.clearReferenceCount(this.getClass().getName());
+    }
+  }
+
+  private List<Tablet> convertToTablets(final TabletInsertionEvent tabletInsertionEvent) {
+    if (tabletInsertionEvent instanceof PipeInsertNodeTabletInsertionEvent) {
+      return ((PipeInsertNodeTabletInsertionEvent) tabletInsertionEvent).convertToTablets();
+    } else if (tabletInsertionEvent instanceof PipeRawTabletInsertionEvent) {
+      return Collections.singletonList(
+          ((PipeRawTabletInsertionEvent) tabletInsertionEvent).convertToTablet());
+    }
+
+    LOGGER.warn(
+        "SubscriptionPipeTabletEventBatch {} only support convert PipeInsertNodeTabletInsertionEvent or PipeRawTabletInsertionEvent to tablet. Ignore {}.",
+        this,
+        tabletInsertionEvent);
+    return Collections.emptyList();
+  }
+
+  public String toString() {
+    return "SubscriptionPipeTabletEventBatch{enrichedEvents="
+        + enrichedEvents.stream().map(EnrichedEvent::coreReportMessage).collect(Collectors.toList())
+        + ", size of tablets="
+        + tablets.size()
+        + ", maxDelayInMs="
+        + maxDelayInMs
+        + ", firstEventProcessingTime="
+        + firstEventProcessingTime
+        + ", maxBatchSizeInBytes="
+        + maxBatchSizeInBytes
+        + ", totalBufferSize="
+        + totalBufferSize
+        + "}";
+  }
+}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/batch/SubscriptionPipeTsFileEventBatch.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/batch/SubscriptionPipeTsFileEventBatch.java
new file mode 100644
index 00000000000..1e0f91ae787
--- /dev/null
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/batch/SubscriptionPipeTsFileEventBatch.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.subscription.event.batch;
+
+import org.apache.iotdb.db.pipe.connector.payload.evolvable.batch.PipeTabletEventTsFileBatch;
+import org.apache.iotdb.pipe.api.event.dml.insertion.TabletInsertionEvent;
+
+import java.io.File;
+import java.util.List;
+
+public class SubscriptionPipeTsFileEventBatch {
+
+  private final PipeTabletEventTsFileBatch batch;
+
+  public SubscriptionPipeTsFileEventBatch(
+      final int maxDelayInMs, final long requestMaxBatchSizeInBytes) {
+    this.batch = new PipeTabletEventTsFileBatch(maxDelayInMs, requestMaxBatchSizeInBytes);
+  }
+
+  public synchronized List<File> sealTsFiles() throws Exception {
+    return batch.sealTsFiles();
+  }
+
+  public synchronized boolean shouldEmit() {
+    return batch.shouldEmit();
+  }
+
+  public synchronized boolean onEvent(final TabletInsertionEvent event) throws Exception {
+    return batch.onEvent(event);
+  }
+
+  public void ack() {
+    batch.decreaseEventsReferenceCount(this.getClass().getName(), true);
+  }
+
+  public synchronized void cleanup() {
+    // close batch, it includes clearing the reference count of events
+    batch.close();
+  }
+
+  public String toString() {
+    return "SubscriptionPipeTsFileEventBatch{batch=" + batch + "}";
+  }
+}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/pipe/SubscriptionPipeEmptyEvent.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/pipe/SubscriptionPipeEmptyEvent.java
new file mode 100644
index 00000000000..04493c76599
--- /dev/null
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/pipe/SubscriptionPipeEmptyEvent.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.subscription.event.pipe;
+
+import java.io.File;
+
+public class SubscriptionPipeEmptyEvent implements SubscriptionPipeEvents {
+
+  @Override
+  public File getTsFile() {
+    return null;
+  }
+
+  @Override
+  public void ack() {}
+
+  @Override
+  public void cleanup() {}
+
+  @Override
+  public String toString() {
+    return "SubscriptionEmptyPipeEvent";
+  }
+}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/pipe/SubscriptionPipeEvents.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/pipe/SubscriptionPipeEvents.java
new file mode 100644
index 00000000000..14a649b16d7
--- /dev/null
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/pipe/SubscriptionPipeEvents.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.subscription.event.pipe;
+
+import java.io.File;
+
+public interface SubscriptionPipeEvents {
+
+  /**
+   * @return {@code null} if the pipe events do not contain the corresponding tsfile.
+   */
+  File getTsFile();
+
+  void ack();
+
+  void cleanup();
+}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/pipe/SubscriptionPipeTabletBatchEvents.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/pipe/SubscriptionPipeTabletBatchEvents.java
new file mode 100644
index 00000000000..9402f717a08
--- /dev/null
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/pipe/SubscriptionPipeTabletBatchEvents.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.subscription.event.pipe;
+
+import org.apache.iotdb.db.subscription.event.batch.SubscriptionPipeTabletEventBatch;
+
+import java.io.File;
+
+public class SubscriptionPipeTabletBatchEvents implements SubscriptionPipeEvents {
+
+  private final SubscriptionPipeTabletEventBatch batch;
+
+  public SubscriptionPipeTabletBatchEvents(final SubscriptionPipeTabletEventBatch batch) {
+    this.batch = batch;
+  }
+
+  @Override
+  public File getTsFile() {
+    return null;
+  }
+
+  @Override
+  public void ack() {
+    batch.ack();
+  }
+
+  @Override
+  public void cleanup() {
+    batch.cleanup();
+  }
+
+  @Override
+  public String toString() {
+    return "SubscriptionPipeTabletBatchEvents{batch=" + batch + "}";
+  }
+}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/pipe/SubscriptionPipeTsFileBatchEvents.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/pipe/SubscriptionPipeTsFileBatchEvents.java
new file mode 100644
index 00000000000..795ae748345
--- /dev/null
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/pipe/SubscriptionPipeTsFileBatchEvents.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.subscription.event.pipe;
+
+import org.apache.iotdb.db.subscription.event.batch.SubscriptionPipeTsFileEventBatch;
+
+import java.io.File;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class SubscriptionPipeTsFileBatchEvents implements SubscriptionPipeEvents {
+
+  private final SubscriptionPipeTsFileEventBatch batch;
+  private final File tsFile;
+
+  private final AtomicInteger referenceCount; // shared between the same batch
+  private final AtomicBoolean isAcked = new AtomicBoolean(false);
+  private final AtomicBoolean isClosed = new AtomicBoolean(false);
+
+  public SubscriptionPipeTsFileBatchEvents(
+      final SubscriptionPipeTsFileEventBatch batch,
+      final File tsFile,
+      final AtomicInteger referenceCount) {
+    this.batch = batch;
+    this.tsFile = tsFile;
+    this.referenceCount = referenceCount;
+  }
+
+  @Override
+  public File getTsFile() {
+    return tsFile;
+  }
+
+  @Override
+  public void ack() {
+    if (!isAcked.get() && referenceCount.decrementAndGet() == 0) {
+      isAcked.set(true);
+      batch.ack();
+    }
+  }
+
+  @Override
+  public void cleanup() {
+    if (!isClosed.get() && referenceCount.decrementAndGet() == 0) {
+      isClosed.set(true);
+      // close batch, it includes clearing the reference count of events
+      batch.cleanup();
+    }
+  }
+
+  @Override
+  public String toString() {
+    return "SubscriptionPipeTsFileBatchEvents{batch="
+        + batch
+        + ", tsFile="
+        + tsFile
+        + ", referenceCount="
+        + referenceCount
+        + ", isAcked="
+        + isAcked
+        + ", isClosed="
+        + isClosed
+        + "}";
+  }
+}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/pipe/SubscriptionPipeTsFilePlainEvent.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/pipe/SubscriptionPipeTsFilePlainEvent.java
new file mode 100644
index 00000000000..139396d2cda
--- /dev/null
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/event/pipe/SubscriptionPipeTsFilePlainEvent.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.subscription.event.pipe;
+
+import org.apache.iotdb.db.pipe.event.common.tsfile.PipeTsFileInsertionEvent;
+
+import java.io.File;
+
+public class SubscriptionPipeTsFilePlainEvent implements SubscriptionPipeEvents {
+
+  private final PipeTsFileInsertionEvent tsFileInsertionEvent;
+
+  public SubscriptionPipeTsFilePlainEvent(final PipeTsFileInsertionEvent tsFileInsertionEvent) {
+    this.tsFileInsertionEvent = tsFileInsertionEvent;
+  }
+
+  @Override
+  public File getTsFile() {
+    return tsFileInsertionEvent.getTsFile();
+  }
+
+  @Override
+  public void ack() {
+    tsFileInsertionEvent.decreaseReferenceCount(this.getClass().getName(), true);
+  }
+
+  @Override
+  public void cleanup() {
+    // clear the reference count of event
+    tsFileInsertionEvent.clearReferenceCount(this.getClass().getName());
+  }
+
+  @Override
+  public String toString() {
+    return "SubscriptionPipeTsFilePlainEvent{tsFileInsertionEvent="
+        + tsFileInsertionEvent.coreReportMessage()
+        + "}";
+  }
+}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/receiver/SubscriptionReceiverV1.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/receiver/SubscriptionReceiverV1.java
index 9876339101a..1da7a78a945 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/receiver/SubscriptionReceiverV1.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/receiver/SubscriptionReceiverV1.java
@@ -34,7 +34,6 @@ import org.apache.iotdb.db.protocol.client.ConfigNodeInfo;
 import org.apache.iotdb.db.subscription.agent.SubscriptionAgent;
 import org.apache.iotdb.db.subscription.broker.SubscriptionPrefetchingQueue;
 import org.apache.iotdb.db.subscription.event.SubscriptionEvent;
-import org.apache.iotdb.db.subscription.event.SubscriptionEventBinaryCache;
 import org.apache.iotdb.db.subscription.metric.SubscriptionPrefetchingQueueMetrics;
 import org.apache.iotdb.rpc.RpcUtils;
 import org.apache.iotdb.rpc.TSStatusCode;
@@ -274,9 +273,11 @@ public class SubscriptionReceiverV1 implements SubscriptionReceiver {
     LOGGER.info("Subscription: consumer {} subscribe {} successfully", consumerConfig, topicNames);
     return PipeSubscribeSubscribeResp.toTPipeSubscribeResp(
         RpcUtils.SUCCESS_STATUS,
-        SubscriptionAgent.consumer()
-            .getTopicsSubscribedByConsumer(
-                consumerConfig.getConsumerGroupId(), consumerConfig.getConsumerId()));
+        SubscriptionAgent.topic()
+            .getTopicConfigs(
+                SubscriptionAgent.consumer()
+                    .getTopicNamesSubscribedByConsumer(
+                        consumerConfig.getConsumerGroupId(), consumerConfig.getConsumerId())));
   }
 
   private TPipeSubscribeResp handlePipeSubscribeUnsubscribe(final PipeSubscribeUnsubscribeReq req) {
@@ -312,9 +313,11 @@ public class SubscriptionReceiverV1 implements SubscriptionReceiver {
         "Subscription: consumer {} unsubscribe {} successfully", consumerConfig, topicNames);
     return PipeSubscribeUnsubscribeResp.toTPipeSubscribeResp(
         RpcUtils.SUCCESS_STATUS,
-        SubscriptionAgent.consumer()
-            .getTopicsSubscribedByConsumer(
-                consumerConfig.getConsumerGroupId(), consumerConfig.getConsumerId()));
+        SubscriptionAgent.topic()
+            .getTopicConfigs(
+                SubscriptionAgent.consumer()
+                    .getTopicNamesSubscribedByConsumer(
+                        consumerConfig.getConsumerGroupId(), consumerConfig.getConsumerId())));
   }
 
   private TPipeSubscribeResp handlePipeSubscribePoll(final PipeSubscribePollReq req) {
@@ -357,17 +360,19 @@ public class SubscriptionReceiverV1 implements SubscriptionReceiver {
           events.parallelStream()
               .map(
                   (event) -> {
-                    final SubscriptionPollResponse response = event.getResponse();
+                    final SubscriptionPollResponse response = event.getCurrentResponse();
+                    if (Objects.isNull(response)) {
+                      throw new SubscriptionException("null response");
+                    }
                     final SubscriptionCommitContext commitContext = response.getCommitContext();
                     try {
-                      final ByteBuffer byteBuffer =
-                          SubscriptionEventBinaryCache.getInstance().serialize(event);
+                      final ByteBuffer byteBuffer = event.getCurrentResponseByteBuffer();
                       SubscriptionPrefetchingQueueMetrics.getInstance()
                           .mark(
                               SubscriptionPrefetchingQueue.generatePrefetchingQueueId(
                                   commitContext.getConsumerGroupId(), commitContext.getTopicName()),
                               byteBuffer.limit());
-                      SubscriptionEventBinaryCache.getInstance().resetByteBuffer(event, false);
+                      event.resetResponseByteBuffer(false);
                       LOGGER.info(
                           "Subscription: consumer {} poll {} successfully with request: {}",
                           consumerConfig,
@@ -407,7 +412,7 @@ public class SubscriptionReceiverV1 implements SubscriptionReceiver {
       final ConsumerConfig consumerConfig, final PollPayload messagePayload) {
     final Set<String> subscribedTopicNames =
         SubscriptionAgent.consumer()
-            .getTopicsSubscribedByConsumer(
+            .getTopicNamesSubscribedByConsumer(
                 consumerConfig.getConsumerGroupId(), consumerConfig.getConsumerId());
     Set<String> topicNames = messagePayload.getTopicNames();
     if (topicNames.isEmpty()) {
@@ -505,16 +510,16 @@ public class SubscriptionReceiverV1 implements SubscriptionReceiver {
 
   private void closeConsumer(final ConsumerConfig consumerConfig) {
     // unsubscribe all subscribed topics
-    final Set<String> topics =
+    final Set<String> topicNames =
         SubscriptionAgent.consumer()
-            .getTopicsSubscribedByConsumer(
+            .getTopicNamesSubscribedByConsumer(
                 consumerConfig.getConsumerGroupId(), consumerConfig.getConsumerId());
-    if (!topics.isEmpty()) {
+    if (!topicNames.isEmpty()) {
       LOGGER.info(
           "Subscription: unsubscribe all subscribed topics {} before close consumer {}",
-          topics,
+          topicNames,
           consumerConfig);
-      unsubscribe(consumerConfig, topics);
+      unsubscribe(consumerConfig, topicNames);
     }
 
     // drop consumer if existed
diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/CommonConfig.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/CommonConfig.java
index d105c2cb765..d8660178e5e 100644
--- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/CommonConfig.java
+++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/CommonConfig.java
@@ -35,6 +35,8 @@ import java.io.IOException;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
 
+import static org.apache.iotdb.commons.conf.IoTDBConstant.MB;
+
 public class CommonConfig {
 
   public static final String OLD_CONFIG_NODE_CONFIG_NAME = "iotdb-confignode.properties";
@@ -254,13 +256,15 @@ public class CommonConfig {
 
   private int subscriptionSubtaskExecutorMaxThreadNum =
       Math.min(5, Math.max(1, Runtime.getRuntime().availableProcessors() / 2));
-  private int subscriptionMaxTabletsPerPrefetching = 64;
-  private int subscriptionMaxTabletsSizeInBytesPerPrefetching = 8388608; // 8MB
+  private int subscriptionPrefetchTabletBatchMaxDelayInMs = 1000; // 1s
+  private long subscriptionPrefetchTabletBatchMaxSizeInBytes = 16 * MB;
+  private int subscriptionPrefetchTsFileBatchMaxDelayInMs = 5000; // 5s
+  private long subscriptionPrefetchTsFileBatchMaxSizeInBytes = 80 * MB;
   private int subscriptionPollMaxBlockingTimeMs = 500;
   private int subscriptionSerializeMaxBlockingTimeMs = 100;
   private long subscriptionLaunchRetryIntervalMs = 1000;
   private int subscriptionRecycleUncommittedEventIntervalMs = 60000; // 60s
-  private int subscriptionReadFileBufferSize = 8388608; // 8MB
+  private long subscriptionReadFileBufferSize = 8 * MB;
 
   /** Whether to use persistent schema mode. */
   private String schemaEngineMode = "Memory";
@@ -1130,22 +1134,42 @@ public class CommonConfig {
             Math.max(1, Runtime.getRuntime().availableProcessors() / 2));
   }
 
-  public int getSubscriptionMaxTabletsPerPrefetching() {
-    return subscriptionMaxTabletsPerPrefetching;
+  public int getSubscriptionPrefetchTabletBatchMaxDelayInMs() {
+    return subscriptionPrefetchTabletBatchMaxDelayInMs;
+  }
+
+  public void setSubscriptionPrefetchTabletBatchMaxDelayInMs(
+      int subscriptionPrefetchTabletBatchMaxDelayInMs) {
+    this.subscriptionPrefetchTabletBatchMaxDelayInMs = subscriptionPrefetchTabletBatchMaxDelayInMs;
+  }
+
+  public long getSubscriptionPrefetchTabletBatchMaxSizeInBytes() {
+    return subscriptionPrefetchTabletBatchMaxSizeInBytes;
+  }
+
+  public void setSubscriptionPrefetchTabletBatchMaxSizeInBytes(
+      long subscriptionPrefetchTabletBatchMaxSizeInBytes) {
+    this.subscriptionPrefetchTabletBatchMaxSizeInBytes =
+        subscriptionPrefetchTabletBatchMaxSizeInBytes;
+  }
+
+  public int getSubscriptionPrefetchTsFileBatchMaxDelayInMs() {
+    return subscriptionPrefetchTsFileBatchMaxDelayInMs;
   }
 
-  public void setSubscriptionMaxTabletsPerPrefetching(int subscriptionMaxTabletsPerPrefetching) {
-    this.subscriptionMaxTabletsPerPrefetching = subscriptionMaxTabletsPerPrefetching;
+  public void setSubscriptionPrefetchTsFileBatchMaxDelayInMs(
+      int subscriptionPrefetchTsFileBatchMaxDelayInMs) {
+    this.subscriptionPrefetchTsFileBatchMaxDelayInMs = subscriptionPrefetchTsFileBatchMaxDelayInMs;
   }
 
-  public int getSubscriptionMaxTabletsSizeInBytesPerPrefetching() {
-    return subscriptionMaxTabletsSizeInBytesPerPrefetching;
+  public long getSubscriptionPrefetchTsFileBatchMaxSizeInBytes() {
+    return subscriptionPrefetchTsFileBatchMaxSizeInBytes;
   }
 
-  public void setSubscriptionMaxTabletsSizeInBytesPerPrefetching(
-      int subscriptionMaxTabletsSizeInBytesPerPrefetching) {
-    this.subscriptionMaxTabletsSizeInBytesPerPrefetching =
-        subscriptionMaxTabletsSizeInBytesPerPrefetching;
+  public void setSubscriptionPrefetchTsFileBatchMaxSizeInBytes(
+      long subscriptionPrefetchTsFileBatchMaxSizeInBytes) {
+    this.subscriptionPrefetchTsFileBatchMaxSizeInBytes =
+        subscriptionPrefetchTsFileBatchMaxSizeInBytes;
   }
 
   public int getSubscriptionPollMaxBlockingTimeMs() {
@@ -1183,11 +1207,11 @@ public class CommonConfig {
         subscriptionRecycleUncommittedEventIntervalMs;
   }
 
-  public int getSubscriptionReadFileBufferSize() {
+  public long getSubscriptionReadFileBufferSize() {
     return subscriptionReadFileBufferSize;
   }
 
-  public void setSubscriptionReadFileBufferSize(int subscriptionReadFileBufferSize) {
+  public void setSubscriptionReadFileBufferSize(long subscriptionReadFileBufferSize) {
     this.subscriptionReadFileBufferSize = subscriptionReadFileBufferSize;
   }
 
diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/CommonDescriptor.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/CommonDescriptor.java
index 185483a25d9..0a1fe35da7c 100644
--- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/CommonDescriptor.java
+++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/CommonDescriptor.java
@@ -595,16 +595,26 @@ public class CommonDescriptor {
     if (config.getSubscriptionSubtaskExecutorMaxThreadNum() <= 0) {
       config.setSubscriptionSubtaskExecutorMaxThreadNum(5);
     }
-    config.setSubscriptionMaxTabletsPerPrefetching(
+    config.setSubscriptionPrefetchTabletBatchMaxDelayInMs(
         Integer.parseInt(
             properties.getProperty(
-                "subscription_max_tablets_per_prefetching",
-                String.valueOf(config.getSubscriptionMaxTabletsPerPrefetching()))));
-    config.setSubscriptionMaxTabletsSizeInBytesPerPrefetching(
+                "subscription_prefetch_tablet_batch_max_delay_in_ms",
+                String.valueOf(config.getSubscriptionPrefetchTabletBatchMaxDelayInMs()))));
+    config.setSubscriptionPrefetchTabletBatchMaxSizeInBytes(
+        Long.parseLong(
+            properties.getProperty(
+                "subscription_prefetch_tablet_batch_max_size_in_bytes",
+                String.valueOf(config.getSubscriptionPrefetchTabletBatchMaxSizeInBytes()))));
+    config.setSubscriptionPrefetchTsFileBatchMaxDelayInMs(
         Integer.parseInt(
             properties.getProperty(
-                "subscription_max_tablets_size_in_bytes_per_prefetching",
-                String.valueOf(config.getSubscriptionMaxTabletsSizeInBytesPerPrefetching()))));
+                "subscription_prefetch_ts_file_batch_max_delay_in_ms",
+                String.valueOf(config.getSubscriptionPrefetchTsFileBatchMaxDelayInMs()))));
+    config.setSubscriptionPrefetchTsFileBatchMaxSizeInBytes(
+        Long.parseLong(
+            properties.getProperty(
+                "subscription_prefetch_ts_file_batch_max_size_in_bytes",
+                String.valueOf(config.getSubscriptionPrefetchTsFileBatchMaxSizeInBytes()))));
     config.setSubscriptionPollMaxBlockingTimeMs(
         Integer.parseInt(
             properties.getProperty(
@@ -626,7 +636,7 @@ public class CommonDescriptor {
                 "subscription_recycle_uncommitted_event_interval_ms",
                 String.valueOf(config.getSubscriptionRecycleUncommittedEventIntervalMs()))));
     config.setSubscriptionReadFileBufferSize(
-        Integer.parseInt(
+        Long.parseLong(
             properties.getProperty(
                 "subscription_read_file_buffer_size",
                 String.valueOf(config.getSubscriptionReadFileBufferSize()))));
diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/config/constant/PipeExtractorConstant.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/config/constant/PipeExtractorConstant.java
index 1bf147e998b..79086799fcd 100644
--- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/config/constant/PipeExtractorConstant.java
+++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/config/constant/PipeExtractorConstant.java
@@ -35,8 +35,10 @@ public class PipeExtractorConstant {
   public static final String EXTRACTOR_MODE_KEY = "extractor.mode";
   public static final String SOURCE_MODE_KEY = "source.mode";
   public static final String EXTRACTOR_MODE_QUERY_VALUE = "query";
+  public static final String EXTRACTOR_MODE_SNAPSHOT_VALUE = "snapshot";
   public static final String EXTRACTOR_MODE_SUBSCRIBE_VALUE = "subscribe";
-  public static final String EXTRACTOR_MODE_DEFAULT_VALUE = EXTRACTOR_MODE_SUBSCRIBE_VALUE;
+  public static final String EXTRACTOR_MODE_LIVE_VALUE = "live";
+  public static final String EXTRACTOR_MODE_DEFAULT_VALUE = EXTRACTOR_MODE_LIVE_VALUE;
 
   public static final String EXTRACTOR_PATTERN_KEY = "extractor.pattern";
   public static final String SOURCE_PATTERN_KEY = "source.pattern";
@@ -66,6 +68,7 @@ public class PipeExtractorConstant {
   public static final String SOURCE_HISTORY_LOOSE_RANGE_KEY = "source.history.loose-range";
   public static final String EXTRACTOR_HISTORY_LOOSE_RANGE_TIME_VALUE = "time";
   public static final String EXTRACTOR_HISTORY_LOOSE_RANGE_PATH_VALUE = "path";
+  public static final String EXTRACTOR_HISTORY_LOOSE_RANGE_ALL_VALUE = "all";
   public static final String EXTRACTOR_HISTORY_LOOSE_RANGE_DEFAULT_VALUE = "";
   public static final String EXTRACTOR_MODS_ENABLE_KEY = "extractor.mods.enable";
   public static final String SOURCE_MODS_ENABLE_KEY = "source.mods.enable";
@@ -86,6 +89,7 @@ public class PipeExtractorConstant {
   public static final String SOURCE_REALTIME_LOOSE_RANGE_KEY = "source.realtime.loose-range";
   public static final String EXTRACTOR_REALTIME_LOOSE_RANGE_TIME_VALUE = "time";
   public static final String EXTRACTOR_REALTIME_LOOSE_RANGE_PATH_VALUE = "path";
+  public static final String EXTRACTOR_REALTIME_LOOSE_RANGE_ALL_VALUE = "all";
   public static final String EXTRACTOR_REALTIME_LOOSE_RANGE_DEFAULT_VALUE = "";
 
   public static final String EXTRACTOR_START_TIME_KEY = "extractor.start-time";
diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/subscription/config/SubscriptionConfig.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/subscription/config/SubscriptionConfig.java
index 3a269b50550..bf40650d604 100644
--- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/subscription/config/SubscriptionConfig.java
+++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/subscription/config/SubscriptionConfig.java
@@ -35,12 +35,20 @@ public class SubscriptionConfig {
     return COMMON_CONFIG.getSubscriptionSubtaskExecutorMaxThreadNum();
   }
 
-  public int getSubscriptionMaxTabletsPerPrefetching() {
-    return COMMON_CONFIG.getSubscriptionMaxTabletsPerPrefetching();
+  public int getSubscriptionPrefetchTabletBatchMaxDelayInMs() {
+    return COMMON_CONFIG.getSubscriptionPrefetchTabletBatchMaxDelayInMs();
   }
 
-  public int getSubscriptionMaxTabletsSizeInBytesPerPrefetching() {
-    return COMMON_CONFIG.getSubscriptionMaxTabletsSizeInBytesPerPrefetching();
+  public long getSubscriptionPrefetchTabletBatchMaxSizeInBytes() {
+    return COMMON_CONFIG.getSubscriptionPrefetchTabletBatchMaxSizeInBytes();
+  }
+
+  public int getSubscriptionPrefetchTsFileBatchMaxDelayInMs() {
+    return COMMON_CONFIG.getSubscriptionPrefetchTsFileBatchMaxDelayInMs();
+  }
+
+  public long getSubscriptionPrefetchTsFileBatchMaxSizeInBytes() {
+    return COMMON_CONFIG.getSubscriptionPrefetchTsFileBatchMaxSizeInBytes();
   }
 
   public int getSubscriptionPollMaxBlockingTimeMs() {
@@ -59,7 +67,7 @@ public class SubscriptionConfig {
     return COMMON_CONFIG.getSubscriptionRecycleUncommittedEventIntervalMs();
   }
 
-  public int getSubscriptionReadFileBufferSize() {
+  public long getSubscriptionReadFileBufferSize() {
     return COMMON_CONFIG.getSubscriptionReadFileBufferSize();
   }
 
@@ -72,10 +80,17 @@ public class SubscriptionConfig {
         "SubscriptionSubtaskExecutorMaxThreadNum: {}",
         getSubscriptionSubtaskExecutorMaxThreadNum());
     LOGGER.info(
-        "SubscriptionMaxTabletsPerPrefetching: {}", getSubscriptionMaxTabletsPerPrefetching());
+        "SubscriptionPrefetchTabletBatchMaxDelayInMs: {}",
+        getSubscriptionPrefetchTabletBatchMaxDelayInMs());
+    LOGGER.info(
+        "SubscriptionPrefetchTabletBatchMaxSizeInBytes: {}",
+        getSubscriptionPrefetchTabletBatchMaxSizeInBytes());
+    LOGGER.info(
+        "SubscriptionPrefetchTsFileBatchMaxDelayInMs: {}",
+        getSubscriptionPrefetchTsFileBatchMaxDelayInMs());
     LOGGER.info(
-        "SubscriptionMaxTabletsSizeInBytesPerPrefetching: {}",
-        getSubscriptionMaxTabletsSizeInBytesPerPrefetching());
+        "SubscriptionPrefetchTsFileBatchMaxSizeInBytes: {}",
+        getSubscriptionPrefetchTsFileBatchMaxSizeInBytes());
     LOGGER.info("SubscriptionPollMaxBlockingTimeMs: {}", getSubscriptionPollMaxBlockingTimeMs());
     LOGGER.info(
         "SubscriptionSerializeMaxBlockingTimeMs: {}", getSubscriptionSerializeMaxBlockingTimeMs());