Bug #48120 proxy doesn't increase the hard limit when max-open-files is used
Submitted: 16 Oct 18:06
Reporter: Matthew Lord
Status: Verified
Category:Proxy Severity:S3 (Non-critical)
Version:2.0.x, 2.1.x OS:Any (doesn't affect windows )
Assigned to: MEM Agent Devs Target Version:
Tags: rlimit, open files

[16 Oct 18:06] Matthew Lord
Description:
I would like to see us increase the soft _and_ hard limit for open files when
max-open-files is specified (this is what mysqld_safe does with it's unlimit -n X system
call).

This would help to completely eliminate the common problem of running out of 
available FDs and encountering the "all backends are down" errors.

Increasing the hard limit shouldn't be a problem since we're running as root 
when we make the setrlimit call.  This will avoid the need to mess with anything
else, such as /etc/security/limits.conf on linux, in order to increase the
open files limit beyond the default soft limit (which was 4,000 on my linux
machine).

How to repeat:
N/A

Suggested fix:
--- chassis.c   2009-10-14 17:44:12.000000000 -0400
+++ chassis-mlord.c     2009-10-16 12:05:10.000000000 -0400
@@ -1091,9 +1091,12 @@
                                  G_STRLOC, g_strerror(errno), errno);
        } else {
                rlim_t soft_limit = max_files_rlimit.rlim_cur;
+               rlim_t hard_limit = max_files_rlimit.rlim_max;
+
                g_debug("%s: current RLIMIT_NOFILE = %llu (hard: %llu)", G_STRLOC,
max_files_rlimit.rlim_cur, max_files_rlimit.rlim_max);
 
                max_files_rlimit.rlim_cur = max_files_number;
+               max_files_rlimit.rlim_max  = max_files_number;
 
                g_debug("%s: trying to set new RLIMIT_NOFILE = %llu (hard: %llu)",
G_STRLOC, max_files_rlimit.rlim_cur, max_files_rlimit.rlim_max);
                if (-1 == setrlimit(RLIMIT_NOFILE, &max_files_rlimit)) {