Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

open file descriptor limits not updating or being overridden #1576

Closed
ghost opened this issue Jan 7, 2017 · 15 comments
Closed

open file descriptor limits not updating or being overridden #1576

ghost opened this issue Jan 7, 2017 · 15 comments
Labels

Comments

@ghost
Copy link

ghost commented Jan 7, 2017

Windows Version: Microsoft Windows [Version 10.0.14393]

Appending session required pam_limits.so to the /etc/pam.d/common-session and /etc/pam.d/common-session-noninteractive files, and then updating the /etc/security/limits.conf by appending:

*              soft     nofile          35000
*              hard     nofile          35000

and restarting Windows, still does not actually update the ulimit -n value (or ulimit -Hn). It is stuck at 2048 and I am wondering if it can even be changed or if it is being overridden by some process manager, script, or the like?

@stehufntdev
Copy link
Collaborator

Thanks for reporting the issue. Most of the limits are not currently supported, but we are tracking the work. Please give us feedback for this scenario on uservoice so we can prioritize - https://wpdev.uservoice.com/forums/266908-command-prompt-console-bash-on-ubuntu-on-windo/category/161892-bash.

@hcldan
Copy link

hcldan commented Feb 10, 2017

So I just ran into this today as well.

I found that with those settings, I could do

su - myusername

and for that session the ulimit would be set according to limits.conf

I don't want to have to do that all the time though...

@ghost
Copy link
Author

ghost commented Feb 11, 2017

Starting a session with su - myusername only allowed me to change ulimit -n if I decreased it less than it's current value (whatever it's current value is set at). I was not able to ever increase the value. So, this must be some sort of bug?

For example, ulimit -n defaults at 2048, but after setting ulimit -n 2000 I am no longer able to change the value to anything greater than 2000.

EDIT: Lol, in fact I can set the ulimit -n lower without using su. Perhaps, I didn't understand what exactly you are doing @ddumontatibm

@sunilmut
Copy link
Member

sunilmut commented Mar 2, 2017

@ddumontatibm - Thanks for your post. Can you please describe your scenario that is blocked by this? Also, as per @stehufntdev, please open a user voice ticket if you would like us to prioritize it.

@hcldan
Copy link

hcldan commented Mar 2, 2017

@sunilmut Sure.

I'm using bash on windows to try to build a project with node and webpack. There are many file that are opened during that process. Even with my workaround to set limits in conf files and use su, I was unable to complete the build due to file limit.

@DachuanZhao
Copy link

any processing ?

@pecigonzalo
Copy link

@stehufntdev that link no longer works, could you update on the status of this? Its related to #633.

@pecigonzalo
Copy link

pecigonzalo commented Jun 14, 2020

I just found a "better" workaround.

We can use prlimit -p PID to set limits for other processes, if we allow that command (or wrap it in a script to further secure it) and execute it with sudo at init, we can effectively change the limits for the running shell.

EG:

❯ prlimit -p "$$"
RESOURCE   DESCRIPTION                             SOFT      HARD UNITS
AS         address space limit                unlimited unlimited bytes
CORE       max core file size                         0 unlimited bytes
CPU        CPU time                           unlimited unlimited seconds
DATA       max data size                      unlimited unlimited bytes
FSIZE      max file size                      unlimited unlimited bytes
LOCKS      max number of file locks held      unlimited unlimited locks
MEMLOCK    max locked-in-memory address space     65536     65536 bytes
MSGQUEUE   max bytes in POSIX mqueues            819200    819200 bytes
NICE       max nice prio allowed to raise             0         0
NOFILE     max number of open files                1024      4096 files
NPROC      max number of processes                31823     31823 processes
RSS        max resident set size              unlimited unlimited bytes
RTPRIO     max real-time priority                     0         0
RTTIME     timeout for real-time tasks        unlimited unlimited microsecs
SIGPENDING max number of pending signals          31823     31823 signals
STACK      max stack size                       8388608 unlimited bytes

$$ resolves to the current process PID

Then change it

sudo prlimit -p "$$" --nofile=10000:10000

And "reload" the shell

exec zsh

Verify

❯ prlimit -p "$$"
RESOURCE   DESCRIPTION                             SOFT      HARD UNITS
AS         address space limit                unlimited unlimited bytes
CORE       max core file size                         0 unlimited bytes
CPU        CPU time                           unlimited unlimited seconds
DATA       max data size                      unlimited unlimited bytes
FSIZE      max file size                      unlimited unlimited bytes
LOCKS      max number of file locks held      unlimited unlimited locks
MEMLOCK    max locked-in-memory address space     65536     65536 bytes
MSGQUEUE   max bytes in POSIX mqueues            819200    819200 bytes
NICE       max nice prio allowed to raise             0         0
NOFILE     max number of open files               10001     10001 files
NPROC      max number of processes                31823     31823 processes
RSS        max resident set size              unlimited unlimited bytes
RTPRIO     max real-time priority                     0         0
RTTIME     timeout for real-time tasks        unlimited unlimited microsecs
SIGPENDING max number of pending signals          31823     31823 signals
STACK      max stack size                       8388608 unlimited bytes

To make it permanent I added
sudo prlimit -p "$$" --nofile=10000:10000 to my ~/.zlogin and user ALL=(ALL) NOPASSWD: /usr/bin/prlimit somewhere in the sudoers.d folder

@therealkenc
Copy link
Collaborator

Support for ulimit -n was improved in 16257. Full support for ulimit and prlimit is available in WSL2. Ref #4575.

@istvan-ujjmeszaros
Copy link

@therealkenc if I run ubuntu2004 run "ulimit -n" then the result is still 1024 despite I have edited all the files that are mentioned in all the other related threads. I am on the Release Preview Channel. Can you double-check if this really is resolved?

@therealkenc
Copy link
Collaborator

image

@istvan-ujjmeszaros
Copy link

Doesn't seem to have an effect on ubuntu2004 run (unfortunately RubyMine is using this way to work with WSL and ending up in the Too many open files exception).
image

@therealkenc
Copy link
Collaborator

ubuntu2004 run "ulimit -n"

That outputs the limit of a different shell (with a different PID) than the one where you changed the limit with prlimit(1). That much is linux-behavior.

Assuming setting the limit in .profile, newspeak would be something like:

C:\> wsl.exe -d Ubuntu /bin/bash -lc "ulimit -n"

Some kind of placeholder feature request to make the default unlimited would probably not be out of line. Or yet another wsl.conf thingy. Absent a more complete resolution #994, anyway.

@istvan-ujjmeszaros
Copy link

That's looking like a possible workaround! But I am not sure if I can alter RubyMine to do the calls with these arguments. I will open a ticket at Jetbrains but it would be great if this hard-coded value could be changed somehow. Is it possible to rebuild the kernel or something like that?
image

@manugarri
Copy link

@therealkenc almost 2 years after the last message on this thread. I am still struggling to change ulimit, I have tried several options.

Only thing that seems to work is following @pecigonzalo prlimit suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants