Closed alexanderdean closed 9 years ago
Update, I've managed to reproduce the error without Sluice involved:
jruby-1.7.11 :008 > files_to_process = []
=> []
jruby-1.7.11 :009 > files_to_process.size
=> 0
jruby-1.7.11 :011 > files_to_process = my_fog.directories.get(in_l.bucket, :prefix => in_l.dir).files.all({})
=> <Fog::Storage::AWS::Files
<snip>
jruby-1.7.11 :013 > file = files_to_process.pop
=> <Fog::Storage::AWS::File
<snip>
jruby-1.7.11 :025 > files_to_process.size
=> 5
jruby-1.7.11 :026 > files_to_process = files_to_process.reverse
ArgumentError: service and directory are required for this operation
from /home/vagrant/.rvm/gems/jruby-1.7.11/gems/fog-core-1.22.0/lib/fog/core/attributes.rb:188:in `requires'
from /home/vagrant/.rvm/gems/jruby-1.7.11/gems/fog-1.22.0/lib/fog/aws/models/storage/files.rb:23:in `all'
from /home/vagrant/.rvm/gems/jruby-1.7.11/gems/fog-core-1.22.0/lib/fog/core/collection.rb:139:in `lazy_load'
from /home/vagrant/.rvm/gems/jruby-1.7.11/gems/fog-core-1.22.0/lib/fog/core/collection.rb:22:in `empty?'
from /home/vagrant/.rvm/gems/jruby-1.7.11/gems/fog-core-1.22.0/lib/fog/core/collection.rb:84:in `inspect'
from /home/vagrant/.rvm/gems/jruby-1.7.11/gems/formatador-0.2.4/lib/formatador.rb:92:in `indent'
from /home/vagrant/.rvm/gems/jruby-1.7.11/gems/fog-core-1.22.0/lib/fog/core/collection.rb:77:in `inspect'
from org/jruby/RubyProc.java:271:in `call'
from org/jruby/RubyKernel.java:1521:in `loop'
from org/jruby/RubyKernel.java:1284:in `catch'
from org/jruby/RubyKernel.java:1284:in `catch'
from /home/vagrant/.rvm/rubies/jruby-1.7.11/bin/irb:13:in `(root)'
Update 2, this works:
jruby-1.7.11 :030 > files_to_process = files_to_process.to_a.reverse
=> [ <Fog::Storage::AWS::File
<snip>
My conclusion is that there's something in the abstraction from a Ruby Array into a Fog Files via a Fog Collection which is leaky, and the leak is only evident in JRuby.
Is this evident in other operations or just reverse? It seems to be an odd interaction with whether or not @loaded (and other instance variables, for that matter) are loaded. Are you doing operations across threads or otherwise where this state might be off?
Originally I was doing a lot inside of threads, but then I was able to reproduce it just in JRuby irb
(in Update 1). All a bit odd
Indeed. It must be interacting strangely with the lazy loading stuff, but then trying to fetch the data in a context in which the credentials and connection are no longer in scope. Haven't heard other's run in to this. Since you see it in irb, perhaps it is a broader JRuby related issue. How isolated of an example can you get to produce the behavior in irb?
Closing due inactivity. Please create a new issue at fog-aws if this stills need to be tackled.
Thanks!
I am the author of Sluice which uses fog to perform lots of file operations on S3.
It works fine in Ruby, but in JRuby file ops involving Arrays of
Fog::Storage::AWS::File
s are erroring out with "error: org.jruby.embed.EvalFailedException: (ArgumentError) service and directory are required for this operation".Here are full steps to reproduce:
The exact same code works fine in Ruby.
Any idea why JRuby would be struggling with Arrays of Fog Files in a way that vanilla Ruby does not?