Summary: | ASTERISK-24011: [patch]safe_asterisk tries to set ulimit -n too high on linux systems with lots of RAM | ||||
Reporter: | Michael Myles (xdrive) | Labels: | |||
Date Opened: | 2014-07-09 11:54:44 | Date Closed: | 2014-10-09 03:04:41 | ||
Priority: | Minor | Regression? | |||
Status: | Closed/Complete | Components: | Contrib/General | ||
Versions: | Frequency of Occurrence | ||||
Related Issues: |
| ||||
Environment: | Attachments: | ( 0) safe_asterisk-ulimit.diff | |||
Description: | It appears the safe_asterisk script tries to increase the open file limit based on the value in /proc/sys/fs/file-max divided by 2. In some modern linux systems this value is calculated based on the amount of RAM available and turns out to be roughly 100 per 1MB of RAM.
see: fs/file_table.c in linux kernel /* * One file with associated inode and dcache is very roughly 1K. * Per default don't use more than 10% of our memory for files. */ n = (mempages * (PAGE_SIZE / 1024)) / 10; files_stat.max_files = max_t(unsigned long, n, NR_FILE); On systems with lots of RAM, (In our case a CentOS 6.4 server with 24GB of RAM) this number / 2 can exceed the upper limit which can actually be set per process (2^20=1048576) This causes the safe_asterisk script to fail to increase the max number of open files and ulimit to display the error: "open files: cannot modify limit: Operation not permitted" Suggest adding an upper bound check to the script to ensure that the value/2 is not above the maximum. | ||||
Comments: | By: Matt Jordan (mjordan) 2014-07-10 09:16:07.271-0500 If you'd like to contribute a patch that would check for said upper limit, that would be appreciated. By: Michael Myles (xdrive) 2014-07-10 10:01:14.680-0500 Attaching patch. This just caps MAXFILES at 2^20 which is probably still far higher than would ever be necessary or sane, but should at least prevent safe_asterisk from exceeding the absolute maximum in most implementations. By: Rusty Newton (rnewton) 2014-07-11 16:41:01.831-0500 Michael can you reattach your patch. I see it linked in the description, but I don't see it attached. You may have attached it before your license was processed. Use the More > Attach Files dialog and make sure to select Code Contribution. By: Michael Myles (xdrive) 2014-07-14 08:16:31.684-0500 Reattached. You're right, I added that before my license was processed, but Jira still allowed me to link to the uploaded file despite not listing it as an attachment. By: Rusty Newton (rnewton) 2014-08-01 16:42:10.830-0500 Thanks. I also removed the old attachments. If you want to walk your patch through the rest of the contribution process, you can throw it on Reviewboard as well and then edit this issue to add the Reviewboard link URL. [Patch contribution process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process] By: Walter Doekes (wdoekes) 2014-08-21 05:13:11.330-0500 Good fix, although you shouldn't use {{>}} to compare, but {{-gt}}. |