From 61acb991f9ad1ab44a5eaa1c4434a6ceebd596a0 Mon Sep 17 00:00:00 2001
From: Georgy Lomakin <g.lomakin@picodata.io>
Date: Mon, 10 Feb 2025 17:21:39 +0300
Subject: [PATCH 1/2] closes #1200; feat: support memtx_max_tuple_size into the
 configuration file

---
 src/cli/args.rs              |  6 ++++++
 src/config.rs                | 12 ++++++++++++
 src/tarantool.rs             |  1 +
 test/int/test_config_file.py |  3 +++
 4 files changed, 22 insertions(+)

diff --git a/src/cli/args.rs b/src/cli/args.rs
index 7577e16979..75e3ae755d 100644
--- a/src/cli/args.rs
+++ b/src/cli/args.rs
@@ -301,6 +301,12 @@ pub struct Run {
     /// By default, 64 MiB is used.
     pub memtx_memory: Option<ByteSize>,
 
+    #[clap(long = "memtx-max-tuple-size", env = "PICODATA_MEMTX_MAX_TUPLE_SIZE")]
+    /// Size of the largest allocation unit, for the memtx storage engine
+    ///
+    /// By default, 1 MiB is used.
+    pub memtx_max_tuple_size: Option<ByteSize>,
+
     #[clap(hide = true, long = "entrypoint-fd")]
     /// A pipe file descriptor from which picodata reads the entrypoint info
     /// when doing a rebootstrap during the cluster initialization.
diff --git a/src/config.rs b/src/config.rs
index 886db575eb..c9bc8e200b 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -350,6 +350,10 @@ Using configuration file '{args_path}'.");
             config_from_args.instance.memtx.memory = Some(memtx_memory);
         }
 
+        if let Some(memtx_max_tuple_size) = args.memtx_max_tuple_size {
+            config_from_args.instance.memtx.max_tuple_size = Some(memtx_max_tuple_size);
+        }
+
         // --config-parameter has higher priority than other command line
         // arguments as a side effect of the fact that clap doesn't tell us
         // where the value came from: cli or env. Because we want
@@ -1382,6 +1386,12 @@ pub struct MemtxSection {
     /// Corresponds to `box.cfg.memtx_memory`.
     #[introspection(config_default = "64M")]
     pub memory: Option<ByteSize>,
+
+    /// Memory limit for one tuple.
+    ///
+    /// Corresponds to `box.cfg.memtx_max_tuple_size`.
+    #[introspection(config_default = "1M")]
+    pub max_tuple_size: Option<ByteSize>,
 }
 
 tarantool::define_str_enum! {
@@ -2470,11 +2480,13 @@ instance:
             let config = setup_for_tests(Some(yaml), &["run",
                 "-c", "  instance.log .level =debug  ",
                 "--config-parameter", "instance. memtx . memory=  999",
+                "--config-parameter", "instance. memtx . max_tuple_size=  998",
             ]).unwrap();
             assert_eq!(config.instance.tier.unwrap(), "ABC");
             assert_eq!(config.cluster.name.unwrap(), "DEF");
             assert_eq!(config.instance.log.level.unwrap(), args::LogLevel::Debug);
             assert_eq!(config.instance.memtx.memory.unwrap().to_string(), String::from("999B"));
+            assert_eq!(config.instance.memtx.max_tuple_size.unwrap().to_string(), String::from("998B"));
             assert_eq!(config.instance.audit.unwrap(), "audit.txt");
             assert_eq!(config.instance.instance_dir.unwrap(), PathBuf::from("."));
 
diff --git a/src/tarantool.rs b/src/tarantool.rs
index db42dae36a..e18be92657 100644
--- a/src/tarantool.rs
+++ b/src/tarantool.rs
@@ -322,6 +322,7 @@ impl Cfg {
         #[rustfmt::skip]
         const BYTESIZE_FIELDS: &[(&str, &str)] = &[
             ("memtx_memory",                config_parameter_path!(instance.memtx.memory)),
+            ("memtx_max_tuple_size",        config_parameter_path!(instance.memtx.max_tuple_size)),
             ("vinyl_memory",                config_parameter_path!(instance.vinyl.memory)),
             ("vinyl_cache",                 config_parameter_path!(instance.vinyl.cache)),
             ("vinyl_max_tuple_size",        config_parameter_path!(instance.vinyl.max_tuple_size)),
diff --git a/test/int/test_config_file.py b/test/int/test_config_file.py
index f6374ffb1f..fef2238568 100644
--- a/test/int/test_config_file.py
+++ b/test/int/test_config_file.py
@@ -18,6 +18,7 @@ instance:
 
     memtx:
         memory: 42069
+        max_tuple_size: 10485760
 """
     )
     instance = cluster.add_instance(wait_online=False)
@@ -29,6 +30,7 @@ instance:
     assert info["replicaset_name"] == "with-love"
 
     assert instance.eval("return box.cfg.memtx_memory") == 42069
+    assert instance.eval("return box.cfg.memtx_max_tuple_size") == 10485760
 
 
 def test_pico_config(cluster: Cluster, port_distributor: PortDistributor):
@@ -103,6 +105,7 @@ instance:
             peer=dict(value=[f"{host}:{port}"], source="config_file"),
             memtx=dict(
                 memory=dict(value="64M", source="default"),
+                max_tuple_size=dict(value="1M", source="default"),
             ),
             vinyl=dict(
                 memory=dict(value="128M", source="default"),
-- 
GitLab


From a413656ef5c45b223c28133d7028714d1dcf3ac2 Mon Sep 17 00:00:00 2001
From: Georgy Lomakin <g.lomakin@picodata.io>
Date: Mon, 10 Feb 2025 21:27:50 +0300
Subject: [PATCH 2/2] chore: update changelog.md

---
 CHANGELOG.md | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 57c5be5747..b9f05455b9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -23,6 +23,8 @@ with the `YY.MINOR.MICRO` scheme.
 - New parameters for Vinyl configuration: `bloom_fpr`, `max_tuple_size`, `page_size`, `range_size`,
   `run_count_per_size`, `run_size_ratio`, `read_threads`, `write_threads` and `timeout`.
 
+- New parameter for Memtx configuration: `max_tuple_size`.
+
 - `plugin_dir` parameter is renamed to `share_dir` (--plugin-dir -> --share-dir,
   PICODATA_PLUGIN_DIR -> PICODATA_SHARE_DIR, config: instance.plugin_dir ->
   instance.share_dir)
-- 
GitLab