You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by sp...@apache.org on 2023/02/27 15:30:08 UTC

[iotdb] branch master updated: [IOTDB-5458] Add Session Idle Time Metrics and Upgrade Thrift related Metrics (#9124)

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

spricoder 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 9d1a076aef [IOTDB-5458] Add Session Idle Time Metrics and Upgrade Thrift related Metrics (#9124)
9d1a076aef is described below

commit 9d1a076aef90d77f2dfbf3ae204893561112f729
Author: ZhangHongYin <46...@users.noreply.github.com>
AuthorDate: Mon Feb 27 23:30:01 2023 +0800

    [IOTDB-5458] Add Session Idle Time Metrics and Upgrade Thrift related Metrics (#9124)
    
    * Add connection idle time
    
    * Upgrade thrift related metric level and add doc
    
    * Update session idle time
    
    * Fix doc
    
    * Update Performance Overview Dashboard
    
    * Fix thrift related metric name
    
    * Update Performance Overview
---
 .../thrift/ConfigNodeRPCServiceHandlerMetrics.java |   2 +-
 .../thrift/ConfigNodeRPCServiceMetrics.java        |   2 +-
 ...pache-IoTDB-Performance-Overview-Dashboard.json | 363 ++++++++++++----
 docs/UserGuide/Monitor-Alert/Metric-Tool.md        |  69 +--
 docs/zh/UserGuide/Monitor-Alert/Metric-Tool.md     |  99 ++---
 .../iotdb/commons/service/metric/enums/Metric.java |   3 +-
 .../org/apache/iotdb/db/audit/AuditLogger.java     |   4 +-
 .../exchange/MPPDataExchangeServiceMetrics.java    |   2 +-
 ...MppDataExchangeServiceThriftHandlerMetrics.java |   6 +-
 .../iotdb/db/query/control/SessionManager.java     |  55 ++-
 .../service/DataNodeInternalRPCServiceMetrics.java |   2 +-
 .../apache/iotdb/db/service/RPCServiceMetrics.java |   2 +-
 .../thrift/handler/BaseServerContextHandler.java   |   4 +-
 .../InternalServiceThriftHandlerMetrics.java       |   6 +-
 .../handler/RPCServiceThriftHandlerMetrics.java    |   9 +-
 .../service/thrift/impl/ClientRPCServiceImpl.java  | 461 ++++++++++++---------
 16 files changed, 682 insertions(+), 407 deletions(-)

diff --git a/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceHandlerMetrics.java b/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceHandlerMetrics.java
index 7c3483d72a..0762343094 100644
--- a/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceHandlerMetrics.java
+++ b/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceHandlerMetrics.java
@@ -38,7 +38,7 @@ public class ConfigNodeRPCServiceHandlerMetrics implements IMetricSet {
   public void bindTo(AbstractMetricService metricService) {
     metricService.createAutoGauge(
         Metric.THRIFT_CONNECTIONS.toString(),
-        MetricLevel.IMPORTANT,
+        MetricLevel.CORE,
         thriftConnectionNumber,
         AtomicLong::get,
         Tag.NAME.toString(),
diff --git a/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceMetrics.java b/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceMetrics.java
index e237dd75b0..7e052a87a2 100644
--- a/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceMetrics.java
+++ b/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceMetrics.java
@@ -40,7 +40,7 @@ public class ConfigNodeRPCServiceMetrics implements IMetricSet {
   public void bindTo(AbstractMetricService metricService) {
     metricService.createAutoGauge(
         Metric.THRIFT_ACTIVE_THREADS.toString(),
-        MetricLevel.IMPORTANT,
+        MetricLevel.CORE,
         thriftServiceThread,
         AbstractThriftServiceThread::getActiveThreadCount,
         Tag.NAME.toString(),
diff --git a/docs/UserGuide/Monitor-Alert/Apache-IoTDB-Performance-Overview-Dashboard.json b/docs/UserGuide/Monitor-Alert/Apache-IoTDB-Performance-Overview-Dashboard.json
index 1ae6ed9b3d..7620f7914e 100644
--- a/docs/UserGuide/Monitor-Alert/Apache-IoTDB-Performance-Overview-Dashboard.json
+++ b/docs/UserGuide/Monitor-Alert/Apache-IoTDB-Performance-Overview-Dashboard.json
@@ -9,7 +9,7 @@
       "pluginName": "Prometheus"
     }
   ],
-  "__elements": {},
+  "__elements": [],
   "__requires": [
     {
       "type": "panel",
@@ -21,7 +21,7 @@
       "type": "grafana",
       "id": "grafana",
       "name": "Grafana",
-      "version": "9.3.2"
+      "version": "8.4.2"
     },
     {
       "type": "datasource",
@@ -69,6 +69,7 @@
   "fiscalYearStartMonth": 0,
   "graphTooltip": 1,
   "id": null,
+  "iteration": 1677469194439,
   "links": [],
   "liveNow": false,
   "panels": [
@@ -76,7 +77,7 @@
       "collapsed": false,
       "datasource": {
         "type": "prometheus",
-        "uid": "wRIkFL2Vz"
+        "uid": "${DS_PROMETHEUS}"
       },
       "gridPos": {
         "h": 1,
@@ -90,7 +91,7 @@
         {
           "datasource": {
             "type": "prometheus",
-            "uid": "wRIkFL2Vz"
+            "uid": "${DS_PROMETHEUS}"
           },
           "refId": "A"
         }
@@ -143,7 +144,7 @@
         },
         "textMode": "auto"
       },
-      "pluginVersion": "9.3.2",
+      "pluginVersion": "8.4.2",
       "targets": [
         {
           "datasource": {
@@ -205,7 +206,7 @@
         },
         "textMode": "auto"
       },
-      "pluginVersion": "9.3.2",
+      "pluginVersion": "8.4.2",
       "targets": [
         {
           "datasource": {
@@ -267,7 +268,7 @@
         },
         "textMode": "auto"
       },
-      "pluginVersion": "9.3.2",
+      "pluginVersion": "8.4.2",
       "targets": [
         {
           "datasource": {
@@ -339,7 +340,7 @@
         },
         "showUnfilled": true
       },
-      "pluginVersion": "9.3.2",
+      "pluginVersion": "8.4.2",
       "targets": [
         {
           "datasource": {
@@ -402,8 +403,6 @@
             "mode": "palette-classic"
           },
           "custom": {
-            "axisCenteredZero": false,
-            "axisColorMode": "text",
             "axisLabel": "",
             "axisPlacement": "auto",
             "barAlignment": 0,
@@ -528,7 +527,7 @@
         },
         "textMode": "auto"
       },
-      "pluginVersion": "9.3.2",
+      "pluginVersion": "8.4.2",
       "targets": [
         {
           "datasource": {
@@ -590,7 +589,7 @@
         },
         "textMode": "auto"
       },
-      "pluginVersion": "9.3.2",
+      "pluginVersion": "8.4.2",
       "targets": [
         {
           "datasource": {
@@ -652,7 +651,7 @@
         },
         "textMode": "auto"
       },
-      "pluginVersion": "9.3.2",
+      "pluginVersion": "8.4.2",
       "targets": [
         {
           "datasource": {
@@ -673,7 +672,7 @@
       "collapsed": false,
       "datasource": {
         "type": "prometheus",
-        "uid": "wRIkFL2Vz"
+        "uid": "${DS_PROMETHEUS}"
       },
       "gridPos": {
         "h": 1,
@@ -687,7 +686,7 @@
         {
           "datasource": {
             "type": "prometheus",
-            "uid": "wRIkFL2Vz"
+            "uid": "${DS_PROMETHEUS}"
           },
           "refId": "A"
         }
@@ -707,8 +706,6 @@
             "mode": "palette-classic"
           },
           "custom": {
-            "axisCenteredZero": false,
-            "axisColorMode": "text",
             "axisLabel": "",
             "axisPlacement": "auto",
             "barAlignment": 0,
@@ -814,8 +811,6 @@
             "mode": "palette-classic"
           },
           "custom": {
-            "axisCenteredZero": false,
-            "axisColorMode": "text",
             "axisLabel": "",
             "axisPlacement": "auto",
             "barAlignment": 0,
@@ -911,8 +906,6 @@
             "mode": "palette-classic"
           },
           "custom": {
-            "axisCenteredZero": false,
-            "axisColorMode": "text",
             "axisLabel": "",
             "axisPlacement": "auto",
             "barAlignment": 0,
@@ -1008,8 +1001,6 @@
             "mode": "palette-classic"
           },
           "custom": {
-            "axisCenteredZero": false,
-            "axisColorMode": "text",
             "axisLabel": "",
             "axisPlacement": "auto",
             "barAlignment": 0,
@@ -1113,8 +1104,6 @@
             "mode": "palette-classic"
           },
           "custom": {
-            "axisCenteredZero": false,
-            "axisColorMode": "text",
             "axisLabel": "",
             "axisPlacement": "auto",
             "barAlignment": 0,
@@ -1227,8 +1216,6 @@
             "mode": "palette-classic"
           },
           "custom": {
-            "axisCenteredZero": false,
-            "axisColorMode": "text",
             "axisLabel": "",
             "axisPlacement": "auto",
             "barAlignment": 0,
@@ -1276,7 +1263,7 @@
         "x": 16,
         "y": 18
       },
-      "id": 14,
+      "id": 57,
       "options": {
         "legend": {
           "calcs": [
@@ -1308,6 +1295,250 @@
       "title": "P99 Time Consumed Of Interface",
       "type": "timeseries"
     },
+    {
+      "description": "",
+      "fieldConfig": {
+        "defaults": {
+          "color": {
+            "mode": "palette-classic"
+          },
+          "custom": {
+            "axisLabel": "",
+            "axisPlacement": "auto",
+            "barAlignment": 0,
+            "drawStyle": "line",
+            "fillOpacity": 10,
+            "gradientMode": "none",
+            "hideFrom": {
+              "legend": false,
+              "tooltip": false,
+              "viz": false
+            },
+            "lineInterpolation": "linear",
+            "lineWidth": 1,
+            "pointSize": 5,
+            "scaleDistribution": {
+              "type": "linear"
+            },
+            "showPoints": "never",
+            "spanNulls": false,
+            "stacking": {
+              "group": "A",
+              "mode": "none"
+            },
+            "thresholdsStyle": {
+              "mode": "off"
+            }
+          },
+          "mappings": [
+            {
+              "options": {
+                "match": "empty",
+                "result": {
+                  "index": 0,
+                  "text": "0"
+                }
+              },
+              "type": "special"
+            },
+            {
+              "options": {
+                "match": "null+nan",
+                "result": {
+                  "index": 1,
+                  "text": "0"
+                }
+              },
+              "type": "special"
+            }
+          ],
+          "thresholds": {
+            "mode": "absolute",
+            "steps": [
+              {
+                "color": "green",
+                "value": null
+              }
+            ]
+          },
+          "unit": "ns"
+        },
+        "overrides": []
+      },
+      "gridPos": {
+        "h": 8,
+        "w": 12,
+        "x": 0,
+        "y": 26
+      },
+      "id": 56,
+      "options": {
+        "legend": {
+          "calcs": [
+            "mean"
+          ],
+          "displayMode": "table",
+          "placement": "right",
+          "showLegend": true
+        },
+        "tooltip": {
+          "mode": "multi",
+          "sort": "desc"
+        }
+      },
+      "targets": [
+        {
+          "datasource": {
+            "type": "prometheus",
+            "uid": "${DS_PROMETHEUS}"
+          },
+          "editorMode": "code",
+          "exemplar": true,
+          "expr": "sum(rate(session_idle_time_sum{instance=\"$instance\"}[1m])) / sum(rate(session_idle_time_count{instance=\"$instance\"}[1m]))",
+          "hide": false,
+          "interval": "",
+          "legendFormat": "Average Idle",
+          "range": true,
+          "refId": "B"
+        },
+        {
+          "datasource": {
+            "type": "prometheus",
+            "uid": "${DS_PROMETHEUS}"
+          },
+          "exemplar": true,
+          "expr": "sum(rate(performance_overview_seconds_sum{instance=~\"$instance\"}[1m])) / sum(rate(performance_overview_seconds_count{instance=~\"$instance\"}[1m])) * 1000000000",
+          "hide": false,
+          "interval": "",
+          "legendFormat": "Average Busy",
+          "refId": "A"
+        }
+      ],
+      "title": "Session Idle Time",
+      "type": "timeseries"
+    },
+    {
+      "fieldConfig": {
+        "defaults": {
+          "color": {
+            "mode": "palette-classic"
+          },
+          "custom": {
+            "axisLabel": "",
+            "axisPlacement": "auto",
+            "barAlignment": 0,
+            "drawStyle": "line",
+            "fillOpacity": 5,
+            "gradientMode": "none",
+            "hideFrom": {
+              "legend": false,
+              "tooltip": false,
+              "viz": false
+            },
+            "lineInterpolation": "linear",
+            "lineWidth": 1,
+            "pointSize": 5,
+            "scaleDistribution": {
+              "type": "linear"
+            },
+            "showPoints": "never",
+            "spanNulls": false,
+            "stacking": {
+              "group": "A",
+              "mode": "none"
+            },
+            "thresholdsStyle": {
+              "mode": "off"
+            }
+          },
+          "mappings": [],
+          "thresholds": {
+            "mode": "absolute",
+            "steps": [
+              {
+                "color": "green",
+                "value": null
+              },
+              {
+                "color": "red",
+                "value": 80
+              }
+            ]
+          }
+        },
+        "overrides": [
+          {
+            "__systemRef": "hideSeriesFrom",
+            "matcher": {
+              "id": "byNames",
+              "options": {
+                "mode": "exclude",
+                "names": [
+                  "Total"
+                ],
+                "prefix": "All except:",
+                "readOnly": true
+              }
+            },
+            "properties": [
+              {
+                "id": "custom.hideFrom",
+                "value": {
+                  "legend": false,
+                  "tooltip": false,
+                  "viz": true
+                }
+              }
+            ]
+          }
+        ]
+      },
+      "gridPos": {
+        "h": 8,
+        "w": 12,
+        "x": 12,
+        "y": 26
+      },
+      "id": 54,
+      "options": {
+        "legend": {
+          "calcs": [],
+          "displayMode": "list",
+          "placement": "bottom"
+        },
+        "tooltip": {
+          "mode": "single",
+          "sort": "none"
+        }
+      },
+      "targets": [
+        {
+          "datasource": {
+            "type": "prometheus",
+            "uid": "${DS_PROMETHEUS}"
+          },
+          "exemplar": true,
+          "expr": "thrift_connections{instance=~\"$instance\", name=~\".*Client.*\"}",
+          "interval": "",
+          "legendFormat": "Total",
+          "refId": "A"
+        },
+        {
+          "datasource": {
+            "type": "prometheus",
+            "uid": "${DS_PROMETHEUS}"
+          },
+          "exemplar": true,
+          "expr": "thrift_active_threads{instance=~\"$instance\", name=~\".*Client.*\"}",
+          "hide": false,
+          "interval": "",
+          "legendFormat": "Active",
+          "refId": "B"
+        }
+      ],
+      "title": "Client Connection",
+      "type": "timeseries"
+    },
     {
       "datasource": {
         "type": "prometheus",
@@ -1320,8 +1551,6 @@
             "mode": "palette-classic"
           },
           "custom": {
-            "axisCenteredZero": false,
-            "axisColorMode": "text",
             "axisLabel": "",
             "axisPlacement": "auto",
             "barAlignment": 0,
@@ -1388,7 +1617,7 @@
         "h": 8,
         "w": 12,
         "x": 0,
-        "y": 26
+        "y": 34
       },
       "id": 46,
       "options": {
@@ -1434,8 +1663,6 @@
             "mode": "palette-classic"
           },
           "custom": {
-            "axisCenteredZero": false,
-            "axisColorMode": "text",
             "axisLabel": "",
             "axisPlacement": "auto",
             "barAlignment": 0,
@@ -1481,7 +1708,7 @@
         "h": 8,
         "w": 12,
         "x": 12,
-        "y": 26
+        "y": 34
       },
       "id": 24,
       "options": {
@@ -1527,8 +1754,6 @@
             "mode": "palette-classic"
           },
           "custom": {
-            "axisCenteredZero": false,
-            "axisColorMode": "text",
             "axisLabel": "",
             "axisPlacement": "auto",
             "barAlignment": 0,
@@ -1595,7 +1820,7 @@
         "h": 8,
         "w": 12,
         "x": 0,
-        "y": 34
+        "y": 42
       },
       "id": 47,
       "options": {
@@ -1641,8 +1866,6 @@
             "mode": "palette-classic"
           },
           "custom": {
-            "axisCenteredZero": false,
-            "axisColorMode": "text",
             "axisLabel": "",
             "axisPlacement": "auto",
             "barAlignment": 0,
@@ -1688,7 +1911,7 @@
         "h": 8,
         "w": 12,
         "x": 12,
-        "y": 34
+        "y": 42
       },
       "id": 28,
       "options": {
@@ -1733,8 +1956,6 @@
             "mode": "palette-classic"
           },
           "custom": {
-            "axisCenteredZero": false,
-            "axisColorMode": "text",
             "axisLabel": "",
             "axisPlacement": "auto",
             "barAlignment": 0,
@@ -1779,7 +2000,7 @@
         "h": 8,
         "w": 8,
         "x": 0,
-        "y": 42
+        "y": 50
       },
       "id": 11,
       "options": {
@@ -1823,8 +2044,6 @@
             "mode": "palette-classic"
           },
           "custom": {
-            "axisCenteredZero": false,
-            "axisColorMode": "text",
             "axisLabel": "",
             "axisPlacement": "auto",
             "barAlignment": 0,
@@ -1891,7 +2110,7 @@
         "h": 8,
         "w": 8,
         "x": 8,
-        "y": 42
+        "y": 50
       },
       "id": 51,
       "options": {
@@ -1936,8 +2155,6 @@
             "mode": "palette-classic"
           },
           "custom": {
-            "axisCenteredZero": false,
-            "axisColorMode": "text",
             "axisLabel": "",
             "axisPlacement": "auto",
             "barAlignment": 0,
@@ -1983,7 +2200,7 @@
         "h": 8,
         "w": 8,
         "x": 16,
-        "y": 42
+        "y": 50
       },
       "id": 13,
       "options": {
@@ -2020,13 +2237,13 @@
       "collapsed": false,
       "datasource": {
         "type": "prometheus",
-        "uid": "wRIkFL2Vz"
+        "uid": "${DS_PROMETHEUS}"
       },
       "gridPos": {
         "h": 1,
         "w": 24,
         "x": 0,
-        "y": 50
+        "y": 58
       },
       "id": 34,
       "panels": [],
@@ -2034,7 +2251,7 @@
         {
           "datasource": {
             "type": "prometheus",
-            "uid": "wRIkFL2Vz"
+            "uid": "${DS_PROMETHEUS}"
           },
           "refId": "A"
         }
@@ -2053,8 +2270,6 @@
             "mode": "palette-classic"
           },
           "custom": {
-            "axisCenteredZero": false,
-            "axisColorMode": "text",
             "axisLabel": "",
             "axisPlacement": "auto",
             "barAlignment": 0,
@@ -2100,7 +2315,7 @@
         "h": 8,
         "w": 8,
         "x": 0,
-        "y": 51
+        "y": 59
       },
       "id": 15,
       "options": {
@@ -2155,8 +2370,6 @@
             "mode": "palette-classic"
           },
           "custom": {
-            "axisCenteredZero": false,
-            "axisColorMode": "text",
             "axisLabel": "",
             "axisPlacement": "auto",
             "barAlignment": 0,
@@ -2202,7 +2415,7 @@
         "h": 8,
         "w": 8,
         "x": 8,
-        "y": 51
+        "y": 59
       },
       "id": 18,
       "options": {
@@ -2245,8 +2458,6 @@
             "mode": "palette-classic"
           },
           "custom": {
-            "axisCenteredZero": false,
-            "axisColorMode": "text",
             "axisLabel": "",
             "axisPlacement": "auto",
             "barAlignment": 0,
@@ -2308,7 +2519,7 @@
         "h": 8,
         "w": 8,
         "x": 16,
-        "y": 51
+        "y": 59
       },
       "id": 17,
       "options": {
@@ -2364,8 +2575,6 @@
             "mode": "palette-classic"
           },
           "custom": {
-            "axisCenteredZero": false,
-            "axisColorMode": "text",
             "axisLabel": "",
             "axisPlacement": "auto",
             "barAlignment": 0,
@@ -2411,7 +2620,7 @@
         "h": 8,
         "w": 8,
         "x": 0,
-        "y": 59
+        "y": 67
       },
       "id": 48,
       "options": {
@@ -2479,8 +2688,6 @@
             "mode": "palette-classic"
           },
           "custom": {
-            "axisCenteredZero": false,
-            "axisColorMode": "text",
             "axisLabel": "",
             "axisPlacement": "auto",
             "barAlignment": 0,
@@ -2526,7 +2733,7 @@
         "h": 8,
         "w": 8,
         "x": 8,
-        "y": 59
+        "y": 67
       },
       "id": 52,
       "options": {
@@ -2569,8 +2776,6 @@
             "mode": "palette-classic"
           },
           "custom": {
-            "axisCenteredZero": false,
-            "axisColorMode": "text",
             "axisLabel": "",
             "axisPlacement": "auto",
             "barAlignment": 0,
@@ -2616,7 +2821,7 @@
         "h": 8,
         "w": 8,
         "x": 16,
-        "y": 59
+        "y": 67
       },
       "id": 49,
       "options": {
@@ -2671,8 +2876,6 @@
             "mode": "palette-classic"
           },
           "custom": {
-            "axisCenteredZero": false,
-            "axisColorMode": "text",
             "axisLabel": "",
             "axisPlacement": "auto",
             "barAlignment": 0,
@@ -2779,7 +2982,7 @@
         "h": 8,
         "w": 8,
         "x": 0,
-        "y": 67
+        "y": 75
       },
       "id": 44,
       "options": {
@@ -2834,8 +3037,6 @@
             "mode": "palette-classic"
           },
           "custom": {
-            "axisCenteredZero": false,
-            "axisColorMode": "text",
             "axisLabel": "",
             "axisPlacement": "auto",
             "barAlignment": 0,
@@ -2942,7 +3143,7 @@
         "h": 8,
         "w": 8,
         "x": 8,
-        "y": 67
+        "y": 75
       },
       "id": 16,
       "options": {
@@ -2997,8 +3198,6 @@
             "mode": "palette-classic"
           },
           "custom": {
-            "axisCenteredZero": false,
-            "axisColorMode": "text",
             "axisLabel": "",
             "axisPlacement": "auto",
             "barAlignment": 0,
@@ -3120,7 +3319,7 @@
         "h": 8,
         "w": 8,
         "x": 16,
-        "y": 67
+        "y": 75
       },
       "id": 20,
       "options": {
@@ -3153,8 +3352,8 @@
       "type": "timeseries"
     }
   ],
-  "refresh": "15m",
-  "schemaVersion": 37,
+  "refresh": "10s",
+  "schemaVersion": 35,
   "style": "dark",
   "tags": [],
   "templating": {
@@ -3226,6 +3425,6 @@
   "timezone": "browser",
   "title": "Apache IoTDB Performance Overview Dashboard",
   "uid": "ZRfEph04k",
-  "version": 1,
+  "version": 2,
   "weekStart": ""
 }
\ No newline at end of file
diff --git a/docs/UserGuide/Monitor-Alert/Metric-Tool.md b/docs/UserGuide/Monitor-Alert/Metric-Tool.md
index 3b0a7ad102..3879be46df 100644
--- a/docs/UserGuide/Monitor-Alert/Metric-Tool.md
+++ b/docs/UserGuide/Monitor-Alert/Metric-Tool.md
@@ -121,7 +121,21 @@ carefully evaluated. The current Core-level metrics are as follows:
 | entry                     | name="{{interface}}"                              | Timer     | The time consumed of thrift operations              |
 | mem                       | name="IoTConsensus"                               | AutoGauge | The memory usage of IoTConsensus, Unit: byte        |
 
-#### 4.1.2. Node Statistics
+#### 4.1.2. Interface
+
+| Metric                | Tags                               | Type      | Description                                                    |
+| --------------------- |------------------------------------| --------- | -------------------------------------------------------------- |
+| thrift_connections    | name="ConfigNodeRPC"               | AutoGauge | The number of thrift internal connections in ConfigNode        |
+| thrift_connections    | name="InternalRPC"                 | AutoGauge | The number of thrift internal connections in DataNode          |
+| thrift_connections    | name="MPPDataExchangeRPC"          | AutoGauge | The number of thrift internal connections in MPP               |
+| thrift_connections    | name="ClientRPC"                   | AutoGauge | The number of thrift connections of Client                     |
+| thrift_active_threads | name="ConfigNodeRPC-Service"       | AutoGauge | The number of thrift active internal connections in ConfigNode |
+| thrift_active_threads | name="DataNodeInternalRPC-Service" | AutoGauge | The number of thrift active internal connections in DataNode   |
+| thrift_active_threads | name="MPPDataExchangeRPC-Service"  | AutoGauge | The number of thrift active internal connections in MPP        |
+| thrift_active_threads | name="ClientRPC-Service"           | AutoGauge | The number of thrift active connections of client              |
+| session_idle_time     | name = "sessionId"                 | Histogram | The distribution of idle time of different sessions            |
+
+#### 4.1.3. Node Statistics
 | Metric   | Tags                                  | Type      | Description                               |
 | -------- | ------------------------------------- | --------- | ----------------------------------------- |
 | quantity | name="database"                       | AutoGauge | The number of database                    |
@@ -129,7 +143,7 @@ carefully evaluated. The current Core-level metrics are as follows:
 | quantity | name="pointsIn"                       | Counter   | The number of write points                |
 | points   | database="{{database}}", type="flush" | Gauge     | The point number of last flushed memtable |
 
-#### 4.1.3. Cluster Tracing
+#### 4.1.4. Cluster Tracing
 | Metric                               | Tags                                                 | Type  | Description                                      |
 | ------------------------------------ | ---------------------------------------------------- | ----- | ------------------------------------------------ |
 | performance_overview                 | interface="{{interface}}", type="{{statement_type}}" | Timer | The time consumed of operations in client        |
@@ -147,7 +161,7 @@ carefully evaluated. The current Core-level metrics are as follows:
 | performance_overview_schedule_detail | stage="memtable"                                     | Timer | The time consumed on writing memtable            |
 | performance_overview_schedule_detail | stage="last_cache"                                   | Timer | The time consumed on updating last cache         |
 
-#### 4.1.4. Task Statistics
+#### 4.1.5. Task Statistics
 
 | Metric    | Tags                                              | Type      | Description                           |
 | --------- | ------------------------------------------------- | --------- | ------------------------------------- |
@@ -156,7 +170,7 @@ carefully evaluated. The current Core-level metrics are as follows:
 | queue     | name="flush",status="running/waiting"             | AutoGauge | The number of flush tasks             |
 | cost_task | name="inner_compaction/cross_compaction/flush"    | Gauge     | The time consumed of compaction tasks |
 
-#### 4.1.5. IoTDB process
+#### 4.1.6. IoTDB process
 
 | Metric            | Tags           | Type      | Description                                            |
 | ----------------- | -------------- | --------- | ------------------------------------------------------ |
@@ -166,7 +180,7 @@ carefully evaluated. The current Core-level metrics are as follows:
 | process_total_mem | name="memory"  | AutoGauge | The current requested memory for IoTDB process         |
 | process_free_mem  | name="memory"  | AutoGauge | The free available memory of IoTDB process             |
 
-#### 4.1.6. System
+#### 4.1.7. System
 
 | Metric                         | Tags          | Type      | Description                                                |
 | ------------------------------ | ------------- | --------- | ---------------------------------------------------------- |
@@ -180,13 +194,13 @@ carefully evaluated. The current Core-level metrics are as follows:
 | sys_disk_total_space           | name="disk"   | AutoGauge | The total disk space                                       |
 | sys_disk_free_space            | name="disk"   | AutoGauge | The available disk space                                   |
 
-#### 4.1.7. Log
+#### 4.1.8. Log
 
 | Metric         | Tags                                | Type    | Description              |
 | -------------- | ----------------------------------- | ------- | ------------------------ |
 | logback_events | level="trace/debug/info/warn/error" | Counter | The number of log events |
 
-#### 4.1.8. File
+#### 4.1.9. File
 
 | Metric     | Tags                      | Type      | Description                                                                 |
 | ---------- | ------------------------- | --------- | --------------------------------------------------------------------------- |
@@ -206,7 +220,7 @@ carefully evaluated. The current Core-level metrics are as follows:
 | file_count | name="open_file_handlers" | AutoGauge | The count of open files of the IoTDB process, only supports Linux and MacOS |
 | file_count | name="mods                | AutoGauge | The count of modification file                                              |
 
-#### 4.1.9. JVM Memory
+#### 4.1.10. JVM Memory
 
 | Metric                          | Tags                            | Type      | Description                 |
 | ------------------------------- | ------------------------------- | --------- | --------------------------- |
@@ -217,7 +231,7 @@ carefully evaluated. The current Core-level metrics are as follows:
 | jvm_memory_max_bytes            | {area="heap/nonheap",id="xxx",} | AutoGauge | The max memory of JVM       |
 | jvm_memory_used_bytes           | {area="heap/nonheap",id="xxx",} | AutoGauge | The used memory of JVM      |
 
-#### 4.1.10. JVM Thread
+#### 4.1.11. JVM Thread
 
 | Metric                     | Tags                                                          | Type      | Description                              |
 | -------------------------- | ------------------------------------------------------------- | --------- | ---------------------------------------- |
@@ -226,7 +240,7 @@ carefully evaluated. The current Core-level metrics are as follows:
 | jvm_threads_peak_threads   |                                                               | AutoGauge | The number of peak thread                |
 | jvm_threads_states_threads | state="runnable/blocked/waiting/timed-waiting/new/terminated" | AutoGauge | The number of thread in different states |
 
-#### 4.1.11. JVM GC
+#### 4.1.12. JVM GC
 
 | Metric                        | Tags                                                  | Type      | Description                                                                 |
 | ----------------------------- | ----------------------------------------------------- | --------- | --------------------------------------------------------------------------- |
@@ -285,20 +299,7 @@ carefully evaluated. The current Core-level metrics are as follows:
 | cache     | name="DataPartition", type="hit"   | Counter   | The hit number of DataPartition Cache                                    |
 | cache     | name="DataPartition", type="all"   | Counter   | The access number of SDataPartition Cache                                |
 
-#### 4.2.4. Interface
-
-| Metric                | Tags                               | Type      | Description                                                    |
-| --------------------- | ---------------------------------- | --------- | -------------------------------------------------------------- |
-| thrift_connections    | name="ConfigNodeRPC"               | AutoGauge | The number of thrift internal connections in ConfigNode        |
-| thrift_connections    | name="Internal"                    | AutoGauge | The number of thrift internal connections in DataNode          |
-| thrift_connections    | name="MPPDataExchange"             | AutoGauge | The number of thrift internal connections in MPP               |
-| thrift_connections    | name="RPC"                         | AutoGauge | The number of thrift connections of Client                     |
-| thrift_active_threads | name="ConfigNodeRPC-Service"       | AutoGauge | The number of thrift active internal connections in ConfigNode |
-| thrift_active_threads | name="DataNodeInternalRPC-Service" | AutoGauge | The number of thrift active internal connections in DataNode   |
-| thrift_active_threads | name="MPPDataExchangeRPC-Service"  | AutoGauge | The number of thrift active internal connections in MPP        |
-| thrift_active_threads | name="ClientRPC-Service"           | AutoGauge | The number of thrift active connections of client              |
-
-#### 4.2.5. Memory
+#### 4.2.4. Memory
 
 | Metric | Tags                             | Type      | Description                                                  |
 | ------ | -------------------------------- | --------- | ------------------------------------------------------------ |
@@ -309,7 +310,7 @@ carefully evaluated. The current Core-level metrics are as follows:
 | mem    | name="IoTConsensusSync"          | AutoGauge | The memory usage of IoTConsensus SyncStatus, Unit: byte      |
 | mem    | name="schema_region_total_usage" | AutoGauge | The memory usage of all SchemaRegion, Unit: byte             |
 
-#### 4.2.6. Compaction
+#### 4.2.5. Compaction
 
 | Metric                | Tags                                                | Type    | Description                            |
 | --------------------- | --------------------------------------------------- | ------- | -------------------------------------- |
@@ -319,7 +320,7 @@ carefully evaluated. The current Core-level metrics are as follows:
 | compaction_task_count | name = "inner_compaction", type="unsequence"        | Counter | The number of inner sequence compction |
 | compaction_task_count | name = "cross_compaction", type="cross"             | Counter | The number of corss compction          |
 
-#### 4.2.7. IoTDB Process
+#### 4.2.6. IoTDB Process
 
 | Metric                | Tags           | Type      | Description                                 |
 | --------------------- | -------------- | --------- | ------------------------------------------- |
@@ -328,20 +329,20 @@ carefully evaluated. The current Core-level metrics are as follows:
 | process_threads_count | name="process" | AutoGauge | The number of thread of IoTDB process       |
 | process_status        | name="process" | AutoGauge | The status of IoTDB process, 1=live, 0=dead |
 
-#### 4.2.8. JVM Class
+#### 4.2.7. JVM Class
 
 | Metric                       | Tags | Type      | Description                  |
 | ---------------------------- | ---- | --------- | ---------------------------- |
 | jvm_classes_unloaded_classes |      | AutoGauge | The number of unloaded class |
 | jvm_classes_loaded_classes   |      | AutoGauge | The number of loaded class   |
 
-#### 4.2.9. JVM Compilation
+#### 4.2.8. JVM Compilation
 
 | Metric                  | Tags                                          | Type      | Description                      |
 | ----------------------- | --------------------------------------------- | --------- | -------------------------------- |
 | jvm_compilation_time_ms | {compiler="HotSpot 64-Bit Tiered Compilers",} | AutoGauge | The time consumed in compilation |
 
-#### 4.2.10. Query Planning
+#### 4.2.9. Query Planning
 
 | Metric          | Tags                         | Type  | Description                                         |
 | --------------- | ---------------------------- | ----- | --------------------------------------------------- |
@@ -351,14 +352,14 @@ carefully evaluated. The current Core-level metrics are as follows:
 | query_plan_cost | stage="partition_fetcher"    | Timer | The partition information fetching time-consuming   |
 | query_plan_cost | stage="schema_fetcher"       | Timer | The schema information fetching time-consuming      |
 
-#### 4.2.11. Plan Dispatcher
+#### 4.2.10. Plan Dispatcher
 
 | Metric     | Tags                      | Type  | Description                                                  |
 | ---------- | ------------------------- | ----- | ------------------------------------------------------------ |
 | dispatcher | stage="wait_for_dispatch" | Timer | The distribution plan dispatcher time-consuming              |
 | dispatcher | stage="dispatch_read"     | Timer | The distribution plan dispatcher time-consuming (only query) |
 
-#### 4.2.12. Query Resource
+#### 4.2.11. Query Resource
 
 | Metric         | Tags                     | Type | Description                                |
 | -------------- | ------------------------ | ---- | ------------------------------------------ |
@@ -367,7 +368,7 @@ carefully evaluated. The current Core-level metrics are as follows:
 | query_resource | type="flushing_memtable" | Rate | The access frequency of flushing memtables |
 | query_resource | type="working_memtable"  | Rate | The access frequency of working memtables  |
 
-#### 4.2.13. Data Exchange
+#### 4.2.12. Data Exchange
 
 | Metric              | Tags                                                                   | Type      | Description                                                     |
 | ------------------- | ---------------------------------------------------------------------- | --------- | --------------------------------------------------------------- |
@@ -381,7 +382,7 @@ carefully evaluated. The current Core-level metrics are as follows:
 | data_exchange_count | name="get_data_block_num", type="server/caller"                        | Histogram | The number of received TsBlocks by source handles               |
 | data_exchange_count | name="on_acknowledge_data_block_num", type="server/caller"             | Histogram | The number of acknowledged TsBlocks by source handles           |
 
-#### 4.2.14. Query Task Schedule
+#### 4.2.13. Query Task Schedule
 
 | Metric           | Tags                           | Type      | Description                                      |
 | ---------------- | ------------------------------ | --------- | ------------------------------------------------ |
@@ -390,7 +391,7 @@ carefully evaluated. The current Core-level metrics are as follows:
 | driver_scheduler | name="ready_queue_task_count"  | AutoGauge | The number of tasks queued in the ready queue    |
 | driver_scheduler | name="block_queued_task_count" | AutoGauge | The number of tasks queued in the blocking queue |
 
-#### 4.2.15. Query Execution
+#### 4.2.14. Query Execution
 
 | Metric                   | Tags                                                                                | Type    | Description                                                                             |
 | ------------------------ | ----------------------------------------------------------------------------------- | ------- | --------------------------------------------------------------------------------------- |
diff --git a/docs/zh/UserGuide/Monitor-Alert/Metric-Tool.md b/docs/zh/UserGuide/Monitor-Alert/Metric-Tool.md
index f3b75a8df7..ba236c6528 100644
--- a/docs/zh/UserGuide/Monitor-Alert/Metric-Tool.md
+++ b/docs/zh/UserGuide/Monitor-Alert/Metric-Tool.md
@@ -99,7 +99,21 @@ Core 级别的监控指标在系统运行中默认开启,每一个 Core 级别
 | entry                     | name="{{interface}}"                              | Timer     | Client 建立的 Thrift 的耗时情况        |
 | mem                       | name="IoTConsensus"                               | AutoGauge | IoT共识协议的内存占用,单位为byte      |
 
-#### 4.1.2. 节点统计
+#### 4.1.2. 接口层统计
+
+| Metric                | Tags                               | Type      | Description                         |
+| --------------------- |------------------------------------| --------- | ----------------------------------- |
+| thrift_connections    | name="ConfigNodeRPC"               | AutoGauge | ConfigNode 的内部 Thrift 连接数     |
+| thrift_connections    | name="InternalRPC"                 | AutoGauge | DataNode 的内部 Thrift 连接数       |
+| thrift_connections    | name="MPPDataExchangeRPC"          | AutoGauge | MPP 框架的内部 Thrift 连接数        |
+| thrift_connections    | name="ClientRPC"                   | AutoGauge | Client 建立的 Thrift 连接数         |
+| thrift_active_threads | name="ConfigNodeRPC-Service"       | AutoGauge | ConfigNode 的内部活跃 Thrift 连接数 |
+| thrift_active_threads | name="DataNodeInternalRPC-Service" | AutoGauge | DataNode 的内部活跃 Thrift 连接数   |
+| thrift_active_threads | name="MPPDataExchangeRPC-Service"  | AutoGauge | MPP 框架的内部活跃 Thrift 连接数    |
+| thrift_active_threads | name="ClientRPC-Service"           | AutoGauge | Client 建立的活跃 Thrift 连接数     |
+| session_idle_time     | name = "sessionId"                 | Histogram | 不同 Session 的空闲时间分布情况     |
+
+#### 4.1.3. 节点统计
 | Metric   | Tags                                  | Type      | Description                 |
 | -------- | ------------------------------------- | --------- | --------------------------- |
 | quantity | name="database"                       | AutoGauge | 系统数据库数量              |
@@ -107,7 +121,7 @@ Core 级别的监控指标在系统运行中默认开启,每一个 Core 级别
 | quantity | name="pointsIn"                       | Counter   | 系统累计写入点数            |
 | points   | database="{{database}}", type="flush" | Gauge     | 最新一个刷盘的memtale的点数 |
 
-#### 4.1.3. 集群全链路
+#### 4.1.4. 集群全链路
 | Metric                               | Tags                                                 | Type  | Description                |
 | ------------------------------------ | ---------------------------------------------------- | ----- | -------------------------- |
 | performance_overview                 | interface="{{interface}}", type="{{statement_type}}" | Timer | 客户端执行的操作的耗时情况 |
@@ -125,7 +139,7 @@ Core 级别的监控指标在系统运行中默认开启,每一个 Core 级别
 | performance_overview_schedule_detail | stage="memtable"                                     | Timer | 写入 Memtable 总耗时       |
 | performance_overview_schedule_detail | stage="last_cache"                                   | Timer | 更新 LastCache 总耗时      |
 
-#### 4.1.4. 任务统计
+#### 4.1.5. 任务统计
 
 | Metric    | Tags                                              | Type      | Description      |
 | --------- | ------------------------------------------------- | --------- | ---------------- |
@@ -134,7 +148,7 @@ Core 级别的监控指标在系统运行中默认开启,每一个 Core 级别
 | queue     | name="flush",status="running/waiting"             | AutoGauge | 刷盘任务数       |
 | cost_task | name="inner_compaction/cross_compaction/flush"    | Gauge     | 任务耗时情况     |
 
-#### 4.1.5. IoTDB 进程运行状态
+#### 4.1.6. IoTDB 进程运行状态
 
 | Metric            | Tags           | Type      | Description                         |
 | ----------------- | -------------- | --------- | ----------------------------------- |
@@ -144,7 +158,7 @@ Core 级别的监控指标在系统运行中默认开启,每一个 Core 级别
 | process_total_mem | name="memory"  | AutoGauge | IoTDB 进程当前已申请内存            |
 | process_free_mem  | name="memory"  | AutoGauge | IoTDB 进程当前剩余可用内存          |
 
-#### 4.1.6. 系统运行状态
+#### 4.1.7. 系统运行状态
 
 | Metric                         | Tags          | Type      | Description                              |
 | ------------------------------ | ------------- | --------- | ---------------------------------------- |
@@ -158,13 +172,13 @@ Core 级别的监控指标在系统运行中默认开启,每一个 Core 级别
 | sys_disk_total_space           | name="disk"   | AutoGauge | 系统磁盘总大小                           |
 | sys_disk_free_space            | name="disk"   | AutoGauge | 系统磁盘可用大小                         |
 
-#### 4.1.7. IoTDB 日志统计
+#### 4.1.8. IoTDB 日志统计
 
 | Metric         | Tags                                | Type    | Description        |
 | -------------- | ----------------------------------- | ------- | ------------------ |
 | logback_events | level="trace/debug/info/warn/error" | Counter | 不同类型的日志个数 |
 
-#### 4.1.8. 文件统计信息
+#### 4.1.9. 文件统计信息
 
 | Metric     | Tags                      | Type      | Description                              |
 | ---------- | ------------------------- | --------- | ---------------------------------------- |
@@ -184,7 +198,7 @@ Core 级别的监控指标在系统运行中默认开启,每一个 Core 级别
 | file_count | name="open_file_handlers" | AutoGauge | IoTDB 进程打开文件数,仅支持Linux和MacOS |
 | file_count | name="mods                | AutoGauge | Modification 文件的数目                  |
 
-#### 4.1.9. JVM 内存统计
+#### 4.1.10. JVM 内存统计
 
 | Metric                          | Tags                            | Type      | Description          |
 | ------------------------------- | ------------------------------- | --------- | -------------------- |
@@ -195,7 +209,7 @@ Core 级别的监控指标在系统运行中默认开启,每一个 Core 级别
 | jvm_memory_max_bytes            | {area="heap/nonheap",id="xxx",} | AutoGauge | 最大内存             |
 | jvm_memory_used_bytes           | {area="heap/nonheap",id="xxx",} | AutoGauge | 已使用内存大小       |
 
-#### 4.1.10. JVM 线程统计
+#### 4.1.11. JVM 线程统计
 
 | Metric                     | Tags                                                          | Type      | Description              |
 | -------------------------- | ------------------------------------------------------------- | --------- | ------------------------ |
@@ -204,7 +218,7 @@ Core 级别的监控指标在系统运行中默认开启,每一个 Core 级别
 | jvm_threads_peak_threads   |                                                               | AutoGauge | 峰值线程数               |
 | jvm_threads_states_threads | state="runnable/blocked/waiting/timed-waiting/new/terminated" | AutoGauge | 当前处于各种状态的线程数 |
 
-#### 4.1.11. JVM GC 统计
+#### 4.1.12. JVM GC 统计
 
 | Metric                        | Tags                                                  | Type      | Description                            |
 | ----------------------------- | ----------------------------------------------------- | --------- | -------------------------------------- |
@@ -232,22 +246,22 @@ Core 级别的监控指标在系统运行中默认开启,每一个 Core 级别
 
 #### 4.2.2. IoT共识协议统计
 
-| Metric        | Tags                                                                                         | Type      | Description                      |
-| ------------- | -------------------------------------------------------------------------------------------- | --------- | -------------------------------- |
-| iot_consensus | name="logDispatcher-{{IP}}:{{Port}}", region="{{region}}", type="currentSyncIndex"           | AutoGauge | 副本组同步线程的当前同步进度     |
-| iot_consensus | name="logDispatcher-{{IP}}:{{Port}}", region="{{region}}", type="cachedRequestInMemoryQueue" | AutoGauge | 副本组同步线程缓存队列请求总大小 |
-| iot_consensus | name="IoTConsensusServerImpl", region="{{region}}", type="searchIndex"                       | AutoGauge | 副本组主流程写入进度             |
-| iot_consensus | name="IoTConsensusServerImpl", region="{{region}}", type="safeIndex"                         | AutoGauge | 副本组同步进度                   |
+| Metric        | Tags                                                                                         | Type      | Description                       |
+| ------------- | -------------------------------------------------------------------------------------------- | --------- | --------------------------------- |
+| iot_consensus | name="logDispatcher-{{IP}}:{{Port}}", region="{{region}}", type="currentSyncIndex"           | AutoGauge | 副本组同步线程的当前同步进度      |
+| iot_consensus | name="logDispatcher-{{IP}}:{{Port}}", region="{{region}}", type="cachedRequestInMemoryQueue" | AutoGauge | 副本组同步线程缓存队列请求总大小  |
+| iot_consensus | name="IoTConsensusServerImpl", region="{{region}}", type="searchIndex"                       | AutoGauge | 副本组主流程写入进度              |
+| iot_consensus | name="IoTConsensusServerImpl", region="{{region}}", type="safeIndex"                         | AutoGauge | 副本组同步进度                    |
 | iot_consensus | name="IoTConsensusServerImpl", region="{{region}}", type="syncLag"                           | AutoGauge | 副本组写入进度与同步进度差        |
-| iot_consensus | name="IoTConsensusServerImpl", region="{{region}}", type="LogEntriesFromWAL"                 | AutoGauge | 副本组Batch中来自WAL的日志项数量 |
-| iot_consensus | name="IoTConsensusServerImpl", region="{{region}}", type="LogEntriesFromQueue"               | AutoGauge | 副本组Batch中来自队列的日志项数量  |
-| stage         | name="iot_consensus", region="{{region}}", type="getStateMachineLock"                        | Histogram | 主流程获取状态机锁耗时           |
-| stage         | name="iot_consensus", region="{{region}}", type="checkingBeforeWrite"                        | Histogram | 主流程写入状态机检查耗时         |
-| stage         | name="iot_consensus", region="{{region}}", type="writeStateMachine"                          | Histogram | 主流程写入状态机耗时             |
-| stage         | name="iot_consensus", region="{{region}}", type="offerRequestToQueue"                        | Histogram | 主流程尝试添加队列耗时           |
-| stage         | name="iot_consensus", region="{{region}}", type="consensusWrite"                             | Histogram | 主流程全写入耗时                 |
-| stage         | name="iot_consensus", region="{{region}}", type="constructBatch"                             | Histogram | 同步线程构造 Batch 耗时          |
-| stage         | name="iot_consensus", region="{{region}}", type="syncLogTimePerRequest"                      | Histogram | 异步回调流程同步日志耗时         |
+| iot_consensus | name="IoTConsensusServerImpl", region="{{region}}", type="LogEntriesFromWAL"                 | AutoGauge | 副本组Batch中来自WAL的日志项数量  |
+| iot_consensus | name="IoTConsensusServerImpl", region="{{region}}", type="LogEntriesFromQueue"               | AutoGauge | 副本组Batch中来自队列的日志项数量 |
+| stage         | name="iot_consensus", region="{{region}}", type="getStateMachineLock"                        | Histogram | 主流程获取状态机锁耗时            |
+| stage         | name="iot_consensus", region="{{region}}", type="checkingBeforeWrite"                        | Histogram | 主流程写入状态机检查耗时          |
+| stage         | name="iot_consensus", region="{{region}}", type="writeStateMachine"                          | Histogram | 主流程写入状态机耗时              |
+| stage         | name="iot_consensus", region="{{region}}", type="offerRequestToQueue"                        | Histogram | 主流程尝试添加队列耗时            |
+| stage         | name="iot_consensus", region="{{region}}", type="consensusWrite"                             | Histogram | 主流程全写入耗时                  |
+| stage         | name="iot_consensus", region="{{region}}", type="constructBatch"                             | Histogram | 同步线程构造 Batch 耗时           |
+| stage         | name="iot_consensus", region="{{region}}", type="syncLogTimePerRequest"                      | Histogram | 异步回调流程同步日志耗时          |
 
 #### 4.2.3. 缓存统计
 
@@ -264,20 +278,7 @@ Core 级别的监控指标在系统运行中默认开启,每一个 Core 级别
 | cache     | name="DataPartition", type="hit"   | Counter   | DataPartition Cache 的命中次数                          |
 | cache     | name="DataPartition", type="all"   | Counter   | DataPartition Cache 的访问次数                          |
 
-#### 4.2.4. 接口层统计
-
-| Metric                | Tags                               | Type      | Description                         |
-| --------------------- | ---------------------------------- | --------- | ----------------------------------- |
-| thrift_connections    | name="ConfigNodeRPC"               | AutoGauge | ConfigNode 的内部 Thrift 连接数     |
-| thrift_connections    | name="Internal"                    | AutoGauge | DataNode 的内部 Thrift 连接数       |
-| thrift_connections    | name="MPPDataExchange"             | AutoGauge | MPP 框架的内部 Thrift 连接数        |
-| thrift_connections    | name="RPC"                         | AutoGauge | Client 建立的 Thrift 连接数         |
-| thrift_active_threads | name="ConfigNodeRPC-Service"       | AutoGauge | ConfigNode 的内部活跃 Thrift 连接数 |
-| thrift_active_threads | name="DataNodeInternalRPC-Service" | AutoGauge | DataNode 的内部活跃 Thrift 连接数   |
-| thrift_active_threads | name="MPPDataExchangeRPC-Service"  | AutoGauge | MPP 框架的内部活跃 Thrift 连接数    |
-| thrift_active_threads | name="ClientRPC-Service"           | AutoGauge | Client 建立的活跃 Thrift 连接数     |
-
-#### 4.2.5. 内存统计
+#### 4.2.4. 内存统计
 | Metric | Tags                             | Type      | Description                                       |
 | ------ | -------------------------------- | --------- | ------------------------------------------------- |
 | mem    | name="database_{{name}}"         | AutoGauge | DataNode内对应DataRegion的内存占用,单位为byte    |
@@ -287,7 +288,7 @@ Core 级别的监控指标在系统运行中默认开启,每一个 Core 级别
 | mem    | name="IoTConsensusSync"          | AutoGauge | IoT共识协议用于同步的内存占用,单位为byte         |
 | mem    | name="schema_region_total_usage" | AutoGauge | 所有SchemaRegion的总内存占用,单位为byte          |
 
-#### 4.2.6. 合并统计
+#### 4.2.5. 合并统计
 
 | Metric                | Tags                                                | Type    | Description        |
 | --------------------- | --------------------------------------------------- | ------- | ------------------ |
@@ -297,7 +298,7 @@ Core 级别的监控指标在系统运行中默认开启,每一个 Core 级别
 | compaction_task_count | name = "inner_compaction", type="unsequence"        | Counter | 乱序空间内合并次数 |
 | compaction_task_count | name = "cross_compaction", type="cross"             | Counter | 跨空间合并次数     |
 
-#### 4.2.7. IoTDB 进程统计
+#### 4.2.6. IoTDB 进程统计
 
 | Metric                | Tags           | Type      | Description                          |
 | --------------------- | -------------- | --------- | ------------------------------------ |
@@ -306,20 +307,20 @@ Core 级别的监控指标在系统运行中默认开启,每一个 Core 级别
 | process_threads_count | name="process" | AutoGauge | IoTDB 进程当前线程数                 |
 | process_status        | name="process" | AutoGauge | IoTDB 进程存活状态,1为存活,0为终止 |
 
-#### 4.2.8. JVM 类加载统计
+#### 4.2.7. JVM 类加载统计
 
 | Metric                       | Tags | Type      | Description         |
 | ---------------------------- | ---- | --------- | ------------------- |
 | jvm_classes_unloaded_classes |      | AutoGauge | 累计卸载的class数量 |
 | jvm_classes_loaded_classes   |      | AutoGauge | 累计加载的class数量 |
 
-#### 4.2.9. JVM 编译时间统计
+#### 4.2.8. JVM 编译时间统计
 
 | Metric                  | Tags                                          | Type      | Description        |
 | ----------------------- | --------------------------------------------- | --------- | ------------------ |
 | jvm_compilation_time_ms | {compiler="HotSpot 64-Bit Tiered Compilers",} | AutoGauge | 耗费在编译上的时间 |
 
-#### 4.2.10. 查询规划耗时统计
+#### 4.2.9. 查询规划耗时统计
 
 | Metric          | Tags                         | Type  | Description                |
 | --------------- | ---------------------------- | ----- | -------------------------- |
@@ -329,14 +330,14 @@ Core 级别的监控指标在系统运行中默认开启,每一个 Core 级别
 | query_plan_cost | stage="partition_fetcher"    | Timer | 分区信息拉取耗时           |
 | query_plan_cost | stage="schema_fetcher"       | Timer | 元数据信息拉取耗时         |
 
-#### 4.2.11. 执行计划分发耗时统计
+#### 4.2.10. 执行计划分发耗时统计
 
 | Metric     | Tags                      | Type  | Description          |
 | ---------- | ------------------------- | ----- | -------------------- |
 | dispatcher | stage="wait_for_dispatch" | Timer | 分发执行计划耗时     |
 | dispatcher | stage="dispatch_read"     | Timer | 查询执行计划发送耗时 |
 
-#### 4.2.12. 查询资源访问统计
+#### 4.2.11. 查询资源访问统计
 
 | Metric         | Tags                     | Type | Description                |
 | -------------- | ------------------------ | ---- | -------------------------- |
@@ -345,7 +346,7 @@ Core 级别的监控指标在系统运行中默认开启,每一个 Core 级别
 | query_resource | type="flushing_memtable" | Rate | flushing memtable 访问频率 |
 | query_resource | type="working_memtable"  | Rate | working memtable 访问频率  |
 
-#### 4.2.13. 数据传输模块统计
+#### 4.2.12. 数据传输模块统计
 
 | Metric              | Tags                                                                   | Type      | Description                             |
 | ------------------- | ---------------------------------------------------------------------- | --------- | --------------------------------------- |
@@ -359,7 +360,7 @@ Core 级别的监控指标在系统运行中默认开启,每一个 Core 级别
 | data_exchange_count | name="get_data_block_num", type="server/caller"                        | Histogram | source handle 接收 TsBlock 数量         |
 | data_exchange_count | name="on_acknowledge_data_block_num", type="server/caller"             | Histogram | source handle 确认接收 TsBlock 数量     |
 
-#### 4.2.14. 查询任务调度统计
+#### 4.2.13. 查询任务调度统计
 
 | Metric           | Tags                           | Type      | Description        |
 | ---------------- | ------------------------------ | --------- | ------------------ |
@@ -368,7 +369,7 @@ Core 级别的监控指标在系统运行中默认开启,每一个 Core 级别
 | driver_scheduler | name="ready_queue_task_count"  | AutoGauge | 就绪队列排队任务数 |
 | driver_scheduler | name="block_queued_task_count" | AutoGauge | 阻塞队列排队任务数 |
 
-#### 4.2.15. 查询执行耗时统计
+#### 4.2.14. 查询执行耗时统计
 
 | Metric                   | Tags                                                                                | Type    | Description                                    |
 | ------------------------ | ----------------------------------------------------------------------------------- | ------- | ---------------------------------------------- |
diff --git a/node-commons/src/main/java/org/apache/iotdb/commons/service/metric/enums/Metric.java b/node-commons/src/main/java/org/apache/iotdb/commons/service/metric/enums/Metric.java
index 9644224f04..efc66b7ffb 100644
--- a/node-commons/src/main/java/org/apache/iotdb/commons/service/metric/enums/Metric.java
+++ b/node-commons/src/main/java/org/apache/iotdb/commons/service/metric/enums/Metric.java
@@ -88,7 +88,8 @@ public enum Metric {
   PERFORMANCE_OVERVIEW_DETAIL,
   PERFORMANCE_OVERVIEW_SCHEDULE_DETAIL,
   SCHEMA_REGION,
-  SCHEMA_ENGINE;
+  SCHEMA_ENGINE,
+  SESSION_IDLE_TIME;
 
   @Override
   public String toString() {
diff --git a/server/src/main/java/org/apache/iotdb/db/audit/AuditLogger.java b/server/src/main/java/org/apache/iotdb/db/audit/AuditLogger.java
index 4d7e7f94bd..3d1fe71dea 100644
--- a/server/src/main/java/org/apache/iotdb/db/audit/AuditLogger.java
+++ b/server/src/main/java/org/apache/iotdb/db/audit/AuditLogger.java
@@ -63,7 +63,9 @@ public class AuditLogger {
 
   private static final SessionManager SESSION_MANAGER = SessionManager.getInstance();
 
-  private AuditLogger() {}
+  private AuditLogger() {
+    // empty constructor
+  }
 
   @NotNull
   private static InsertRowStatement generateInsertStatement(
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/execution/exchange/MPPDataExchangeServiceMetrics.java b/server/src/main/java/org/apache/iotdb/db/mpp/execution/exchange/MPPDataExchangeServiceMetrics.java
index b49e5e9a5c..4297a217a9 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/execution/exchange/MPPDataExchangeServiceMetrics.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/execution/exchange/MPPDataExchangeServiceMetrics.java
@@ -39,7 +39,7 @@ public class MPPDataExchangeServiceMetrics implements IMetricSet {
   public void bindTo(AbstractMetricService metricService) {
     metricService.createAutoGauge(
         Metric.THRIFT_ACTIVE_THREADS.toString(),
-        MetricLevel.IMPORTANT,
+        MetricLevel.CORE,
         thriftServiceThread,
         AbstractThriftServiceThread::getActiveThreadCount,
         Tag.NAME.toString(),
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/execution/exchange/MppDataExchangeServiceThriftHandlerMetrics.java b/server/src/main/java/org/apache/iotdb/db/mpp/execution/exchange/MppDataExchangeServiceThriftHandlerMetrics.java
index cf194e423c..e7e543880b 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/execution/exchange/MppDataExchangeServiceThriftHandlerMetrics.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/execution/exchange/MppDataExchangeServiceThriftHandlerMetrics.java
@@ -42,11 +42,11 @@ public class MppDataExchangeServiceThriftHandlerMetrics implements IMetricSet {
     MetricService.getInstance()
         .createAutoGauge(
             Metric.THRIFT_CONNECTIONS.toString(),
-            MetricLevel.IMPORTANT,
+            MetricLevel.CORE,
             thriftConnectionNumber,
             AtomicLong::get,
             Tag.NAME.toString(),
-            "MPPDataExchange");
+            "MPPDataExchangeRPC");
   }
 
   @Override
@@ -56,7 +56,7 @@ public class MppDataExchangeServiceThriftHandlerMetrics implements IMetricSet {
             MetricType.AUTO_GAUGE,
             Metric.THRIFT_CONNECTIONS.toString(),
             Tag.NAME.toString(),
-            "MPPDataExchange");
+            "MPPDataExchangeRPC");
   }
 
   @Override
diff --git a/server/src/main/java/org/apache/iotdb/db/query/control/SessionManager.java b/server/src/main/java/org/apache/iotdb/db/query/control/SessionManager.java
index 4fd13c04d5..e2bd2a0c5c 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/control/SessionManager.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/control/SessionManager.java
@@ -16,11 +16,15 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.iotdb.db.query.control;
 
 import org.apache.iotdb.common.rpc.thrift.TSStatus;
 import org.apache.iotdb.commons.conf.IoTDBConstant;
 import org.apache.iotdb.commons.service.JMXService;
+import org.apache.iotdb.commons.service.metric.MetricService;
+import org.apache.iotdb.commons.service.metric.enums.Metric;
+import org.apache.iotdb.commons.service.metric.enums.Tag;
 import org.apache.iotdb.db.audit.AuditLogger;
 import org.apache.iotdb.db.auth.AuthorizerManager;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
@@ -30,6 +34,7 @@ import org.apache.iotdb.db.mpp.plan.statement.StatementType;
 import org.apache.iotdb.db.mpp.plan.statement.sys.AuthorStatement;
 import org.apache.iotdb.db.query.control.clientsession.IClientSession;
 import org.apache.iotdb.db.service.basic.BasicOpenSessionResp;
+import org.apache.iotdb.metrics.utils.MetricLevel;
 import org.apache.iotdb.rpc.RpcUtils;
 import org.apache.iotdb.rpc.TSStatusCode;
 import org.apache.iotdb.service.rpc.thrift.TSConnectionInfo;
@@ -54,12 +59,12 @@ import static org.apache.iotdb.db.utils.ErrorHandlingUtils.onNPEOrUnexpectedExce
 
 public class SessionManager implements SessionManagerMBean {
   private static final Logger LOGGER = LoggerFactory.getLogger(SessionManager.class);
-  public static final Logger AUDIT_LOGGER =
-      LoggerFactory.getLogger(IoTDBConstant.AUDIT_LOGGER_NAME);
   // When the client abnormally exits, we can still know who to disconnect
   /** currSession can be only used in client-thread model services. */
   private final ThreadLocal<IClientSession> currSession = new ThreadLocal<>();
 
+  private final ThreadLocal<Long> currSessionIdleTime = new ThreadLocal<>();
+
   // sessions does not contain MqttSessions..
   private final Map<IClientSession, Object> sessions = new ConcurrentHashMap<>();
   // used for sessions.
@@ -253,15 +258,34 @@ public class SessionManager implements SessionManagerMBean {
     return QueryResourceManager.getInstance().assignQueryId();
   }
 
-  /**
-   * this method can be only used in client-thread model.
-   *
-   * @return
-   */
+  /** this method can be only used in client-thread model. */
   public IClientSession getCurrSession() {
     return currSession.get();
   }
 
+  /** get current session and update session idle time. */
+  public IClientSession getCurrSessionAndUpdateIdleTime() {
+    IClientSession clientSession = getCurrSession();
+    Long idleTime = currSessionIdleTime.get();
+    if (idleTime == null) {
+      currSessionIdleTime.set(System.nanoTime());
+    } else {
+      MetricService.getInstance()
+          .getOrCreateHistogram(
+              Metric.SESSION_IDLE_TIME.toString(),
+              MetricLevel.CORE,
+              Tag.NAME.toString(),
+              String.valueOf(clientSession.getId()))
+          .update(System.nanoTime() - idleTime);
+    }
+    return clientSession;
+  }
+
+  /** update connection idle time after execution. */
+  public void updateIdleTime() {
+    currSessionIdleTime.set(System.nanoTime());
+  }
+
   public TimeZone getSessionTimeZone() {
     IClientSession session = currSession.get();
     if (session != null) {
@@ -277,20 +301,18 @@ public class SessionManager implements SessionManagerMBean {
    * service, calling this method has no side effect. <br>
    * MUST CALL THIS METHOD IN client-thread model services. Fortunately, we can just call this
    * method in thrift's event handler.
-   *
-   * @return
    */
   public void removeCurrSession() {
     IClientSession session = currSession.get();
     sessions.remove(session);
     currSession.remove();
+    currSessionIdleTime.remove();
   }
 
   /**
    * this method can be only used in client-thread model. Do not use this method in message-thread
    * model based service.
    *
-   * @param session
    * @return false if the session has been initialized.
    */
   public boolean registerSession(IClientSession session) {
@@ -299,17 +321,12 @@ public class SessionManager implements SessionManagerMBean {
       return false;
     }
     this.currSession.set(session);
+    this.currSessionIdleTime.set(System.nanoTime());
     sessions.put(session, placeHolder);
     return true;
   }
 
-  /**
-   * must be called after registerSession()) will mark the session login.
-   *
-   * @param username
-   * @param zoneId
-   * @param clientVersion
-   */
+  /** must be called after registerSession()) will mark the session login. */
   public void supplySession(
       IClientSession session,
       String username,
@@ -356,6 +373,8 @@ public class SessionManager implements SessionManagerMBean {
 
     private static final SessionManager INSTANCE = new SessionManager();
 
-    private SessionManagerHelper() {}
+    private SessionManagerHelper() {
+      // empty constructor
+    }
   }
 }
diff --git a/server/src/main/java/org/apache/iotdb/db/service/DataNodeInternalRPCServiceMetrics.java b/server/src/main/java/org/apache/iotdb/db/service/DataNodeInternalRPCServiceMetrics.java
index fe3e5e5c3f..782e6e59a0 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/DataNodeInternalRPCServiceMetrics.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/DataNodeInternalRPCServiceMetrics.java
@@ -41,7 +41,7 @@ public class DataNodeInternalRPCServiceMetrics implements IMetricSet {
   public void bindTo(AbstractMetricService metricService) {
     metricService.createAutoGauge(
         Metric.THRIFT_ACTIVE_THREADS.toString(),
-        MetricLevel.IMPORTANT,
+        MetricLevel.CORE,
         thriftServiceThread,
         AbstractThriftServiceThread::getActiveThreadCount,
         Tag.NAME.toString(),
diff --git a/server/src/main/java/org/apache/iotdb/db/service/RPCServiceMetrics.java b/server/src/main/java/org/apache/iotdb/db/service/RPCServiceMetrics.java
index db56726c41..20bef9d2dc 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/RPCServiceMetrics.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/RPCServiceMetrics.java
@@ -40,7 +40,7 @@ public class RPCServiceMetrics implements IMetricSet {
   public void bindTo(AbstractMetricService metricService) {
     metricService.createAutoGauge(
         Metric.THRIFT_ACTIVE_THREADS.toString(),
-        MetricLevel.IMPORTANT,
+        MetricLevel.CORE,
         thriftServiceThread,
         AbstractThriftServiceThread::getActiveThreadCount,
         Tag.NAME.toString(),
diff --git a/server/src/main/java/org/apache/iotdb/db/service/thrift/handler/BaseServerContextHandler.java b/server/src/main/java/org/apache/iotdb/db/service/thrift/handler/BaseServerContextHandler.java
index 7366d2b47d..f189239b13 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/thrift/handler/BaseServerContextHandler.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/thrift/handler/BaseServerContextHandler.java
@@ -50,7 +50,9 @@ public class BaseServerContextHandler {
     }
   }
 
-  public BaseServerContextHandler() {}
+  public BaseServerContextHandler() {
+    // empty constructor
+  }
 
   public ServerContext createContext(TProtocol in, TProtocol out) {
     Socket socket =
diff --git a/server/src/main/java/org/apache/iotdb/db/service/thrift/handler/InternalServiceThriftHandlerMetrics.java b/server/src/main/java/org/apache/iotdb/db/service/thrift/handler/InternalServiceThriftHandlerMetrics.java
index 97b2b7bce5..d545d6b1f8 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/thrift/handler/InternalServiceThriftHandlerMetrics.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/thrift/handler/InternalServiceThriftHandlerMetrics.java
@@ -40,11 +40,11 @@ public class InternalServiceThriftHandlerMetrics implements IMetricSet {
   public void bindTo(AbstractMetricService metricService) {
     metricService.createAutoGauge(
         Metric.THRIFT_CONNECTIONS.toString(),
-        MetricLevel.IMPORTANT,
+        MetricLevel.CORE,
         thriftConnectionNumber,
         AtomicLong::get,
         Tag.NAME.toString(),
-        "Internal");
+        "InternalRPC");
   }
 
   @Override
@@ -53,7 +53,7 @@ public class InternalServiceThriftHandlerMetrics implements IMetricSet {
         MetricType.AUTO_GAUGE,
         Metric.THRIFT_CONNECTIONS.toString(),
         Tag.NAME.toString(),
-        "Internal");
+        "InternalRPC");
   }
 
   @Override
diff --git a/server/src/main/java/org/apache/iotdb/db/service/thrift/handler/RPCServiceThriftHandlerMetrics.java b/server/src/main/java/org/apache/iotdb/db/service/thrift/handler/RPCServiceThriftHandlerMetrics.java
index 1aacc38f41..680198b558 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/thrift/handler/RPCServiceThriftHandlerMetrics.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/thrift/handler/RPCServiceThriftHandlerMetrics.java
@@ -37,17 +37,20 @@ public class RPCServiceThriftHandlerMetrics implements IMetricSet {
   public void bindTo(AbstractMetricService metricService) {
     metricService.createAutoGauge(
         Metric.THRIFT_CONNECTIONS.toString(),
-        MetricLevel.IMPORTANT,
+        MetricLevel.CORE,
         thriftConnectionNumber,
         AtomicLong::get,
         Tag.NAME.toString(),
-        "RPC");
+        "ClientRPC");
   }
 
   @Override
   public void unbindFrom(AbstractMetricService metricService) {
     metricService.remove(
-        MetricType.AUTO_GAUGE, Metric.THRIFT_CONNECTIONS.toString(), Tag.NAME.toString(), "RPC");
+        MetricType.AUTO_GAUGE,
+        Metric.THRIFT_CONNECTIONS.toString(),
+        Tag.NAME.toString(),
+        "ClientRPC");
   }
 
   @Override
diff --git a/server/src/main/java/org/apache/iotdb/db/service/thrift/impl/ClientRPCServiceImpl.java b/server/src/main/java/org/apache/iotdb/db/service/thrift/impl/ClientRPCServiceImpl.java
index b08c7c9e26..5423acac60 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/thrift/impl/ClientRPCServiceImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/thrift/impl/ClientRPCServiceImpl.java
@@ -150,9 +150,9 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
 
   private static final boolean enableAuditLog = config.isEnableAuditLog();
 
-  private final IPartitionFetcher PARTITION_FETCHER;
+  private final IPartitionFetcher partitionFetcher;
 
-  private final ISchemaFetcher SCHEMA_FETCHER;
+  private final ISchemaFetcher schemaFetcher;
 
   @FunctionalInterface
   public interface SelectResult {
@@ -177,8 +177,8 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
       };
 
   public ClientRPCServiceImpl() {
-    PARTITION_FETCHER = ClusterPartitionFetcher.getInstance();
-    SCHEMA_FETCHER = ClusterSchemaFetcher.getInstance();
+    partitionFetcher = ClusterPartitionFetcher.getInstance();
+    schemaFetcher = ClusterSchemaFetcher.getInstance();
   }
 
   private TSExecuteStatementResp executeStatementInternal(
@@ -186,16 +186,15 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
     boolean finished = false;
     long queryId = Long.MIN_VALUE;
     String statement = req.getStatement();
-    if (!SESSION_MANAGER.checkLogin(SESSION_MANAGER.getCurrSession())) {
+    IClientSession clientSession = SESSION_MANAGER.getCurrSessionAndUpdateIdleTime();
+    if (!SESSION_MANAGER.checkLogin(clientSession)) {
       return RpcUtils.getTSExecuteStatementResp(getNotLoggedInStatus());
     }
 
     long startTime = System.currentTimeMillis();
     StatementType statementType = null;
     try {
-      Statement s =
-          StatementGenerator.createStatement(
-              statement, SESSION_MANAGER.getCurrSession().getZoneId());
+      Statement s = StatementGenerator.createStatement(statement, clientSession.getZoneId());
 
       if (s == null) {
         return RpcUtils.getTSExecuteStatementResp(
@@ -203,7 +202,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
                 TSStatusCode.SQL_PARSE_ERROR, "This operation type is not supported"));
       }
       // permission check
-      TSStatus status = AuthorityChecker.checkAuthority(s, SESSION_MANAGER.getCurrSession());
+      TSStatus status = AuthorityChecker.checkAuthority(s, clientSession);
       if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
         return RpcUtils.getTSExecuteStatementResp(status);
       }
@@ -213,16 +212,16 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
         AuditLogger.log(statement, s);
       }
 
-      queryId = SESSION_MANAGER.requestQueryId(SESSION_MANAGER.getCurrSession(), req.statementId);
+      queryId = SESSION_MANAGER.requestQueryId(clientSession, req.statementId);
       // create and cache dataset
       ExecutionResult result =
           COORDINATOR.execute(
               s,
               queryId,
-              SESSION_MANAGER.getSessionInfo(SESSION_MANAGER.getCurrSession()),
+              SESSION_MANAGER.getSessionInfo(clientSession),
               statement,
-              PARTITION_FETCHER,
-              SCHEMA_FETCHER,
+              partitionFetcher,
+              schemaFetcher,
               req.getTimeout());
 
       if (result.status.code != TSStatusCode.SUCCESS_STATUS.getStatusCode()
@@ -261,6 +260,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
         }
         COORDINATOR.cleanupQueryExecution(queryId);
       }
+      SESSION_MANAGER.updateIdleTime();
     }
   }
 
@@ -268,16 +268,16 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
       TSRawDataQueryReq req, SelectResult setResult) {
     boolean finished = false;
     long queryId = Long.MIN_VALUE;
-    if (!SESSION_MANAGER.checkLogin(SESSION_MANAGER.getCurrSession())) {
+    IClientSession clientSession = SESSION_MANAGER.getCurrSessionAndUpdateIdleTime();
+    if (!SESSION_MANAGER.checkLogin(clientSession)) {
       return RpcUtils.getTSExecuteStatementResp(getNotLoggedInStatus());
     }
     long startTime = System.currentTimeMillis();
     try {
-      Statement s =
-          StatementGenerator.createStatement(req, SESSION_MANAGER.getCurrSession().getZoneId());
+      Statement s = StatementGenerator.createStatement(req, clientSession.getZoneId());
 
       // permission check
-      TSStatus status = AuthorityChecker.checkAuthority(s, SESSION_MANAGER.getCurrSession());
+      TSStatus status = AuthorityChecker.checkAuthority(s, clientSession);
       if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
         return RpcUtils.getTSExecuteStatementResp(status);
       }
@@ -285,16 +285,16 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
       if (enableAuditLog) {
         AuditLogger.log(String.format("execute Raw Data Query: %s", req), s);
       }
-      queryId = SESSION_MANAGER.requestQueryId(SESSION_MANAGER.getCurrSession(), req.statementId);
+      queryId = SESSION_MANAGER.requestQueryId(clientSession, req.statementId);
       // create and cache dataset
       ExecutionResult result =
           COORDINATOR.execute(
               s,
               queryId,
-              SESSION_MANAGER.getSessionInfo(SESSION_MANAGER.getCurrSession()),
+              SESSION_MANAGER.getSessionInfo(clientSession),
               "",
-              PARTITION_FETCHER,
-              SCHEMA_FETCHER,
+              partitionFetcher,
+              schemaFetcher,
               req.getTimeout());
 
       if (result.status.code != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
@@ -328,6 +328,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
             COORDINATOR.getTotalExecutionTime(queryId));
         COORDINATOR.cleanupQueryExecution(queryId);
       }
+      SESSION_MANAGER.updateIdleTime();
     }
   }
 
@@ -335,15 +336,15 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
       TSLastDataQueryReq req, SelectResult setResult) {
     boolean finished = false;
     long queryId = Long.MIN_VALUE;
-    if (!SESSION_MANAGER.checkLogin(SESSION_MANAGER.getCurrSession())) {
+    IClientSession clientSession = SESSION_MANAGER.getCurrSessionAndUpdateIdleTime();
+    if (!SESSION_MANAGER.checkLogin(clientSession)) {
       return RpcUtils.getTSExecuteStatementResp(getNotLoggedInStatus());
     }
     long startTime = System.currentTimeMillis();
     try {
-      Statement s =
-          StatementGenerator.createStatement(req, SESSION_MANAGER.getCurrSession().getZoneId());
+      Statement s = StatementGenerator.createStatement(req, clientSession.getZoneId());
       // permission check
-      TSStatus status = AuthorityChecker.checkAuthority(s, SESSION_MANAGER.getCurrSession());
+      TSStatus status = AuthorityChecker.checkAuthority(s, clientSession);
       if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
         return RpcUtils.getTSExecuteStatementResp(status);
       }
@@ -351,16 +352,16 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
       if (enableAuditLog) {
         AuditLogger.log(String.format("Last Data Query: %s", req), s);
       }
-      queryId = SESSION_MANAGER.requestQueryId(SESSION_MANAGER.getCurrSession(), req.statementId);
+      queryId = SESSION_MANAGER.requestQueryId(clientSession, req.statementId);
       // create and cache dataset
       ExecutionResult result =
           COORDINATOR.execute(
               s,
               queryId,
-              SESSION_MANAGER.getSessionInfo(SESSION_MANAGER.getCurrSession()),
+              SESSION_MANAGER.getSessionInfo(clientSession),
               "",
-              PARTITION_FETCHER,
-              SCHEMA_FETCHER,
+              partitionFetcher,
+              schemaFetcher,
               req.getTimeout());
 
       if (result.status.code != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
@@ -395,6 +396,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
             COORDINATOR.getTotalExecutionTime(queryId));
         COORDINATOR.cleanupQueryExecution(queryId);
       }
+      SESSION_MANAGER.updateIdleTime();
     }
   }
 
@@ -402,29 +404,29 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
       TSAggregationQueryReq req, SelectResult setResult) {
     boolean finished = false;
     long queryId = Long.MIN_VALUE;
-    if (!SESSION_MANAGER.checkLogin(SESSION_MANAGER.getCurrSession())) {
+    IClientSession clientSession = SESSION_MANAGER.getCurrSessionAndUpdateIdleTime();
+    if (!SESSION_MANAGER.checkLogin(clientSession)) {
       return RpcUtils.getTSExecuteStatementResp(getNotLoggedInStatus());
     }
     long startTime = System.currentTimeMillis();
     try {
-      Statement s =
-          StatementGenerator.createStatement(req, SESSION_MANAGER.getCurrSession().getZoneId());
+      Statement s = StatementGenerator.createStatement(req, clientSession.getZoneId());
       // permission check
-      TSStatus status = AuthorityChecker.checkAuthority(s, SESSION_MANAGER.getCurrSession());
+      TSStatus status = AuthorityChecker.checkAuthority(s, clientSession);
       if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
         return RpcUtils.getTSExecuteStatementResp(status);
       }
 
-      queryId = SESSION_MANAGER.requestQueryId(SESSION_MANAGER.getCurrSession(), req.statementId);
+      queryId = SESSION_MANAGER.requestQueryId(clientSession, req.statementId);
       // create and cache dataset
       ExecutionResult result =
           COORDINATOR.execute(
               s,
               queryId,
-              SESSION_MANAGER.getSessionInfo(SESSION_MANAGER.getCurrSession()),
+              SESSION_MANAGER.getSessionInfo(clientSession),
               "",
-              PARTITION_FETCHER,
-              SCHEMA_FETCHER,
+              partitionFetcher,
+              schemaFetcher,
               req.getTimeout());
 
       if (result.status.code != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
@@ -459,6 +461,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
             COORDINATOR.getTotalExecutionTime(queryId));
         COORDINATOR.cleanupQueryExecution(queryId);
       }
+      SESSION_MANAGER.updateIdleTime();
     }
   }
 
@@ -498,7 +501,8 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
     boolean finished = false;
     StatementType statementType = null;
     try {
-      if (!SESSION_MANAGER.checkLogin(SESSION_MANAGER.getCurrSession())) {
+      IClientSession clientSession = SESSION_MANAGER.getCurrSessionAndUpdateIdleTime();
+      if (!SESSION_MANAGER.checkLogin(clientSession)) {
         return RpcUtils.getTSFetchResultsResp(getNotLoggedInStatus());
       }
       TSFetchResultsResp resp = RpcUtils.getTSFetchResultsResp(TSStatusCode.SUCCESS_STATUS);
@@ -538,6 +542,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
         }
         COORDINATOR.cleanupQueryExecution(req.queryId);
       }
+      SESSION_MANAGER.updateIdleTime();
     }
   }
 
@@ -647,7 +652,8 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
   @Override
   public TSStatus setStorageGroup(long sessionId, String storageGroup) {
     try {
-      if (!SESSION_MANAGER.checkLogin(SESSION_MANAGER.getCurrSession())) {
+      IClientSession clientSession = SESSION_MANAGER.getCurrSessionAndUpdateIdleTime();
+      if (!SESSION_MANAGER.checkLogin(clientSession)) {
         return getNotLoggedInStatus();
       }
 
@@ -658,8 +664,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
         AuditLogger.log(String.format("create database %s", storageGroup), statement);
       }
       // permission check
-      TSStatus status =
-          AuthorityChecker.checkAuthority(statement, SESSION_MANAGER.getCurrSession());
+      TSStatus status = AuthorityChecker.checkAuthority(statement, clientSession);
       if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
         return status;
       }
@@ -670,10 +675,10 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
           COORDINATOR.execute(
               statement,
               queryId,
-              SESSION_MANAGER.getSessionInfo(SESSION_MANAGER.getCurrSession()),
+              SESSION_MANAGER.getSessionInfo(clientSession),
               "",
-              PARTITION_FETCHER,
-              SCHEMA_FETCHER);
+              partitionFetcher,
+              schemaFetcher);
 
       return result.status;
     } catch (IoTDBException e) {
@@ -687,7 +692,8 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
   @Override
   public TSStatus createTimeseries(TSCreateTimeseriesReq req) {
     try {
-      if (!SESSION_MANAGER.checkLogin(SESSION_MANAGER.getCurrSession())) {
+      IClientSession clientSession = SESSION_MANAGER.getCurrSessionAndUpdateIdleTime();
+      if (!SESSION_MANAGER.checkLogin(clientSession)) {
         return getNotLoggedInStatus();
       }
 
@@ -699,8 +705,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
         AuditLogger.log(String.format("create timeseries %s", req.getPath()), statement);
       }
       // permission check
-      TSStatus status =
-          AuthorityChecker.checkAuthority(statement, SESSION_MANAGER.getCurrSession());
+      TSStatus status = AuthorityChecker.checkAuthority(statement, clientSession);
       if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
         return status;
       }
@@ -711,10 +716,10 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
           COORDINATOR.execute(
               statement,
               queryId,
-              SESSION_MANAGER.getSessionInfo(SESSION_MANAGER.getCurrSession()),
+              SESSION_MANAGER.getSessionInfo(clientSession),
               "",
-              PARTITION_FETCHER,
-              SCHEMA_FETCHER);
+              partitionFetcher,
+              schemaFetcher);
 
       return result.status;
     } catch (IoTDBException e) {
@@ -722,13 +727,16 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
     } catch (Exception e) {
       return onNPEOrUnexpectedException(
           e, OperationType.CREATE_TIMESERIES, TSStatusCode.EXECUTE_STATEMENT_ERROR);
+    } finally {
+      SESSION_MANAGER.updateIdleTime();
     }
   }
 
   @Override
   public TSStatus createAlignedTimeseries(TSCreateAlignedTimeseriesReq req) {
     try {
-      if (!SESSION_MANAGER.checkLogin(SESSION_MANAGER.getCurrSession())) {
+      IClientSession clientSession = SESSION_MANAGER.getCurrSessionAndUpdateIdleTime();
+      if (!SESSION_MANAGER.checkLogin(clientSession)) {
         return getNotLoggedInStatus();
       }
 
@@ -747,8 +755,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
             statement);
       }
       // permission check
-      TSStatus status =
-          AuthorityChecker.checkAuthority(statement, SESSION_MANAGER.getCurrSession());
+      TSStatus status = AuthorityChecker.checkAuthority(statement, clientSession);
       if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
         return status;
       }
@@ -759,10 +766,10 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
           COORDINATOR.execute(
               statement,
               queryId,
-              SESSION_MANAGER.getSessionInfo(SESSION_MANAGER.getCurrSession()),
+              SESSION_MANAGER.getSessionInfo(clientSession),
               "",
-              PARTITION_FETCHER,
-              SCHEMA_FETCHER);
+              partitionFetcher,
+              schemaFetcher);
 
       return result.status;
     } catch (IoTDBException e) {
@@ -770,13 +777,16 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
     } catch (Exception e) {
       return onNPEOrUnexpectedException(
           e, OperationType.CREATE_ALIGNED_TIMESERIES, TSStatusCode.EXECUTE_STATEMENT_ERROR);
+    } finally {
+      SESSION_MANAGER.updateIdleTime();
     }
   }
 
   @Override
   public TSStatus createMultiTimeseries(TSCreateMultiTimeseriesReq req) {
     try {
-      if (!SESSION_MANAGER.checkLogin(SESSION_MANAGER.getCurrSession())) {
+      IClientSession clientSession = SESSION_MANAGER.getCurrSessionAndUpdateIdleTime();
+      if (!SESSION_MANAGER.checkLogin(clientSession)) {
         return getNotLoggedInStatus();
       }
 
@@ -794,8 +804,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
             statement);
       }
       // permission check
-      TSStatus status =
-          AuthorityChecker.checkAuthority(statement, SESSION_MANAGER.getCurrSession());
+      TSStatus status = AuthorityChecker.checkAuthority(statement, clientSession);
       if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
         return status;
       }
@@ -806,10 +815,10 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
           COORDINATOR.execute(
               statement,
               queryId,
-              SESSION_MANAGER.getSessionInfo(SESSION_MANAGER.getCurrSession()),
+              SESSION_MANAGER.getSessionInfo(clientSession),
               "",
-              PARTITION_FETCHER,
-              SCHEMA_FETCHER);
+              partitionFetcher,
+              schemaFetcher);
 
       return result.status;
     } catch (IoTDBException e) {
@@ -817,13 +826,16 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
     } catch (Exception e) {
       return onNPEOrUnexpectedException(
           e, OperationType.CREATE_MULTI_TIMESERIES, TSStatusCode.EXECUTE_STATEMENT_ERROR);
+    } finally {
+      SESSION_MANAGER.updateIdleTime();
     }
   }
 
   @Override
   public TSStatus deleteTimeseries(long sessionId, List<String> path) {
     try {
-      if (!SESSION_MANAGER.checkLogin(SESSION_MANAGER.getCurrSession())) {
+      IClientSession clientSession = SESSION_MANAGER.getCurrSessionAndUpdateIdleTime();
+      if (!SESSION_MANAGER.checkLogin(clientSession)) {
         return getNotLoggedInStatus();
       }
 
@@ -832,8 +844,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
           StatementGenerator.createDeleteTimeSeriesStatement(path);
 
       // permission check
-      TSStatus status =
-          AuthorityChecker.checkAuthority(statement, SESSION_MANAGER.getCurrSession());
+      TSStatus status = AuthorityChecker.checkAuthority(statement, clientSession);
       if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
         return status;
       }
@@ -844,10 +855,10 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
           COORDINATOR.execute(
               statement,
               queryId,
-              SESSION_MANAGER.getSessionInfo(SESSION_MANAGER.getCurrSession()),
+              SESSION_MANAGER.getSessionInfo(clientSession),
               "",
-              PARTITION_FETCHER,
-              SCHEMA_FETCHER);
+              partitionFetcher,
+              schemaFetcher);
 
       return result.status;
     } catch (IoTDBException e) {
@@ -855,13 +866,16 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
     } catch (Exception e) {
       return onNPEOrUnexpectedException(
           e, OperationType.DELETE_TIMESERIES, TSStatusCode.EXECUTE_STATEMENT_ERROR);
+    } finally {
+      SESSION_MANAGER.updateIdleTime();
     }
   }
 
   @Override
   public TSStatus deleteStorageGroups(long sessionId, List<String> storageGroups) {
     try {
-      if (!SESSION_MANAGER.checkLogin(SESSION_MANAGER.getCurrSession())) {
+      IClientSession clientSession = SESSION_MANAGER.getCurrSessionAndUpdateIdleTime();
+      if (!SESSION_MANAGER.checkLogin(clientSession)) {
         return getNotLoggedInStatus();
       }
 
@@ -873,8 +887,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
       }
 
       // permission check
-      TSStatus status =
-          AuthorityChecker.checkAuthority(statement, SESSION_MANAGER.getCurrSession());
+      TSStatus status = AuthorityChecker.checkAuthority(statement, clientSession);
       if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
         return status;
       }
@@ -885,10 +898,10 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
           COORDINATOR.execute(
               statement,
               queryId,
-              SESSION_MANAGER.getSessionInfo(SESSION_MANAGER.getCurrSession()),
+              SESSION_MANAGER.getSessionInfo(clientSession),
               "",
-              PARTITION_FETCHER,
-              SCHEMA_FETCHER);
+              partitionFetcher,
+              schemaFetcher);
 
       return result.status;
     } catch (IoTDBException e) {
@@ -896,6 +909,8 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
     } catch (Exception e) {
       return onNPEOrUnexpectedException(
           e, OperationType.DELETE_STORAGE_GROUPS, TSStatusCode.EXECUTE_STATEMENT_ERROR);
+    } finally {
+      SESSION_MANAGER.updateIdleTime();
     }
   }
 
@@ -915,60 +930,66 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
     long t1 = System.currentTimeMillis();
     List<TSStatus> results = new ArrayList<>();
     boolean isAllSuccessful = true;
-    if (!SESSION_MANAGER.checkLogin(SESSION_MANAGER.getCurrSession())) {
+    IClientSession clientSession = SESSION_MANAGER.getCurrSessionAndUpdateIdleTime();
+    if (!SESSION_MANAGER.checkLogin(clientSession)) {
       return getNotLoggedInStatus();
     }
 
-    for (int i = 0; i < req.getStatements().size(); i++) {
-      String statement = req.getStatements().get(i);
-      long t2 = System.currentTimeMillis();
-      StatementType type = null;
-      try {
-        Statement s =
-            StatementGenerator.createStatement(
-                statement, SESSION_MANAGER.getCurrSession().getZoneId());
-        if (s == null) {
-          return RpcUtils.getStatus(
-              TSStatusCode.EXECUTE_STATEMENT_ERROR, "This operation type is not supported");
-        }
-        // permission check
-        TSStatus status = AuthorityChecker.checkAuthority(s, SESSION_MANAGER.getCurrSession());
-        if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
-          return status;
-        }
+    try {
+      for (int i = 0; i < req.getStatements().size(); i++) {
+        String statement = req.getStatements().get(i);
+        long t2 = System.currentTimeMillis();
+        StatementType type = null;
+        try {
+          Statement s = StatementGenerator.createStatement(statement, clientSession.getZoneId());
+          if (s == null) {
+            return RpcUtils.getStatus(
+                TSStatusCode.EXECUTE_STATEMENT_ERROR, "This operation type is not supported");
+          }
+          // permission check
+          TSStatus status = AuthorityChecker.checkAuthority(s, clientSession);
+          if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
+            return status;
+          }
 
-        if (enableAuditLog) {
-          AuditLogger.log(statement, s);
-        }
+          if (enableAuditLog) {
+            AuditLogger.log(statement, s);
+          }
 
-        long queryId = SESSION_MANAGER.requestQueryId();
-        type = s.getType();
-        // create and cache dataset
-        ExecutionResult result =
-            COORDINATOR.execute(
-                s,
-                queryId,
-                SESSION_MANAGER.getSessionInfo(SESSION_MANAGER.getCurrSession()),
-                statement,
-                PARTITION_FETCHER,
-                SCHEMA_FETCHER,
-                config.getQueryTimeoutThreshold());
-        results.add(result.status);
-      } catch (Exception e) {
-        LOGGER.warn("Error occurred when executing executeBatchStatement: ", e);
-        TSStatus status =
-            onQueryException(e, "\"" + statement + "\". " + OperationType.EXECUTE_BATCH_STATEMENT);
-        if (status.getCode() != TSStatusCode.INTERNAL_SERVER_ERROR.getStatusCode()) {
-          isAllSuccessful = false;
+          long queryId = SESSION_MANAGER.requestQueryId();
+          type = s.getType();
+          // create and cache dataset
+          ExecutionResult result =
+              COORDINATOR.execute(
+                  s,
+                  queryId,
+                  SESSION_MANAGER.getSessionInfo(clientSession),
+                  statement,
+                  partitionFetcher,
+                  schemaFetcher,
+                  config.getQueryTimeoutThreshold());
+          results.add(result.status);
+        } catch (Exception e) {
+          LOGGER.warn("Error occurred when executing executeBatchStatement: ", e);
+          TSStatus status =
+              onQueryException(
+                  e, "\"" + statement + "\". " + OperationType.EXECUTE_BATCH_STATEMENT);
+          if (status.getCode() != TSStatusCode.INTERNAL_SERVER_ERROR.getStatusCode()) {
+            isAllSuccessful = false;
+          }
+          results.add(status);
+        } finally {
+          addStatementExecutionLatency(
+              OperationType.EXECUTE_STATEMENT, type, System.currentTimeMillis() - t2);
         }
-        results.add(status);
-      } finally {
-        addStatementExecutionLatency(
-            OperationType.EXECUTE_STATEMENT, type, System.currentTimeMillis() - t2);
       }
+    } finally {
+      addStatementExecutionLatency(
+          OperationType.EXECUTE_BATCH_STATEMENT,
+          StatementType.NULL,
+          System.currentTimeMillis() - t1);
+      SESSION_MANAGER.updateIdleTime();
     }
-    addStatementExecutionLatency(
-        OperationType.EXECUTE_BATCH_STATEMENT, StatementType.NULL, System.currentTimeMillis() - t1);
     return isAllSuccessful
         ? RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS, "Execute batch statements successfully")
         : RpcUtils.getStatus(results);
@@ -990,7 +1011,8 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
     long startTime = System.currentTimeMillis();
     StatementType statementType = null;
     try {
-      if (!SESSION_MANAGER.checkLogin(SESSION_MANAGER.getCurrSession())) {
+      IClientSession clientSession = SESSION_MANAGER.getCurrSessionAndUpdateIdleTime();
+      if (!SESSION_MANAGER.checkLogin(clientSession)) {
         return RpcUtils.getTSFetchResultsResp(getNotLoggedInStatus());
       }
 
@@ -1030,6 +1052,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
         }
         COORDINATOR.cleanupQueryExecution(req.queryId);
       }
+      SESSION_MANAGER.updateIdleTime();
     }
   }
 
@@ -1037,7 +1060,8 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
   public TSStatus insertRecords(TSInsertRecordsReq req) {
     long t1 = System.currentTimeMillis();
     try {
-      if (!SESSION_MANAGER.checkLogin(SESSION_MANAGER.getCurrSession())) {
+      IClientSession clientSession = SESSION_MANAGER.getCurrSessionAndUpdateIdleTime();
+      if (!SESSION_MANAGER.checkLogin(clientSession)) {
         return getNotLoggedInStatus();
       }
 
@@ -1062,8 +1086,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
       }
 
       // permission check
-      TSStatus status =
-          AuthorityChecker.checkAuthority(statement, SESSION_MANAGER.getCurrSession());
+      TSStatus status = AuthorityChecker.checkAuthority(statement, clientSession);
       if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
         return status;
       }
@@ -1074,10 +1097,10 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
           COORDINATOR.execute(
               statement,
               queryId,
-              SESSION_MANAGER.getSessionInfo(SESSION_MANAGER.getCurrSession()),
+              SESSION_MANAGER.getSessionInfo(clientSession),
               "",
-              PARTITION_FETCHER,
-              SCHEMA_FETCHER);
+              partitionFetcher,
+              schemaFetcher);
 
       return result.status;
     } catch (IoTDBException e) {
@@ -1090,6 +1113,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
           OperationType.INSERT_RECORDS,
           StatementType.BATCH_INSERT_ROWS,
           System.currentTimeMillis() - t1);
+      SESSION_MANAGER.updateIdleTime();
     }
   }
 
@@ -1097,7 +1121,8 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
   public TSStatus insertRecordsOfOneDevice(TSInsertRecordsOfOneDeviceReq req) {
     long t1 = System.currentTimeMillis();
     try {
-      if (!SESSION_MANAGER.checkLogin(SESSION_MANAGER.getCurrSession())) {
+      IClientSession clientSession = SESSION_MANAGER.getCurrSessionAndUpdateIdleTime();
+      if (!SESSION_MANAGER.checkLogin(clientSession)) {
         return getNotLoggedInStatus();
       }
 
@@ -1122,8 +1147,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
       }
 
       // permission check
-      TSStatus status =
-          AuthorityChecker.checkAuthority(statement, SESSION_MANAGER.getCurrSession());
+      TSStatus status = AuthorityChecker.checkAuthority(statement, clientSession);
       if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
         return status;
       }
@@ -1134,10 +1158,10 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
           COORDINATOR.execute(
               statement,
               queryId,
-              SESSION_MANAGER.getSessionInfo(SESSION_MANAGER.getCurrSession()),
+              SESSION_MANAGER.getSessionInfo(clientSession),
               "",
-              PARTITION_FETCHER,
-              SCHEMA_FETCHER);
+              partitionFetcher,
+              schemaFetcher);
 
       return result.status;
     } catch (IoTDBException e) {
@@ -1150,6 +1174,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
           OperationType.INSERT_RECORDS_OF_ONE_DEVICE,
           StatementType.BATCH_INSERT_ONE_DEVICE,
           System.currentTimeMillis() - t1);
+      SESSION_MANAGER.updateIdleTime();
     }
   }
 
@@ -1157,7 +1182,8 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
   public TSStatus insertStringRecordsOfOneDevice(TSInsertStringRecordsOfOneDeviceReq req) {
     long t1 = System.currentTimeMillis();
     try {
-      if (!SESSION_MANAGER.checkLogin(SESSION_MANAGER.getCurrSession())) {
+      IClientSession clientSession = SESSION_MANAGER.getCurrSessionAndUpdateIdleTime();
+      if (!SESSION_MANAGER.checkLogin(clientSession)) {
         return getNotLoggedInStatus();
       }
 
@@ -1181,8 +1207,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
             true);
       }
       // permission check
-      TSStatus status =
-          AuthorityChecker.checkAuthority(statement, SESSION_MANAGER.getCurrSession());
+      TSStatus status = AuthorityChecker.checkAuthority(statement, clientSession);
       if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
         return status;
       }
@@ -1193,10 +1218,10 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
           COORDINATOR.execute(
               statement,
               queryId,
-              SESSION_MANAGER.getSessionInfo(SESSION_MANAGER.getCurrSession()),
+              SESSION_MANAGER.getSessionInfo(clientSession),
               "",
-              PARTITION_FETCHER,
-              SCHEMA_FETCHER);
+              partitionFetcher,
+              schemaFetcher);
 
       return result.status;
     } catch (IoTDBException e) {
@@ -1212,6 +1237,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
           OperationType.INSERT_STRING_RECORDS_OF_ONE_DEVICE,
           StatementType.BATCH_INSERT_ONE_DEVICE,
           System.currentTimeMillis() - t1);
+      SESSION_MANAGER.updateIdleTime();
     }
   }
 
@@ -1219,7 +1245,8 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
   public TSStatus insertRecord(TSInsertRecordReq req) {
     long t1 = System.currentTimeMillis();
     try {
-      if (!SESSION_MANAGER.checkLogin(SESSION_MANAGER.getCurrSession())) {
+      IClientSession clientSession = SESSION_MANAGER.getCurrSessionAndUpdateIdleTime();
+      if (!SESSION_MANAGER.checkLogin(clientSession)) {
         return getNotLoggedInStatus();
       }
 
@@ -1241,8 +1268,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
       }
 
       // permission check
-      TSStatus status =
-          AuthorityChecker.checkAuthority(statement, SESSION_MANAGER.getCurrSession());
+      TSStatus status = AuthorityChecker.checkAuthority(statement, clientSession);
       if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
         return status;
       }
@@ -1253,10 +1279,10 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
           COORDINATOR.execute(
               statement,
               queryId,
-              SESSION_MANAGER.getSessionInfo(SESSION_MANAGER.getCurrSession()),
+              SESSION_MANAGER.getSessionInfo(clientSession),
               "",
-              PARTITION_FETCHER,
-              SCHEMA_FETCHER);
+              partitionFetcher,
+              schemaFetcher);
 
       return result.status;
     } catch (IoTDBException e) {
@@ -1267,6 +1293,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
     } finally {
       addStatementExecutionLatency(
           OperationType.INSERT_RECORD, StatementType.INSERT, System.currentTimeMillis() - t1);
+      SESSION_MANAGER.updateIdleTime();
     }
   }
 
@@ -1274,7 +1301,8 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
   public TSStatus insertTablets(TSInsertTabletsReq req) {
     long t1 = System.currentTimeMillis();
     try {
-      if (!SESSION_MANAGER.checkLogin(SESSION_MANAGER.getCurrSession())) {
+      IClientSession clientSession = SESSION_MANAGER.getCurrSessionAndUpdateIdleTime();
+      if (!SESSION_MANAGER.checkLogin(clientSession)) {
         return getNotLoggedInStatus();
       }
 
@@ -1289,8 +1317,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
       }
 
       // permission check
-      TSStatus status =
-          AuthorityChecker.checkAuthority(statement, SESSION_MANAGER.getCurrSession());
+      TSStatus status = AuthorityChecker.checkAuthority(statement, clientSession);
       if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
         return status;
       }
@@ -1301,10 +1328,10 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
           COORDINATOR.execute(
               statement,
               queryId,
-              SESSION_MANAGER.getSessionInfo(SESSION_MANAGER.getCurrSession()),
+              SESSION_MANAGER.getSessionInfo(clientSession),
               "",
-              PARTITION_FETCHER,
-              SCHEMA_FETCHER);
+              partitionFetcher,
+              schemaFetcher);
 
       return result.status;
     } catch (IoTDBException e) {
@@ -1317,6 +1344,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
           OperationType.INSERT_TABLETS,
           StatementType.MULTI_BATCH_INSERT,
           System.currentTimeMillis() - t1);
+      SESSION_MANAGER.updateIdleTime();
     }
   }
 
@@ -1324,7 +1352,8 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
   public TSStatus insertTablet(TSInsertTabletReq req) {
     long t1 = System.currentTimeMillis();
     try {
-      if (!SESSION_MANAGER.checkLogin(SESSION_MANAGER.getCurrSession())) {
+      IClientSession clientSession = SESSION_MANAGER.getCurrSessionAndUpdateIdleTime();
+      if (!SESSION_MANAGER.checkLogin(clientSession)) {
         return getNotLoggedInStatus();
       }
 
@@ -1338,8 +1367,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
       }
 
       // permission check
-      TSStatus status =
-          AuthorityChecker.checkAuthority(statement, SESSION_MANAGER.getCurrSession());
+      TSStatus status = AuthorityChecker.checkAuthority(statement, clientSession);
       if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
         return status;
       }
@@ -1350,10 +1378,10 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
           COORDINATOR.execute(
               statement,
               queryId,
-              SESSION_MANAGER.getSessionInfo(SESSION_MANAGER.getCurrSession()),
+              SESSION_MANAGER.getSessionInfo(clientSession),
               "",
-              PARTITION_FETCHER,
-              SCHEMA_FETCHER);
+              partitionFetcher,
+              schemaFetcher);
 
       return result.status;
     } catch (IoTDBException e) {
@@ -1364,6 +1392,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
     } finally {
       addStatementExecutionLatency(
           OperationType.INSERT_TABLET, StatementType.BATCH_INSERT, System.currentTimeMillis() - t1);
+      SESSION_MANAGER.updateIdleTime();
     }
   }
 
@@ -1371,7 +1400,8 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
   public TSStatus insertStringRecords(TSInsertStringRecordsReq req) {
     long t1 = System.currentTimeMillis();
     try {
-      if (!SESSION_MANAGER.checkLogin(SESSION_MANAGER.getCurrSession())) {
+      IClientSession clientSession = SESSION_MANAGER.getCurrSessionAndUpdateIdleTime();
+      if (!SESSION_MANAGER.checkLogin(clientSession)) {
         return getNotLoggedInStatus();
       }
 
@@ -1395,8 +1425,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
       }
 
       // permission check
-      TSStatus status =
-          AuthorityChecker.checkAuthority(statement, SESSION_MANAGER.getCurrSession());
+      TSStatus status = AuthorityChecker.checkAuthority(statement, clientSession);
       if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
         return status;
       }
@@ -1406,10 +1435,10 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
           COORDINATOR.execute(
               statement,
               queryId,
-              SESSION_MANAGER.getSessionInfo(SESSION_MANAGER.getCurrSession()),
+              SESSION_MANAGER.getSessionInfo(clientSession),
               "",
-              PARTITION_FETCHER,
-              SCHEMA_FETCHER);
+              partitionFetcher,
+              schemaFetcher);
 
       return result.status;
     } catch (IoTDBException e) {
@@ -1422,6 +1451,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
           OperationType.INSERT_STRING_RECORDS,
           StatementType.BATCH_INSERT_ROWS,
           System.currentTimeMillis() - t1);
+      SESSION_MANAGER.updateIdleTime();
     }
   }
 
@@ -1470,15 +1500,15 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
   @Override
   public TSStatus deleteData(TSDeleteDataReq req) {
     try {
-      if (!SESSION_MANAGER.checkLogin(SESSION_MANAGER.getCurrSession())) {
+      IClientSession clientSession = SESSION_MANAGER.getCurrSessionAndUpdateIdleTime();
+      if (!SESSION_MANAGER.checkLogin(clientSession)) {
         return getNotLoggedInStatus();
       }
 
       DeleteDataStatement statement = StatementGenerator.createStatement(req);
 
       // permission check
-      TSStatus status =
-          AuthorityChecker.checkAuthority(statement, SESSION_MANAGER.getCurrSession());
+      TSStatus status = AuthorityChecker.checkAuthority(statement, clientSession);
       if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
         return status;
       }
@@ -1488,10 +1518,10 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
           COORDINATOR.execute(
               statement,
               queryId,
-              SESSION_MANAGER.getSessionInfo(SESSION_MANAGER.getCurrSession()),
+              SESSION_MANAGER.getSessionInfo(clientSession),
               "",
-              PARTITION_FETCHER,
-              SCHEMA_FETCHER);
+              partitionFetcher,
+              schemaFetcher);
 
       return result.status;
     } catch (IoTDBException e) {
@@ -1499,6 +1529,8 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
     } catch (Exception e) {
       return onNPEOrUnexpectedException(
           e, OperationType.DELETE_DATA, TSStatusCode.EXECUTE_STATEMENT_ERROR);
+    } finally {
+      SESSION_MANAGER.updateIdleTime();
     }
   }
 
@@ -1525,7 +1557,8 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
   @Override
   public TSStatus createSchemaTemplate(TSCreateSchemaTemplateReq req) {
     try {
-      if (!SESSION_MANAGER.checkLogin(SESSION_MANAGER.getCurrSession())) {
+      IClientSession clientSession = SESSION_MANAGER.getCurrSessionAndUpdateIdleTime();
+      if (!SESSION_MANAGER.checkLogin(clientSession)) {
         return getNotLoggedInStatus();
       }
 
@@ -1538,8 +1571,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
         AuditLogger.log(String.format("create schema template %s", req.getName()), statement);
       }
       // permission check
-      TSStatus status =
-          AuthorityChecker.checkAuthority(statement, SESSION_MANAGER.getCurrSession());
+      TSStatus status = AuthorityChecker.checkAuthority(statement, clientSession);
       if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
         return status;
       }
@@ -1550,10 +1582,10 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
           COORDINATOR.execute(
               statement,
               queryId,
-              SESSION_MANAGER.getSessionInfo(SESSION_MANAGER.getCurrSession()),
+              SESSION_MANAGER.getSessionInfo(clientSession),
               "",
-              PARTITION_FETCHER,
-              SCHEMA_FETCHER);
+              partitionFetcher,
+              schemaFetcher);
 
       return result.status;
     } catch (IoTDBException e) {
@@ -1561,6 +1593,8 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
     } catch (Exception e) {
       return onNPEOrUnexpectedException(
           e, OperationType.CREATE_SCHEMA_TEMPLATE, TSStatusCode.EXECUTE_STATEMENT_ERROR);
+    } finally {
+      SESSION_MANAGER.updateIdleTime();
     }
   }
 
@@ -1580,7 +1614,8 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
   public TSQueryTemplateResp querySchemaTemplate(TSQueryTemplateReq req) {
     TSQueryTemplateResp resp = new TSQueryTemplateResp();
     try {
-      if (!SESSION_MANAGER.checkLogin(SESSION_MANAGER.getCurrSession())) {
+      IClientSession clientSession = SESSION_MANAGER.getCurrSessionAndUpdateIdleTime();
+      if (!SESSION_MANAGER.checkLogin(clientSession)) {
         resp.setStatus(getNotLoggedInStatus());
         return resp;
       }
@@ -1611,6 +1646,8 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
         case SHOW_USING_TEMPLATES:
           resp.setQueryType(TemplateQueryType.SHOW_USING_TEMPLATES.ordinal());
           break;
+        default:
+          break;
       }
       return executeTemplateQueryStatement(statement, req, resp);
     } catch (Exception e) {
@@ -1618,6 +1655,8 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
           onNPEOrUnexpectedException(
               e, OperationType.EXECUTE_QUERY_STATEMENT, TSStatusCode.EXECUTE_STATEMENT_ERROR));
       return resp;
+    } finally {
+      SESSION_MANAGER.updateIdleTime();
     }
   }
 
@@ -1625,9 +1664,9 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
       Statement statement, TSQueryTemplateReq req, TSQueryTemplateResp resp) {
     long startTime = System.currentTimeMillis();
     try {
+      IClientSession clientSession = SESSION_MANAGER.getCurrSessionAndUpdateIdleTime();
       // permission check
-      TSStatus status =
-          AuthorityChecker.checkAuthority(statement, SESSION_MANAGER.getCurrSession());
+      TSStatus status = AuthorityChecker.checkAuthority(statement, clientSession);
       if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
         resp.setStatus(status);
         return resp;
@@ -1642,10 +1681,10 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
           COORDINATOR.execute(
               statement,
               queryId,
-              SESSION_MANAGER.getSessionInfo(SESSION_MANAGER.getCurrSession()),
+              SESSION_MANAGER.getSessionInfo(clientSession),
               null,
-              PARTITION_FETCHER,
-              SCHEMA_FETCHER,
+              partitionFetcher,
+              schemaFetcher,
               config.getQueryTimeoutThreshold());
 
       if (executionResult.status.code != TSStatusCode.SUCCESS_STATUS.getStatusCode()
@@ -1686,13 +1725,15 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
           OperationType.EXECUTE_STATEMENT,
           statement.getType(),
           System.currentTimeMillis() - startTime);
+      SESSION_MANAGER.updateIdleTime();
     }
   }
 
   @Override
   public TSStatus setSchemaTemplate(TSSetSchemaTemplateReq req) throws TException {
     try {
-      if (!SESSION_MANAGER.checkLogin(SESSION_MANAGER.getCurrSession())) {
+      IClientSession clientSession = SESSION_MANAGER.getCurrSessionAndUpdateIdleTime();
+      if (!SESSION_MANAGER.checkLogin(clientSession)) {
         return getNotLoggedInStatus();
       }
 
@@ -1708,8 +1749,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
       }
 
       // permission check
-      TSStatus status =
-          AuthorityChecker.checkAuthority(statement, SESSION_MANAGER.getCurrSession());
+      TSStatus status = AuthorityChecker.checkAuthority(statement, clientSession);
       if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
         return status;
       }
@@ -1720,10 +1760,10 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
           COORDINATOR.execute(
               statement,
               queryId,
-              SESSION_MANAGER.getSessionInfo(SESSION_MANAGER.getCurrSession()),
+              SESSION_MANAGER.getSessionInfo(clientSession),
               "",
-              PARTITION_FETCHER,
-              SCHEMA_FETCHER);
+              partitionFetcher,
+              schemaFetcher);
 
       return result.status;
     } catch (IllegalPathException e) {
@@ -1731,13 +1771,16 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
     } catch (Exception e) {
       return onNPEOrUnexpectedException(
           e, OperationType.EXECUTE_STATEMENT, TSStatusCode.EXECUTE_STATEMENT_ERROR);
+    } finally {
+      SESSION_MANAGER.updateIdleTime();
     }
   }
 
   @Override
   public TSStatus unsetSchemaTemplate(TSUnsetSchemaTemplateReq req) throws TException {
     try {
-      if (!SESSION_MANAGER.checkLogin(SESSION_MANAGER.getCurrSession())) {
+      IClientSession clientSession = SESSION_MANAGER.getCurrSessionAndUpdateIdleTime();
+      if (!SESSION_MANAGER.checkLogin(clientSession)) {
         return getNotLoggedInStatus();
       }
 
@@ -1754,8 +1797,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
       }
 
       // permission check
-      TSStatus status =
-          AuthorityChecker.checkAuthority(statement, SESSION_MANAGER.getCurrSession());
+      TSStatus status = AuthorityChecker.checkAuthority(statement, clientSession);
       if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
         return status;
       }
@@ -1766,10 +1808,10 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
           COORDINATOR.execute(
               statement,
               queryId,
-              SESSION_MANAGER.getSessionInfo(SESSION_MANAGER.getCurrSession()),
+              SESSION_MANAGER.getSessionInfo(clientSession),
               "",
-              PARTITION_FETCHER,
-              SCHEMA_FETCHER);
+              partitionFetcher,
+              schemaFetcher);
 
       return result.status;
     } catch (IllegalPathException e) {
@@ -1777,13 +1819,16 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
     } catch (Exception e) {
       return onNPEOrUnexpectedException(
           e, OperationType.EXECUTE_STATEMENT, TSStatusCode.EXECUTE_STATEMENT_ERROR);
+    } finally {
+      SESSION_MANAGER.updateIdleTime();
     }
   }
 
   @Override
   public TSStatus dropSchemaTemplate(TSDropSchemaTemplateReq req) throws TException {
     try {
-      if (!SESSION_MANAGER.checkLogin(SESSION_MANAGER.getCurrSession())) {
+      IClientSession clientSession = SESSION_MANAGER.getCurrSessionAndUpdateIdleTime();
+      if (!SESSION_MANAGER.checkLogin(clientSession)) {
         return getNotLoggedInStatus();
       }
 
@@ -1797,8 +1842,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
       }
 
       // permission check
-      TSStatus status =
-          AuthorityChecker.checkAuthority(statement, SESSION_MANAGER.getCurrSession());
+      TSStatus status = AuthorityChecker.checkAuthority(statement, clientSession);
       if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
         return status;
       }
@@ -1809,15 +1853,17 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
           COORDINATOR.execute(
               statement,
               queryId,
-              SESSION_MANAGER.getSessionInfo(SESSION_MANAGER.getCurrSession()),
+              SESSION_MANAGER.getSessionInfo(clientSession),
               "",
-              PARTITION_FETCHER,
-              SCHEMA_FETCHER);
+              partitionFetcher,
+              schemaFetcher);
 
       return result.status;
     } catch (Exception e) {
       return onNPEOrUnexpectedException(
           e, OperationType.EXECUTE_STATEMENT, TSStatusCode.EXECUTE_STATEMENT_ERROR);
+    } finally {
+      SESSION_MANAGER.updateIdleTime();
     }
   }
 
@@ -1828,8 +1874,8 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
         .handshake(
             info,
             SESSION_MANAGER.getCurrSession().getClientAddress(),
-            PARTITION_FETCHER,
-            SCHEMA_FETCHER);
+            partitionFetcher,
+            schemaFetcher);
   }
 
   @Override
@@ -1856,7 +1902,8 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
   public TSStatus insertStringRecord(TSInsertStringRecordReq req) {
     long t1 = System.currentTimeMillis();
     try {
-      if (!SESSION_MANAGER.checkLogin(SESSION_MANAGER.getCurrSession())) {
+      IClientSession clientSession = SESSION_MANAGER.getCurrSessionAndUpdateIdleTime();
+      if (!SESSION_MANAGER.checkLogin(clientSession)) {
         return getNotLoggedInStatus();
       }
 
@@ -1874,8 +1921,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
       }
 
       // permission check
-      TSStatus status =
-          AuthorityChecker.checkAuthority(statement, SESSION_MANAGER.getCurrSession());
+      TSStatus status = AuthorityChecker.checkAuthority(statement, clientSession);
       if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
         return status;
       }
@@ -1886,10 +1932,10 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
           COORDINATOR.execute(
               statement,
               queryId,
-              SESSION_MANAGER.getSessionInfo(SESSION_MANAGER.getCurrSession()),
+              SESSION_MANAGER.getSessionInfo(clientSession),
               "",
-              PARTITION_FETCHER,
-              SCHEMA_FETCHER);
+              partitionFetcher,
+              schemaFetcher);
 
       return result.status;
     } catch (IoTDBException e) {
@@ -1902,6 +1948,7 @@ public class ClientRPCServiceImpl implements IClientRPCServiceWithHandler {
           OperationType.INSERT_STRING_RECORD,
           StatementType.INSERT,
           System.currentTimeMillis() - t1);
+      SESSION_MANAGER.updateIdleTime();
     }
   }