Troubleshooting TNS-12531 (TNS:Cannot Allocate Memory Error)
With this post I would like to share some troubleshooting information regarding TNS-12531. Today I received call to check one of the servers because the database was not accessible, when I logged on and checked the space available on the file system I was surprised to see the LVM mount point intended for oracle to be 100% full. When I checked what was causing the disk to fill it turned out to be the listener xml log files. Oracle was generating TNS-12531: TNS:cannot allocate memory error messages as crazy.
The tnslsnr process was stuck and those few times that I tried to start the listener I was waiting forever on Starting /u01/app/grid/product/12.1.0/grid/bin/tnslsnr: please wait…
If you see the definition for TNS-12531 it says it’s due to insufficient memory/resources and most of the solutions are related to resource/memory configuration. But, that was not the problem this time because the server had enough memory. I’ve configured tracing for the listener in order to see in more details what was causing the error.
I’ve set TRACE_LEVEL_listener_name and tried to start the listener in order to populate the trace file. This is some of the output from listener.trc
As you can there was an error for gettaddrinfo() with error number -2, getaddrinfo() is used for network address and service translation and if it succeeds will return 0, otherwise will return error code number. Error codes for getaddrinfo() can be found in netdb.h stored in /usr/include where header files for C compiler are stored. I’ve ran grep to find the error code which is EAI_NONAME.
The description for EAI_NONAME is: The node or service is not known; or both node and service are NULL; or AI_NUMERICSERV was specified in hints.ai_flags and service was not a numeric port-number string.
By node it means hostname, when I checked the definition for hostname I found the problem, which in this case it turned out to be hostname definition which was different from the ip-hostname definition in /etc/hosts. It was clear where the problem was, after fixing the hostname definition the listener started successfully.