Articles in this section

why do I get CRITICAL mprotect(...) failed: 12 (Cannot allocate memory)?

Detail

Aerospike Server running version 7.2 (or above) configured for in memory namespace fails to starts or abruptly stops with following error:

 

Feb 19 2025 12:27:06 GMT: CRITICAL (drv-mem): (drv_mem.c:3569) mprotect(0xxxxxxxxxxxx, 8388608, 3) failed: 12 (Cannot allocate memory)

Answer

Aerospike version 7 and above uses shared memory when configured for storage in-memory.

The likely issue is the shared memory and mmap Kernel settings are misconfigured and needs to be tuned for your system.

 

 

 


Notes

Please review and configure the following settings:

sysctl -a | grep shmmax
sysctl -n kernel.shmall
getconf PAGE_SIZE

a) SHMALL : Setting for the  total amount of shared memory pages that can be used system wide.

SHMALL should always be at least ceil(shmmax/PAGE_SIZE)

This settings can be dynamically configured:

sysctl -w kernel.shmall=<value in bytes>

and  statically make the configuration permanent:

echo "kernel.shmall=<value in bytes>" >> /etc/sysctl.conf

 

b) SHMMAX: This setting the maximum size in bytes of a single shared memory segment that a Linux process can allocate in its virtual address space.

SHMAX should be large enough to allocate one Aerospike disk stripe.

This settings can be dynamically configured:

sysctl -w kernel.shmmax=<value in bytes>

and  statically make the configuration permanent:

echo "kernel.shmmax=<value in bytes>" >> /etc/sysctl.conf

 

 

c) Increase the allowed number of memory mappings to at least 262144:

echo "vm.max_map_count=262144" >> /etc/sysctl.conf
echo 262144 > /proc/sys/vm/max_map_count

Notes:

Aerospike allocates an amount of shared memory equal to the total size of the persistence layer. The number of shared memory segments, called stripes, will be equal to the total number of files or the total number of the SSD device partitions for this namespace. The size of the persistence layer is defined as either the value of the filesize option multiplied by the number of files, or the total storage space of the SSD device partitions for this namespace. Each stripe size is also equal to the filesize option or to the size of a respective SSD device partition. This is because starting with Database 7.0 the in-memory data of the namespace is mirrored to the persistence layer; your capacity planning should reflect a 1:1 ratio between the sizes of memory storage and persistent storage for the namespace.

 


Applies To Earliest Version

7.2

Applies To Latest Version

Current Version
Was this article helpful?
0 out of 0 found this helpful