From 5071c02bb071ca7fdd9080248902f43f1817a546 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Tue, 2 Apr 2024 23:33:06 +0200 Subject: [PATCH 1/3] nixos/redis: enable vmOverCommit by default as recommended by redis itself > WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. > Being disabled, it can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. > 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. --- nixos/modules/services/databases/redis.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/databases/redis.nix b/nixos/modules/services/databases/redis.nix index 1da2fa9f1160..76a1c9b7fb66 100644 --- a/nixos/modules/services/databases/redis.nix +++ b/nixos/modules/services/databases/redis.nix @@ -57,9 +57,9 @@ in { package = mkPackageOption pkgs "redis" { }; vmOverCommit = mkEnableOption '' - setting of vm.overcommit_memory to 1 + set `vm.overcommit_memory` sysctl to 1 (Suggested for Background Saving: ) - ''; + '' // { default = true; }; servers = mkOption { type = with types; attrsOf (submodule ({ config, name, ... }: { From 5f349abc7bb21ee5528acd27fc0667c9b3f7f813 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Tue, 2 Apr 2024 23:53:20 +0200 Subject: [PATCH 2/3] nixos/redis: don't disable transparent hugepages Since https://github.com/redis/redis/pull/4001 included in 6.2.0 transparent hugepages works when being set to madvise which is the NixOS and upstream recommended default. --- nixos/modules/services/databases/redis.nix | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/nixos/modules/services/databases/redis.nix b/nixos/modules/services/databases/redis.nix index 76a1c9b7fb66..ad88a4f589a2 100644 --- a/nixos/modules/services/databases/redis.nix +++ b/nixos/modules/services/databases/redis.nix @@ -312,10 +312,9 @@ in { ''; }) enabledServers); - boot.kernel.sysctl = mkMerge [ - { "vm.nr_hugepages" = "0"; } - ( mkIf cfg.vmOverCommit { "vm.overcommit_memory" = "1"; } ) - ]; + boot.kernel.sysctl = mkIf cfg.vmOverCommit { + "vm.overcommit_memory" = "1"; + }; networking.firewall.allowedTCPPorts = concatMap (conf: optional conf.openFirewall conf.port From 5b88059fe508c4606d0af7619f0face747a45435 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Wed, 3 Apr 2024 15:45:54 +0200 Subject: [PATCH 3/3] nixos/release-notes: add redis vmOverCommit entry --- nixos/doc/manual/release-notes/rl-2405.section.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nixos/doc/manual/release-notes/rl-2405.section.md b/nixos/doc/manual/release-notes/rl-2405.section.md index d83e7c4ff71c..08f1d8cdac75 100644 --- a/nixos/doc/manual/release-notes/rl-2405.section.md +++ b/nixos/doc/manual/release-notes/rl-2405.section.md @@ -293,6 +293,8 @@ The pre-existing [services.ankisyncd](#opt-services.ankisyncd.enable) has been m - `network-interfaces.target` system target was removed as it has been deprecated for a long time. Use `network.target` instead. +- `services.redis.vmOverCommit` now defaults to `true` and no longer enforces Transparent Hugepages (THP) to be disabled. Redis only works with THP configured to `madvise` which is the kernel's default. + - `azure-cli` now has extension support. For example, to install the `aks-preview` extension, use ```nix