The question:
I have a tomcat running a java application that occasionally accumulates socket handles and reaches the ulimit we configured (both soft and hard) for max-open-files, which is 100K. When this happens, the java appears to still be alive, but we can no longer access it.
However my question is about a bizarre phenomenon that accompanies this situation: I cannot mkdir
inside the tomcat folder.
[root@server /opt/apache-tomcat-7.0.52]# mkdir some_folder
mkdir: cannot create directory `some_folder': No space left on device
In fact, I get the same error under multiple different folders that reside under /opt
, but not under /opt
directly, and not - for example - under /opt/apache-tomcat-7.0.52/logs
.
I can't explain it for the life of me, and can only resolve using init 6
. Any suggestions on how to fix the issue and be able to mkdir
again without restart?
Some pointers and clues that I've gathered:
The setup is CentOS 6.5 running under AWS with the said tomcat disk mounted from an EBS volume.
Running df -h
shows that the disk is evidently not full:
[root@server ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 9.9G 3.6G 5.9G 38% /
none 121G 0 121G 0% /dev/shm
/dev/xvdc 1008G 197G 760G 19% /mnt/eternal
Contents of /etc/fstab
(which, for some reason, use double mounting - not sure why):
/dev/xvdc /mnt/eternal ext4 defaults 0 0
/mnt/eternal /opt ext4 defaults,bind 0 0
And appropriate lines from mount
:
/dev/xvdc on /mnt/eternal type ext4 (rw)
/mnt/eternal on /opt type none (rw,bind)
Running df -i
doesn't hint at something bad (and is similar to a healthy system):
[root@server ~]# df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/xvda1 655360 78245 577115 12% /
none 31549847 1 31549846 1% /dev/shm
/dev/xvdc 67108864 12551 67096313 1% /mnt/eternal
Running sysctl fs.file-nr
gives this result which is evidently high but seems far from the limit:
[root@server ~]# sysctl fs.file-nr
fs.file-nr = 101632 0 25087252
Running find /proc | wc -l
returns 62497876
(62M), which could reach some OS limit; on a similar healthy system it's more like 1800000 (1.8M).
The hugely occupied subfolder appears to be /proc/<my-java-pid>/task
(~62M items compared to ~1.7M on the healthy system). This is likely just a reflection of my 100K fds (x2, for both fds and fdinfos) over 300 individual "task" folders.
This appears at the end of my dmesg dump (my java pid in this example is 105940) - not sure how this might relate:
INFO: task java:105940 blocked for more than 120 seconds.
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
java D 0000000000000008 0 105940 1 0x00000080
ffff88161ab55c88 0000000000000082 ffff88161ab55c18 ffffffff8109be4f
ffffffff81ed28f0 ffff881e66360ae0 ffffffff8100bb8e ffff88161ab55c88
ffff881e66361098 ffff88161ab55fd8 000000000000fb88 ffff881e66361098
Call Trace:
[<ffffffff8109be4f>] ? hrtimer_try_to_cancel+0x3f/0xd0
[<ffffffff8100bb8e>] ? apic_timer_interrupt+0xe/0x20
[<ffffffff810521c9>] ? mutex_spin_on_owner+0x99/0xc0
[<ffffffff8151636e>] __mutex_lock_slowpath+0x13e/0x180
[<ffffffff8151620b>] mutex_lock+0x2b/0x50
[<ffffffff8111c461>] generic_file_aio_write+0x71/0x100
[<ffffffffa0121fb1>] ext4_file_write+0x61/0x1e0 [ext4]
[<ffffffff81180d7a>] do_sync_write+0xfa/0x140
[<ffffffff81096ca0>] ? autoremove_wake_function+0x0/0x40
[<ffffffff812292ab>] ? selinux_file_permission+0xfb/0x150
[<ffffffff8121bd26>] ? security_file_permission+0x16/0x20
[<ffffffff81181078>] vfs_write+0xb8/0x1a0
[<ffffffff81181971>] sys_write+0x51/0x90
[<ffffffff81517e2e>] ? do_device_not_available+0xe/0x10
[<ffffffff8100b072>] system_call_fastpath+0x16/0x1b
I would be happy to share/provide any other suggested findings.
Secretly I hope that understanding this weird behavior would shed light on the pathology causing this whole mess. But, that's just my private hope :)