From: sdemjanenko@gmail.com To: unicorn-public@bogomips.org Cc: Stephen Demjanenko <sdemjanenko@gmail.com> Subject: [PATCH] Rescue failed pipe resizes due to permissions Date: Fri, 3 May 2019 15:20:18 -0700 Message-ID: <1556922018-24096-1-git-send-email-sdemjanenko@gmail.com> (raw) From: Stephen Demjanenko <sdemjanenko@gmail.com> When running: ``` require 'kgio' require 'raindrops' F_SETPIPE_SZ = 1031 if RUBY_PLATFORM =~ /linux/ Kgio::Pipe.new.each do |io| io.close_on_exec = true if defined?(F_SETPIPE_SZ) begin puts "setting" io.fcntl(F_SETPIPE_SZ, Raindrops::PAGE_SIZE) rescue Errno::EINVAL puts "rescued" rescue => e puts ["FAILED HARD", e].inspect end end end ``` on a few servers to test some Unicorn boot failures I saw: ``` ["FAILED HARD", #<Errno::EPERM: Operation not permitted>] ``` The `EPERM` error gets raised by the Linux kernel if: ``` (too_many_pipe_buffers_hard(pipe->user) || too_many_pipe_buffers_soft(pipe->user)) && !capable(CAP_SYS_RESOURCE) && !capable(CAP_SYS_ADMIN) ``` Given that the resize is not strictly necessary Unicorn should rescue the error and continue booting. --- lib/unicorn.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/unicorn.rb b/lib/unicorn.rb index 5f2134d..dd5dff4 100644 --- a/lib/unicorn.rb +++ b/lib/unicorn.rb @@ -123,6 +123,9 @@ def self.pipe # :nodoc: io.fcntl(F_SETPIPE_SZ, Raindrops::PAGE_SIZE) rescue Errno::EINVAL # old kernel + rescue Errno::EPERM + # resizes fail if Linux is close to the pipe limit for the user + # or if the user does not have permissions to resize end end end -- 2.7.4
next reply other threads:[~2019-05-03 22:20 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-05-03 22:20 sdemjanenko [this message] 2019-05-03 22:53 ` Eric Wong
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style List information: https://yhbt.net/unicorn/ * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1556922018-24096-1-git-send-email-sdemjanenko@gmail.com \ --to=sdemjanenko@gmail.com \ --cc=unicorn-public@bogomips.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help This inbox may be cloned and mirrored by anyone: git clone --mirror https://yhbt.net/unicorn-public git clone --mirror http://ou63pmih66umazou.onion/unicorn-public # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V1 unicorn-public unicorn-public/ https://yhbt.net/unicorn-public \ unicorn-public@yhbt.net unicorn-public@bogomips.org mongrel-unicorn@rubyforge.org mongrel-unicorn-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org public-inbox-index unicorn-public Example config snippet for mirrors. Newsgroups are available over NNTP: nntp://news.public-inbox.org/inbox.comp.lang.ruby.unicorn nntp://ou63pmih66umazou.onion/inbox.comp.lang.ruby.unicorn note: .onion URLs require Tor: https://www.torproject.org/ code repositories for the project(s) associated with this inbox: ../../unicorn.git AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git