Преглед изворни кода

fix(sessds): Replace min- and max- batch size with batch_size

ieQu1 пре 2 година
родитељ
комит
91ddbbcc3f
3 измењених фајлова са 47 додато и 14 уклоњено
  1. 1 1
      apps/emqx/src/emqx_persistent_session_ds.erl
  2. 19 3
      apps/emqx/src/emqx_schema.erl
  3. 27 10
      rel/i18n/emqx_schema.hocon

+ 1 - 1
apps/emqx/src/emqx_persistent_session_ds.erl

@@ -733,7 +733,7 @@ fetch_new_messages(Session = #{s := S}, ClientInfo) ->
 fetch_new_messages([], Session, _ClientInfo) ->
     Session;
 fetch_new_messages([I | Streams], Session0 = #{inflight := Inflight}, ClientInfo) ->
-    BatchSize = emqx_config:get([session_persistence, max_batch_size]),
+    BatchSize = emqx_config:get([session_persistence, batch_size]),
     case emqx_persistent_session_ds_inflight:n_buffered(all, Inflight) >= BatchSize of
         true ->
             %% Buffer is full:

+ 19 - 3
apps/emqx/src/emqx_schema.erl

@@ -258,7 +258,10 @@ roots(medium) ->
         {"durable_storage",
             sc(
                 ref("durable_storage"),
-                #{importance => ?IMPORTANCE_MEDIUM}
+                #{
+                    importance => ?IMPORTANCE_MEDIUM,
+                    desc => ?DESC(durable_storage)
+                }
             )}
     ];
 roots(low) ->
@@ -1659,20 +1662,33 @@ fields("session_persistence") ->
                     default => false
                 }
             )},
+        {"batch_size",
+            sc(
+                pos_integer(),
+                #{
+                    default => 100,
+                    desc => ?DESC(session_ds_batch_size),
+                    importance => ?IMPORTANCE_MEDIUM
+                }
+            )},
+        %% Deprecated, now the replayer always use constant batch size:
         {"max_batch_size",
             sc(
                 pos_integer(),
                 #{
                     default => 100,
-                    desc => ?DESC(session_ds_max_batch_size)
+                    desc => ?DESC(session_ds_max_batch_size),
+                    importance => ?IMPORTANCE_HIDDEN
                 }
             )},
+        %% Deprecated, now the replayer always use constant batch size:
         {"min_batch_size",
             sc(
                 pos_integer(),
                 #{
                     default => 100,
-                    desc => ?DESC(session_ds_min_batch_size)
+                    desc => ?DESC(session_ds_min_batch_size),
+                    importance => ?IMPORTANCE_HIDDEN
                 }
             )},
         {"idle_poll_interval",

+ 27 - 10
rel/i18n/emqx_schema.hocon

@@ -1531,29 +1531,46 @@ resource_tags.label:
 resource_tags.desc:
 """Tags to annotate this config entry."""
 
+session_persistence_enable.label:
+"""Enable session persistence"""
+
 session_persistence_enable.desc:
 """Use durable storage for client sessions persistence.
-If enabled, sessions configured to outlive client connections, along with their corresponding messages, will be durably stored and survive broker downtime."""
+If enabled, sessions configured to outlive client connections, along with their corresponding messages, will be durably stored and survive broker downtime.
+
+:::warning
+This feature is currently experimental. Please don't enable it in the producation environments that contain valuable data.
+:::"""
+
+
+session_ds_session_gc_interval.label:
+"""Session garbage collection interval"""
 
 session_ds_session_gc_interval.desc:
 """The interval at which session garbage collection is executed for persistent sessions."""
 
+session_ds_session_gc_batch_size.label:
+"""Session garbage collection batch size"""
+
 session_ds_session_gc_batch_size.desc:
 """The size of each batch of expired persistent sessions to be garbage collected per iteration."""
 
-session_ds_max_batch_size.desc:
-"""This value affects the flow control for the persistent sessions.
-The session queries the DB for the new messages in batches.
-Size of the batch doesn't exceed this value or `ReceiveMaximum`, whichever is smaller."""
+session_ds_batch_size.label:
+"""Batch size"""
 
-session_ds_min_batch_size.desc:
+session_ds_batch_size.desc:
 """This value affects the flow control for the persistent sessions.
-The session will query the DB for the new messages when the value of `FreeSpace` variable is larger than this value or `ReceiveMaximum` / 2, whichever is smaller.
+Persistent session queries the durable message storage in batches.
+This value specifies size of the batch.
+
+Note: larger batches generally improve the throughput and overall performance of the system, but increase RAM usage per client."""
 
-`FreeSpace` is calculated as `ReceiveMaximum` for the session - number of inflight messages."""
+durable_storage.label:
+"""Durable storage"""
 
-session_ds_message_retention_period.desc:
-"""The minimum amount of time that messages should be retained for.  After messages have been in storage for at least this period of time, they'll be dropped."""
+durable_storage.desc:
+"""Configuration related to the EMQX durable storages.
 
+EMQX uses durable storages to offload various data, such as MQTT messages, to disc."""
 
 }