getmango / Mango

Mango is a self-hosted manga server and web reader
https://getmango.app
MIT License
1.72k stars 123 forks source link

[Bug Report] Error causing high CPU usage and filling hard drive with logging. #89

Open DuraMorte opened 4 years ago

DuraMorte commented 4 years ago

Describe the bug Jul 09 14:58:56 mango[5177]: accept: No file descriptors available (Socket::Error) Jul 09 14:58:56 mango[5177]: from ???

This message repeats hundreds of times a second. It is causing the syslog to fill the hard drive after a few minutes, and the mango process is utilizing a large partion of the VM's CPU.

To Reproduce I'm not sure what is causing the error, so I cannot explain how to reproduce it.

Environment (please complete the following information):

hkalexling commented 4 years ago

Linux limits the number of open file descriptors. It looks like some process on your machine (might or might not be Mango itself) is opening a lot of files without properly closing them.

Can you use pidof mango to find the process ID of Mango, and then run ls -l /proc/[pid]/fd | wc -l to see the number of file descriptors opened by Mango?

For example, on my system, ls -l /proc/22783/fd | wc -l gives 11.

hkalexling commented 4 years ago

It would be great if you could show me the output of cat /proc/[pid]/limits as well.

DuraMorte commented 4 years ago

The first command returns about 150.

The second command's output is as follows.

Limit Soft Limit Hard Limit Units Max cpu time unlimited unlimited seconds Max file size unlimited unlimited bytes Max data size unlimited unlimited bytes Max stack size 8388608 unlimited bytes Max core file size 0 unlimited bytes Max resident set unlimited unlimited bytes Max processes 31645 31645 processes Max open files 1024 4096 files Max locked memory 16777216 16777216 bytes Max address space unlimited unlimited bytes Max file locks unlimited unlimited locks Max pending signals 31645 31645 signals Max msgqueue size 819200 819200 bytes Max nice priority 0 0 Max realtime priority 0 0 Max realtime timeout unlimited unlimited us

Could this issue be related to running a torrent client on this same VM?

DuraMorte commented 4 years ago

The issue has happened; my syslog has taken over the entire drive, and the first command shows 554.

What should I try?

hkalexling commented 4 years ago

The first command gives you the number of file descriptors opened by Mango, and this line in the second command output

Max open files 1024 4096 files

is saying that your system allows the Mango process to have 1024 files opened. In both cases, the number is lower than the 1024 limit. Do you know what triggers the error? Did this happen when you were reading a manga, or did it happen when Mango is scanning the library?

When it happens again, could you run the following commands to help diagnose the problem?

Thanks!