Gemfire node fails with "Failed to start thread "Unknown thread" - pthread_create failed (EAGAIN) for attributes: stacksize: 1024k, guardsize: 4k, detached."
All supported Gemfire versions
The error pthread_create failed (EAGAIN) for attributes: stacksize: xxxxk. EAGAIN indicates that an OS per-process resource limit has been reached and is not the result of exhausted memory. In this scenario, the kernel returns an out-of-memory condition for that mapping, which the C library reports as EAGAIN, and which the JVM in turn surfaces as OutOfMemoryError: unable to create native thread: possibly out of memory or process/resource limits reached.
A large heap enabled with ZGC or Generational ZGC is more susceptible to this condition as its memory management strategy can easily push past the Linux default limit of 65,530 for vm.max_map_count .
A second, lower-probability contributor would be a per-account thread limit (ulimit -u) ; the EAGAIN error is also consistent with that condition.
This specific failure can be distinguished from heap or memory problems by the following signature:
While restarting the nodes will provide immediate relief, the resolution is to increase vm.max_map_count.
To permanently raise vm.max_map_count:
Log onto each of your cache server hosts as root and increase the mapping capacity. Since the max_map_count only represents the maximum limit and doesn't actively reserve memory from the OS, you can choose an upper limit as high as 2000000 for very large heaps. This provides ample headroom for large ZGC heaps and its active thread stacks.
Add or modify the configuration line inside /etc/sysctl.conf (or your configuration management directory /etc/sysctl.d/):
vm.max_map_count=2000000 Apply the setting immediately to the running kernel without a reboot:
sysctl -w vm.max_map_count=2000000