diff --git a/conf/pika.conf b/conf/pika.conf index 2f6990b959..44c2de9067 100644 --- a/conf/pika.conf +++ b/conf/pika.conf @@ -253,9 +253,8 @@ disable_auto_compactions : false sync-window-size : 9000 # Maximum buffer size of a client connection. -# Only three values are valid here: [67108864(64MB) | 268435456(256MB) | 536870912(512MB)]. # [NOTICE] Master and slaves must have exactly the same value for the max-conn-rbuf-size. -# Supported Units [K|M|G]. Its default unit is in [bytes] and its default value is 268435456(256MB). +# Supported Units [K|M|G]. Its default unit is in [bytes] and its default value is 268435456(256MB). The value range is [64MB, 1GB]. max-conn-rbuf-size : 268435456 diff --git a/docs/ops/config.md b/docs/ops/config.md index cdac25c43b..d0f5a0e4c0 100644 --- a/docs/ops/config.md +++ b/docs/ops/config.md @@ -142,8 +142,7 @@ identify-binlog-type : new # 主从同步流量控制的的窗口,主从高延迟情形下可以通过提高该参数提高同步性能。默认值9000最大值90000。 sync-window-size : 9000 -# 处理客户端连接请求的最大缓存大小,可配置的数值为67108864(64MB) 或 268435456(256MB) 或 536870912(512MB) -# 默认是268435456(256MB),需要注意的是主从的配置需要一致。 +# 处理客户端连接请求的最大缓存大小,默认是268435456(256MB),范围为[64MB, 1GB],需要注意的是主从的配置需要一致。 # 单条命令超过此buffer大小,服务端会自动关闭与客户端的连接。 max-conn-rbuf-size : 268435456 diff --git a/src/pika_admin.cc b/src/pika_admin.cc index d25b9459e4..b0afb5ae98 100644 --- a/src/pika_admin.cc +++ b/src/pika_admin.cc @@ -2174,6 +2174,7 @@ void ConfigCmd::ConfigSet(std::shared_ptr db) { "zset-cache-start-direction", "zset-cache-field-num-per-key", "cache-lfu-decay-time", + "max-conn-rbuf-size", }); res_.AppendStringVector(replyVt); return; @@ -2646,6 +2647,13 @@ void ConfigCmd::ConfigSet(std::shared_ptr db) { } g_pika_conf->SetAclLogMaxLen(static_cast(ival)); res_.AppendStringRaw("+OK\r\n"); + } else if (set_item == "max-conn-rbuf-size") { + if (pstd::string2int(value.data(), value.size(), &ival) == 0 || ival < PIKA_MAX_CONN_RBUF_LB || ival > PIKA_MAX_CONN_RBUF_HB * 2) { + res_.AppendStringRaw( "-ERR Invalid argument \'" + value + "\' for CONFIG SET 'max-conn-rbuf-size'\r\n"); + return; + } + g_pika_conf->SetMaxConnRbufSize(static_cast(ival)); + res_.AppendStringRaw("+OK\r\n"); } else { res_.AppendStringRaw("-ERR Unsupported CONFIG parameter: " + set_item + "\r\n"); } diff --git a/src/pika_conf.cc b/src/pika_conf.cc index 8086bb2285..09ae68996e 100644 --- a/src/pika_conf.cc +++ b/src/pika_conf.cc @@ -538,10 +538,12 @@ int PikaConf::Load() { // max conn rbuf size int tmp_max_conn_rbuf_size = PIKA_MAX_CONN_RBUF; GetConfIntHuman("max-conn-rbuf-size", &tmp_max_conn_rbuf_size); - if (tmp_max_conn_rbuf_size == PIKA_MAX_CONN_RBUF_LB || tmp_max_conn_rbuf_size == PIKA_MAX_CONN_RBUF_HB) { - max_conn_rbuf_size_.store(tmp_max_conn_rbuf_size); + if (tmp_max_conn_rbuf_size <= PIKA_MAX_CONN_RBUF_LB) { + max_conn_rbuf_size_.store(PIKA_MAX_CONN_RBUF_LB); + } else if (tmp_max_conn_rbuf_size >= PIKA_MAX_CONN_RBUF_HB * 2) { + max_conn_rbuf_size_.store(PIKA_MAX_CONN_RBUF_HB * 2); } else { - max_conn_rbuf_size_.store(PIKA_MAX_CONN_RBUF); + max_conn_rbuf_size_.store(tmp_max_conn_rbuf_size); } // rocksdb blob configure @@ -656,6 +658,7 @@ int PikaConf::ConfigRewrite() { SetConfInt("consensus-level", consensus_level_.load()); SetConfInt("replication-num", replication_num_.load()); SetConfStr("slow-cmd-list", pstd::Set2String(slow_cmd_set_, ',')); + SetConfInt("max-conn-rbuf-size", max_conn_rbuf_size_.load()); // options for storage engine SetConfInt("max-cache-files", max_cache_files_); SetConfInt("max-background-compactions", max_background_compactions_); diff --git a/tests/assets/default.conf b/tests/assets/default.conf index a4d89653b1..834db0fe15 100644 --- a/tests/assets/default.conf +++ b/tests/assets/default.conf @@ -243,9 +243,8 @@ slave-priority : 100 sync-window-size : 9000 # Maximum buffer size of a client connection. -# Only three values are valid here: [67108864(64MB) | 268435456(256MB) | 536870912(512MB)]. # [NOTICE] Master and slaves must have exactly the same value for the max-conn-rbuf-size. -# Supported Units [K|M|G]. Its default unit is in [bytes] and its default value is 268435456(256MB). +# Supported Units [K|M|G]. Its default unit is in [bytes] and its default value is 268435456(256MB). The value range is [64MB, 1GB]. max-conn-rbuf-size : 268435456 diff --git a/tests/conf/pika.conf b/tests/conf/pika.conf index 5f9167d96a..a13fae19e9 100644 --- a/tests/conf/pika.conf +++ b/tests/conf/pika.conf @@ -241,9 +241,8 @@ slave-priority : 100 sync-window-size : 9000 # Maximum buffer size of a client connection. -# Only three values are valid here: [67108864(64MB) | 268435456(256MB) | 536870912(512MB)]. # [NOTICE] Master and slaves must have exactly the same value for the max-conn-rbuf-size. -# Supported Units [K|M|G]. Its default unit is in [bytes] and its default value is 268435456(256MB). +# Supported Units [K|M|G]. Its default unit is in [bytes] and its default value is 268435456(256MB). The value range is [64MB, 1GB]. max-conn-rbuf-size : 268435456 diff --git a/tools/kubeblocks_helm/pika/config/pika-config.tpl b/tools/kubeblocks_helm/pika/config/pika-config.tpl index d836c99413..25b2708949 100644 --- a/tools/kubeblocks_helm/pika/config/pika-config.tpl +++ b/tools/kubeblocks_helm/pika/config/pika-config.tpl @@ -220,9 +220,8 @@ slave-priority : 100 sync-window-size : 9000 # Maximum buffer size of a client connection. -# Only three values are valid here: [67108864(64MB) | 268435456(256MB) | 536870912(512MB)]. # [NOTICE] Master and slaves must have exactly the same value for the max-conn-rbuf-size. -# Supported Units [K|M|G]. Its default unit is in [bytes] and its default value is 268435456(256MB). +# Supported Units [K|M|G]. Its default unit is in [bytes] and its default value is 268435456(256MB). The [minimum] value is 67108864(64MB). max-conn-rbuf-size : 268435456