Describe the bug
Hello Team Redis!
Redis logs complain of vm.overcommit set as 0 but this is incorrect. However according to sysctl the variable is set as 1, as recommended.
To reproduce
Start a new Redis instance (or restart an existing instance) via:
systemctl start redis.service
and then look at the log output for when the Redis server starts or restarts e.g.
less /var/log/redis/redis.log
01 Jul 2022 23:23:44.379 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
Then ask sysctl to output the list of variables and values:
sysctl -a
or better still grep that long list:
sysctl -a | grep vm.overcommit
which confirms it is set:
sysctl: reading key "net.ipv6.conf.all.stable_secret"
sysctl: reading key "net.ipv6.conf.default.stable_secret"
sysctl: reading key "net.ipv6.conf.lo.stable_secret"
sysctl: reading key "net.ipv6.conf.venet0.stable_secret"
vm.overcommit_kbytes = 0
**vm.overcommit_memory = 1**
vm.overcommit_ratio = 50
Expected behavior
If possible, Redis log output to be correct concerning warning advice. Have spent a lot of time trying to apply the command to fix the issue which produces an error message when run.
Additional information
My system is a cloud VPS (virtuozzo) running CentOS 7.9 and cPanel & WHM v104.0.4 (STANDARD). Apache 2.4. Redis v7.0.2. It has 48 cores 6 GB RAM but no swap file. Always around 2-4GB available.
Contents of sysctl.conf:
nano /etc/sysctl.conf
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
net.core.somaxconn=65535
vm.overcommit_memory = 1
Regards.
Comment From: enjoy-binbin
sorry for that, see #10906 and #10841
it will be fix in 7.0.3, so now just ignore the warning (the vm.overcommit_memory = 1 is working, we did a wrong check, so the warning is always printed)
Comment From: TheOldMan2000
Awesome, thank you!