Do not set vm.max_map_count when unnecessary (#31285)
This commit modifies the Sys V init startup scripts to only modify vm.max_map_count if needed. In this case, needed means that the current value is less than our default value of 262144 maps.
This commit is contained in:
parent
e5b7137508
commit
87a676e4d5
|
@ -122,7 +122,7 @@ case "$1" in
|
|||
ulimit -l $MAX_LOCKED_MEMORY
|
||||
fi
|
||||
|
||||
if [ -n "$MAX_MAP_COUNT" -a -f /proc/sys/vm/max_map_count ]; then
|
||||
if [ -n "$MAX_MAP_COUNT" -a -f /proc/sys/vm/max_map_count -a "$MAX_MAP_COUNT" -ge $(cat /proc/sys/vm/max_map_count) ]; then
|
||||
sysctl -q -w vm.max_map_count=$MAX_MAP_COUNT
|
||||
fi
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ start() {
|
|||
if [ -n "$MAX_LOCKED_MEMORY" ]; then
|
||||
ulimit -l $MAX_LOCKED_MEMORY
|
||||
fi
|
||||
if [ -n "$MAX_MAP_COUNT" -a -f /proc/sys/vm/max_map_count ]; then
|
||||
if [ -n "$MAX_MAP_COUNT" -a -f /proc/sys/vm/max_map_count -a "$MAX_MAP_COUNT" -ge $(cat /proc/sys/vm/max_map_count) ]; then
|
||||
sysctl -q -w vm.max_map_count=$MAX_MAP_COUNT
|
||||
fi
|
||||
|
||||
|
|
|
@ -163,3 +163,31 @@ setup() {
|
|||
assert_file_exist /var/log/elasticsearch/gc.log.0.current
|
||||
stop_elasticsearch_service
|
||||
}
|
||||
|
||||
# Ensures that if $MAX_MAP_COUNT is less than the set value on the OS
|
||||
# it will be updated
|
||||
@test "[INIT.D] sysctl is run when the value set is too small" {
|
||||
# intentionally a ridiculously low number
|
||||
sysctl -q -w vm.max_map_count=100
|
||||
start_elasticsearch_service
|
||||
max_map_count=$(sysctl -n vm.max_map_count)
|
||||
stop_elasticsearch_service
|
||||
|
||||
[ $max_map_count = 262144 ]
|
||||
|
||||
}
|
||||
|
||||
# Ensures that if $MAX_MAP_COUNT is greater than the set vaule on the OS
|
||||
# we do not attempt to update it this should cover equality as well as I think
|
||||
# we can trust that equality operators work as intended.
|
||||
@test "[INIT.D] sysctl is not run when it already has a larger or equal value set" {
|
||||
# intentionally set to the default +1
|
||||
sysctl -q -w vm.max_map_count=262145
|
||||
start_elasticsearch_service
|
||||
max_map_count=$(sysctl -n vm.max_map_count)
|
||||
stop_elasticsearch_service
|
||||
|
||||
# default value +1
|
||||
[ $max_map_count = 262145 ]
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue