Details
-
Type:
Bug
-
Status:
Reopened
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: JRuby 1.6.4, JRuby 1.6.5
-
Fix Version/s: None
-
Component/s: Miscellaneous
-
Labels:None
-
Environment:I reproduced this on Ubuntu 11.10 and on an older CentOS 5.6 with JRuby 1.6.3 and JRuby 1.6.5
-
Number of attachments :
Description
Hi,
I hope that I'm wrong, but at the moment this looks like a serious bug to me, but maybe I just didn't do enough RTFM. I found this bug when using ActionMailer with sendmail. The "/usr/sbin/sendmail" process was only sometimes called and sometimes it wasn't (most often it wasn't but around every tenth time it suddenly worked)
I investigated it deeply and after hours I distilled it down to the following:
hk@hk:~$ rvm use jruby ruby -e "cmd='/bin/bash -c \"sleep 5\"'; puts Time.now ; system(cmd); puts Time.now; IO.popen(cmd) {} ; puts Time.now "
Wed Oct 26 16:37:08 +0200 2011
Wed Oct 26 16:37:13 +0200 2011
Wed Oct 26 16:37:13 +0200 2011
hk@hk:~$ rvm use 1.8.7 ruby -e "cmd='/bin/bash -c \"sleep 5\"'; puts Time.now ; system(cmd); puts Time.now; IO.popen(cmd) {} ; puts Time.now "
Wed Oct 26 16:37:18 +0200 2011
Wed Oct 26 16:37:23 +0200 2011
Wed Oct 26 16:37:28 +0200 2011
hk@hk:~$
As one can see, the system call on both Ruby Interpreters waits until the subprocess exits. But with MRI it also stops when using IO.popen, but not with JRuby. Here it returns immediately.
I found a very ugly workaround for the moment by doing something like the following:
module ActionMailer
class Base
def perform_delivery_sendmail(mail)
sendmail_args = sendmail_settings[:arguments]
sendmail_args += " -f \"#{mail['return-path']}\"" if mail['return-path']
IO.popen("#{sendmail_settings[:location]} #{sendmail_args}", "r+") do |f| #r+ geht, w+ geht nicht richtig, bzw. nur manchmal
f.puts mail.encoded.gsub(/\r/, '')
f.close_write
sleep 1 # <---- added this line in order to give sendmail some time to process
end
end
end
end
Here are some environment infos:
hk@hk:~$ rvm info jruby
jruby-1.6.5:
system:
uname: "Linux hk 3.0.0-12-generic #20-Ubuntu SMP Fri Oct 7 14:56:25 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux"
bash: "/bin/bash => GNU bash, Version 4.2.10(1)-release (x86_64-pc-linux-gnu)"
zsh: " => not installed"
rvm:
version: "rvm 1.9.0 by Wayne E. Seguin (wayneeseguin@gmail.com) [https://rvm.beginrescueend.com/]"
ruby:
interpreter: "jruby"
version: "1.6.5"
date: "2011-10-25"
platform: "linux-amd64-java"
patchlevel: "OpenJDK 64-Bit Server VM 1.6.0_23"
full_version: "jruby 1.6.5 (ruby-1.8.7-p330) (2011-10-25 9dcd388) (OpenJDK 64-Bit Server VM 1.6.0_23) [linux-amd64-java]"
homes:
gem: "/home/hk/.rvm/gems/jruby-1.6.5"
ruby: "/home/hk/.rvm/rubies/jruby-1.6.5"
binaries:
ruby: "/home/hk/.rvm/rubies/jruby-1.6.5/bin/ruby"
irb: "/home/hk/.rvm/rubies/jruby-1.6.5/bin/irb"
gem: "/home/hk/.rvm/rubies/jruby-1.6.5/bin/gem"
rake: "/home/hk/.rvm/gems/jruby-1.6.5/bin/rake"
environment:
PATH: "/home/hk/.rvm/gems/jruby-1.6.5/bin:/home/hk/.rvm/gems/jruby-1.6.5@global/bin:/home/hk/.rvm/rubies/jruby-1.6.5/bin:/home/hk/.rvm/bin:<other stuff>"
GEM_HOME: "/home/hk/.rvm/gems/jruby-1.6.5"
GEM_PATH: "/home/hk/.rvm/gems/jruby-1.6.5:/home/hk/.rvm/gems/jruby-1.6.5@global"
MY_RUBY_HOME: "/home/hk/.rvm/rubies/jruby-1.6.5"
IRBRC: "/home/hk/.rvm/rubies/jruby-1.6.5/.irbrc"
RUBYOPT: ""
gemset: ""
hk@hk:~$
hk@hk:~$ rvm info 1.8.7
ruby-1.8.7-p352:
system:
uname: "Linux hk 3.0.0-12-generic #20-Ubuntu SMP Fri Oct 7 14:56:25 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux"
bash: "/bin/bash => GNU bash, Version 4.2.10(1)-release (x86_64-pc-linux-gnu)"
zsh: " => not installed"
rvm:
version: "rvm 1.9.0 by Wayne E. Seguin (wayneeseguin@gmail.com) [https://rvm.beginrescueend.com/]"
ruby:
interpreter: "ruby"
version: "1.8.7"
date: "2011-06-30"
platform: "x86_64-linux"
patchlevel: "2011-06-30 patchlevel 352"
full_version: "ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]"
homes:
gem: "/home/hk/.rvm/gems/ruby-1.8.7-p352"
ruby: "/home/hk/.rvm/rubies/ruby-1.8.7-p352"
binaries:
ruby: "/home/hk/.rvm/rubies/ruby-1.8.7-p352/bin/ruby"
irb: "/home/hk/.rvm/rubies/ruby-1.8.7-p352/bin/irb"
gem: "/home/hk/.rvm/rubies/ruby-1.8.7-p352/bin/gem"
rake: "/home/hk/.rvm/gems/ruby-1.8.7-p352/bin/rake"
environment:
PATH: "/home/hk/.rvm/gems/ruby-1.8.7-p352/bin:/home/hk/.rvm/gems/ruby-1.8.7-p352@global/bin:/home/hk/.rvm/rubies/ruby-1.8.7-p352/bin:<other stuff>"
GEM_HOME: "/home/hk/.rvm/gems/ruby-1.8.7-p352"
GEM_PATH: "/home/hk/.rvm/gems/ruby-1.8.7-p352:/home/hk/.rvm/gems/ruby-1.8.7-p352@global"
MY_RUBY_HOME: "/home/hk/.rvm/rubies/ruby-1.8.7-p352"
IRBRC: "/home/hk/.rvm/rubies/ruby-1.8.7-p352/.irbrc"
RUBYOPT: ""
gemset: ""
hk@hk:~$
This bug might be similar or related to JRUBY-5416 and/or
JRUBY-5710