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

Rinda:RingServer not working (used for spork) #3883

Closed
MartinKoerner opened this issue May 12, 2016 · 8 comments · Fixed by #6595
Closed

Rinda:RingServer not working (used for spork) #3883

MartinKoerner opened this issue May 12, 2016 · 8 comments · Fixed by #6595

Comments

@MartinKoerner
Copy link

MartinKoerner commented May 12, 2016

I tried to use spork, but it showed me several errors related to Rinda:Ring (see below).

It worked on jruby 1.7.22...

Environment

$ jruby -v
jruby 9.1.0.0 (2.3.0) 2016-05-02 a633c63 Java HotSpot(TM) 64-Bit Server VM 25.20-b23 on 1.8.0_20-b26 +jit [darwin-x86_64]

# (also tried jruby 9.0.4.0)
$ uname -a
15.4.0 Darwin Kernel Version 15.4.0: Fri Feb 26 22:08:05 PST 2016; root:xnu-3248.40.184~3/RELEASE_X86_64 x86_64

Expected Behavior

Given a script containing this

require 'rinda/ring'
require 'rinda/tuplespace'
DRb.start_service

# Variant 1
Rinda::RingServer.new Rinda::TupleSpace.new

# Variant 2
Rinda::RingServer.new Rinda::TupleSpace.new, ['127.0.0.1']

puts "Ring server up and running"
DRb.thread.join if __FILE__ == $0

I would expect the output "Ring server up and running".

When I use gem install spork and run spork it should not show exceptions

Actual Behavior

When using Variant 1, I get the exception

TypeError: no implicit conversion of Fixnum into String
           initialize at org/jruby/ext/socket/Addrinfo.java:125
           initialize at org/jruby/ext/socket/Addrinfo.java:141
                  udp at org/jruby/ext/socket/Addrinfo.java:240
          make_socket at /usr/local/var/rbenv/versions/jruby-9.1.0.0/lib/ruby/stdlib/rinda/ring.rb:134
  block in initialize at /usr/local/var/rbenv/versions/jruby-9.1.0.0/lib/ruby/stdlib/rinda/ring.rb:110
                 each at org/jruby/RubyArray.java:1593
           initialize at /usr/local/var/rbenv/versions/jruby-9.1.0.0/lib/ruby/stdlib/rinda/ring.rb:106
                <top> at ring_server.rb:4

When using Variant 2, I get the exception

Errno::ENOPROTOOPT: Protocol not available - Protocol not available
           initialize at org/jruby/ext/socket/Addrinfo.java:125
           initialize at org/jruby/ext/socket/Addrinfo.java:141
                  udp at org/jruby/ext/socket/Addrinfo.java:240
          make_socket at /usr/local/var/rbenv/versions/jruby-9.1.0.0/lib/ruby/stdlib/rinda/ring.rb:134
  block in initialize at /usr/local/var/rbenv/versions/jruby-9.1.0.0/lib/ruby/stdlib/rinda/ring.rb:110
                 each at org/jruby/RubyArray.java:1593
           initialize at /usr/local/var/rbenv/versions/jruby-9.1.0.0/lib/ruby/stdlib/rinda/ring.rb:106
                <top> at ring_server.rb:4

spork cannot start any workers, because they can't connect to the Ring Server

@headius
Copy link
Member

headius commented May 12, 2016

I suspect both of these would be fixed by my socket branch, which is unfortunately still a work in progress. You might check it out... it's the ruby-2.3+socket branch and I updated it from master just a few days ago.

@MartinKoerner
Copy link
Author

Thanks for your fast reply.
I checked out the branch, compiled, and tried the examples from above. Unfortunately they don't work either, but the exceptions look a little bit different (and spork is failing with the first one):

# Variant 1
10:19 $ jruby -S ring_server.rb 
TypeError: no implicit conversion of Fixnum into String
                  udp at org/jruby/ext/socket/Addrinfo.java:503
          make_socket at /usr/local/var/rbenv/versions/jruby9100-socket/lib/ruby/stdlib/rinda/ring.rb:134
  block in initialize at /usr/local/var/rbenv/versions/jruby9100-socket/lib/ruby/stdlib/rinda/ring.rb:110
                 each at org/jruby/RubyArray.java:1593
           initialize at /usr/local/var/rbenv/versions/jruby9100-socket/lib/ruby/stdlib/rinda/ring.rb:106
                 at ring_server.rb:6
Exception in thread "Ruby-0-Thread-1: /usr/local/var/rbenv/versions/jruby9100-socket/lib/ruby/stdlib/drb/drb.rb:1539" java.nio.channels.ClosedSelectorException
        at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:83)
        at sun.nio.ch.SelectorImpl.selectNow(SelectorImpl.java:105)
        at org.jruby.util.io.SelectExecutor.selectEnd(SelectExecutor.java:63)
        at org.jruby.util.io.SelectExecutor.go(SelectExecutor.java:44)
        at org.jruby.RubyIO.select(RubyIO.java:3361)
        at org.jruby.RubyIO$INVOKER$s$0$3$select_DBG.call(RubyIO$INVOKER$s$0$3$select_DBG.gen)
        at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodN.call(JavaMethod.java:720)✘-1 
# Variant 2
10:19 $ jruby -S ring_server.rb 
Ring server up and running
Exception in thread "Ruby-0-Thread-2: /usr/local/var/rbenv/versions/jruby9100-socket/lib/ruby/stdlib/rinda/ring.rb:177" java.nio.channels.NotYetConnectedException
        at sun.nio.ch.DatagramChannelImpl.read(DatagramChannelImpl.java:555)
        at org.jruby.ext.socket.RubyBasicSocket.doRead(RubyBasicSocket.java:485)
        at org.jruby.ext.socket.RubyBasicSocket.recv(RubyBasicSocket.java:185)
        at org.jruby.ext.socket.RubyBasicSocket.recv(RubyBasicSocket.java:145)
        at org.jruby.ext.socket.RubyBasicSocket$INVOKER$i$recv_DBG.call(RubyBasicSocket$INVOKER$i$recv_DBG.gen)
        at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:313)
        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:163)
        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:55)
        at org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:301)
        at org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:77)
        at org.jruby.ir.interpreter.Interpreter.INTERPRET_BLOCK(Interpreter.java:132)
        at org.jruby.runtime.InterpretedIRBlockBody.commonYieldPath(InterpretedIRBlockBody.java:141)
        at org.jruby.runtime.IRBlockBody.yieldSpecific(IRBlockBody.java:77)
        at org.jruby.runtime.Block.yieldSpecific(Block.java:136)
        at org.jruby.RubyKernel.loop(RubyKernel.java:1290)
        at org.jruby.RubyKernel$INVOKER$s$0$0$loop_DBG.call(RubyKernel$INVOKER$s$0$0$loop_DBG.gen)
        at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodZeroBlock.call(JavaMethod.java:497)
        at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:273)
        at org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:79)
        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:83)
        at org.jruby.ir.instructions.CallBase.interpret(CallBase.java:423)
        at org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:348)
        at org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:77)
        at org.jruby.ir.interpreter.Interpreter.INTERPRET_BLOCK(Interpreter.java:132)
        at org.jruby.runtime.InterpretedIRBlockBody.commonYieldPath(InterpretedIRBlockBody.java:141)
        at org.jruby.runtime.IRBlockBody.call(IRBlockBody.java:66)
        at org.jruby.runtime.Block.call(Block.java:126)
        at org.jruby.RubyProc.call(RubyProc.java:342)
        at org.jruby.RubyProc.call(RubyProc.java:248)
        at org.jruby.internal.runtime.RubyRunnable.run(RubyRunnable.java:104)
        at java.lang.Thread.run(Thread.java:745)
^CException in thread "Ruby-0-Thread-1: /usr/local/var/rbenv/versions/jruby9100-socket/lib/ruby/stdlib/drb/drb.rb:1539" java.nio.channels.ClosedSelectorException
        at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:83)
        at sun.nio.ch.SelectorImpl.selectNow(SelectorImpl.java:105)

@headius
Copy link
Member

headius commented May 13, 2016

Ok. We are wrapping up 9.1.1.0 to get some quick fixes out for 9.1, but then we can start to look into this together. It may be a good example case to get socket work finished.

Make sure you've provided everything I need to reproduce this. If you want to start looking into it yourself, socket classes are here: https://github.com/jruby/jruby/tree/ruby-2.3+socket/core/src/main/java/org/jruby/ext/socket

@MartinKoerner
Copy link
Author

Today I tested it with 9.1.3.0 and got the same exceptions. The socket-branch wasn't updated yet, so I didn't test it - if you update it from master, I can repeat the test there.
As you probably can tell, I didn't dive into the socket sources and unfortunately I won't have time to do it now, too...

@headius
Copy link
Member

headius commented Sep 6, 2016

This will definitely fall into the work @etehtsea is doing to help us get socket logic up-to-date.

@headius headius added this to the JRuby 9.2.0.0 milestone Sep 6, 2016
@headius
Copy link
Member

headius commented May 15, 2018

This is still a problem on master, but won't get into 9.2 release.

If we can do a one-off fix, it could get into 9.2.1. But I suspect this may need the BIG move of switching to an FFI-based socket library.

@headius headius modified the milestones: JRuby 9.2.0.0, JRuby 9.2.1.0 May 15, 2018
@headius
Copy link
Member

headius commented Sep 19, 2018

Still a problem in 9.2.1 and I don't think we're going to have cycles to investigate it.

The error is largely the same, modulo the move away from Fixnum in Ruby 2.5 (JRuby 9.2):

[] ~/projects/jruby $ jruby ringda.rb 
TypeError: no implicit conversion of Integer into String
          udp at org/jruby/ext/socket/Addrinfo.java:337
  make_socket at /Users/headius/projects/jruby/lib/ruby/stdlib/rinda/ring.rb:133
   initialize at /Users/headius/projects/jruby/lib/ruby/stdlib/rinda/ring.rb:109
         each at org/jruby/RubyArray.java:1802
   initialize at /Users/headius/projects/jruby/lib/ruby/stdlib/rinda/ring.rb:105
       <main> at ringda.rb:6

@kares kares modified the milestones: JRuby 9.2.8.0, JRuby 9.3.0.0 Aug 19, 2019
@headius
Copy link
Member

headius commented Mar 5, 2021

Circling back to this after several years.

Good news: variant 2 appears to work now and the ring server starts up.

Variant 1 still fails due to Rinda passing in a numeric host of 0 and us not knowing what to do with that.

headius added a commit to headius/jruby that referenced this issue Mar 5, 2021
Numeric hosts can be converted to a byte sequence for address
lookup.

Fixes jruby#3883
@headius headius modified the milestones: JRuby 9.3.0.0, JRuby 9.2.18.0 Jun 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants