Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Stephen Betts
@thisisstephenbetts
Modified to this ActiveGraph::Base.query("MATCH (n:ModelVersion) RETURN n") and get the same error
Heinrich Klobuczek
@klobuczek
can you query with neo4j browser?
Stephen Betts
@thisisstephenbetts
Yup
No error message; response is (no changes, no records) which is as expected
Both MATCH (n:ModelVersion) DELETE n and MATCH (n:ModelVersion) RETURN n seemed to work just fine
though did nothing
Heinrich Klobuczek
@klobuczek
is it easy for you to switch to jruby just for testing? If so then replace the neo4j-ruby-driver with neo4j-java-driver gem.
the other driver is likely to have better error messages
Stephen Betts
@thisisstephenbetts
I won't be able to do that tonight. I'll give it a go and check back in.
In the meantime, do you know what the error parameters there imply? No problem if not, just interested
Thanks for looking into this — we appreciate it!
Heinrich Klobuczek
@klobuczek
This an error from the socket library we don’t know how to interpret. I bet this is something simple with the server set up and not intuitivelly related to the error message.
What scheme are you using? neo4j, bolt?
Stephen Betts
@thisisstephenbetts
I was using bolt. Will try with neo4j, and after that jruby
No change at all in switching to neo4j scheme
Stephen Betts
@thisisstephenbetts
Okay, despite my first impressions, jruby has the same problem:
`` Neo4j::Driver::Exceptions::SessionExpiredException: code:fff, error:4, state:4, error_context:plain_socket_send(/tmp/seabolt-20201020-8099-19eti4h/seabolt-1.7.4/src/seabolt/src/bolt/communication-plain.c:231), send error code: 32/Users/stephenbetts/.gem/jruby/2.5.7/gems/neo4j-ruby-driver-1.7.2/ffi/neo4j/driver/internal/error_handling.rb:90:inthrow'
/Users/stephenbetts/.gem/jruby/2.5.7/gems/neo4j-ruby-driver-1.7.2/ffi/neo4j/driver/internal/error_handling.rb:95:in unqualified_error' /Users/stephenbetts/.gem/jruby/2.5.7/gems/neo4j-ruby-driver-1.7.2/ffi/neo4j/driver/internal/error_handling.rb:39:incheck_error'
/Users/stephenbetts/.gem/jruby/2.5.7/gems/neo4j-ruby-driver-1.7.2/ffi/neo4j/driver/internal/async/direct_connection.rb:40:in flush' /Users/stephenbetts/.gem/jruby/2.5.7/gems/neo4j-ruby-driver-1.7.2/ffi/neo4j/driver/internal/async/direct_connection.rb:52:incommit'
/Users/stephenbetts/.gem/jruby/2.5.7/gems/neo4j-ruby-driver-1.7.2/ffi/neo4j/driver/internal/messaging/v3/bolt_protocol_v3.rb:29:in commit_transaction' /Users/stephenbetts/.gem/jruby/2.5.7/gems/neo4j-ruby-driver-1.7.2/ffi/neo4j/driver/internal/explicit_transaction.rb:92:indo_commit'
/Users/stephenbetts/.gem/jruby/2.5.7/gems/neo4j-ruby-driver-1.7.2/ffi/neo4j/driver/internal/explicit_transaction.rb:77:in commit' /Users/stephenbetts/.gem/jruby/2.5.7/gems/neo4j-ruby-driver-1.7.2/ffi/neo4j/driver/internal/explicit_transaction.rb:48:inclose'
/Users/stephenbetts/.gem/jruby/2.5.7/gems/activegraph-10.0.1/lib/active_graph/transaction.rb:10:in close' /Users/stephenbetts/.gem/jruby/2.5.7/gems/neo4j-ruby-driver-1.7.2/lib/neo4j/driver/auto_closable.rb:21:inblock in begin_transaction'
/Users/stephenbetts/.gem/jruby/2.5.7/gems/activegraph-10.0.1/lib/active_graph/transactions.rb:43:in run_transaction_work' /Users/stephenbetts/.gem/jruby/2.5.7/gems/activegraph-10.0.1/lib/active_graph/transactions.rb:38:inblock in send_transaction'
/Users/stephenbetts/.gem/jruby/2.5.7/gems/neo4j-ruby-driver-1.7.2/lib/neo4j/driver/auto_closable.rb:19:in block in session' /Users/stephenbetts/.gem/jruby/2.5.7/gems/activegraph-10.0.1/lib/active_graph/transactions.rb:37:insend_transaction'
/Users/stephenbetts/.gem/jruby/2.5.7/gems/activegraph-10.0.1/lib/active_graph/transactions.rb:21:in transaction' /Users/stephenbetts/.gem/jruby/2.5.7/gems/activegraph-10.0.1/lib/active_graph/base.rb:33:inquery'
`` /Users/stephenbetts/WiP/nypl/subject-headings-explorer-poc/lib/shep/neo4j_csv_processor.rb:31:inwrite_model_version'
/Users/stephenbetts/WiP/nypl/subject-headings-explorer-poc/lib/tasks/graph.rake:55:in block in <main>' /Users/stephenbetts/WiP/nypl/subject-headings-explorer-poc/lib/tasks/graph.rake:86:inblock in <main>'
/Users/stephenbetts/.gem/jruby/2.5.7/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in kernel_load' /Users/stephenbetts/.gem/jruby/2.5.7/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:inrun'
/Users/stephenbetts/.gem/jruby/2.5.7/gems/bundler-2.1.4/lib/bundler/cli.rb:476:in exec' /Users/stephenbetts/.gem/jruby/2.5.7/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:inrun'
/Users/stephenbetts/.gem/jruby/2.5.7/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in invoke_command' /Users/stephenbetts/.gem/jruby/2.5.7/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:indispatch'
/Users/stephenbetts/.gem/jruby/2.5.7/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in dispatch' /Users/stephenbetts/.gem/jruby/2.5.7/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:instart'
/Users/stephenbetts/.gem/jruby/2.5.7/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in start' /Users/stephenbetts/.gem/jruby/2.5.7/gems/bundler-2.1.4/exe/bundle:46:inblock in <main>'
/Users/stephenbetts/.gem/jruby/2.5.7/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in with_friendly_errors' /Users/stephenbetts/.gem/jruby/2.5.7/gems/bundler-2.1.4/exe/bundle:34:in<main>'
/Users/stephenbetts/.gem/jruby/2.5.7/bin/bundle:23:in `<main>'
Tasks: TOP => graph:reset_load_csv => graph:reset_csv
(See full trace by running task with --trace)
Heinrich Klobuczek
@klobuczek
I meant jruby with neo4j-java-driver gem
Replace neo4j-ruby-driver with neo4j-java-driver in your Gemfile
Stephen Betts
@thisisstephenbetts
Ah sorry, I thought I must be missing something
Stephen Betts
@thisisstephenbetts
Still trying to get the neo4j-java-driver driver working, but in the meantime I have a theory. The rake task I'm working on stops and starts the local test neo4j server. I wonder if the connection that ActiveGraph::Base.query uses has expired. Is there a way to reconnect (in the old neo4jrb I was establishing the connection directly with Neo4j::Core::CypherSession.new with the suitable adaptor — that seems different now)
dimitriwoei
@dimitriwoei

Hi, I'm in the process of transitioning to ActiveGraph. I have the following piece of code that needs to be converted:

q = ::Neo4j::Core::Query.new(session: ::Neo4j::ActiveBase.current_session)

I tried using:

q = ::ActiveGraph::Base.query

But I'm getting the following error:

Traceback (most recent call last):
        2: from (irb):13
        1: from (irb):14:in `rescue in irb_binding'
ArgumentError (Could not determine query from arguments: [])

Please advise

Heinrich Klobuczek
@klobuczek
@thisisstephenbetts the driver uses a conection pool and automatically replaces stale connections.
@dimitriwoei I would need to see how q is used.
Heinrich Klobuczek
@klobuczek
otherwise the code corresponds to ActiveGraph::Base.new_query or ActiveGraph::Core::Query.new (without parameters)
dimitriwoei
@dimitriwoei

Thank you. I'm using it for among other things:

q.call("db.index.fulltext.queryNodes('#{Item.fullTextIndex}', '*bla*') \nYIELD node")

and

additional_query_list.each { |additional_query|
   q=q.send(additional_query)
}
q.proxy_as(my_class, :n)
Stephen Betts
@thisisstephenbetts
Thanks @klobuczek — haven't quite got jruby working right. Nearly there though
Heinrich Klobuczek
@klobuczek
If you migrate your entire app to jruby for this exercise, you might as well stay there. :)
Stephen Betts
@thisisstephenbetts
:-)
dimitriwoei
@dimitriwoei
Hi, I have the following case: We are using devise-activegraph to handle authentication. After authentication we would like to use the logged in user to perform queries instead of a generic user, because we would like to make use of the neo4j 4.0 security model with all it's features. What is the proper way to do this?
Heinrich Klobuczek
@klobuczek
I would love to hear from neo4j how they imagined the security model to be used. I have not seen anyone mapping application users to database users 1 to 1 in any database. We have implememented our own security model which is a super set of the neo4j security model on top of user database, not system database. I really cannot imagine doing it any other way. Otherwise for any user sign up you would have to create a new database user ending up with thousands or more users. And then the neo4j driver does not support switching users, you would have to create a separate driver instance (with all its connection pooling etc.) for every user.
4 replies
Gokul J
@gokulj
@thisisstephenbetts did you try setting encryption to false in your neo4j.yml ?
Stephen Betts
@thisisstephenbetts
Hi @gokulj, yes, I have encryption set to false.
@klobuczek I hit some syntax problems with jruby I've used it before and like it, but felt like I might be getting a bit off-track, so went back to play with the regular Ruby. I have found that that exception only gets raised after start (and maybe only after a DB's first start), and only once. This workaround has my tests passing consistently:
    Rake::Task['neo4j:start'].invoke(environment)
    sleep 20

    tried_before = false
    begin
      ActiveGraph::Base.query("Match (n:ModelVersion) return n.version").entries
    rescue Neo4j::Driver::Exceptions::SessionExpiredException
      raise if tried_before

      tried_before = true

      retry
    end
Heinrich Klobuczek
@klobuczek
@thisisstephenbetts I think the problem here is simply that the server is not ready. We are using less and less neo4j-rake_tasks in favor on boltkit. In any case you need to implement a waiting loop for the server like you can see e.g. activegraph/travis.yml https://github.com/neo4jrb/activegraph/blob/ca2fade3f37b2fe00be6f26a3aa0e63e06734fc4/.travis.yml#L14
Stephen Betts
@thisisstephenbetts
Thanks @klobuczek — you might be right, but I don't think so. If I remove that sleep statement I get a Neo4j::Driver::Exceptions::ServiceUnavailableException error, not the session expired one. Also I have increased that sleep to 5 minutes for testing, with no difference. Finally, you can see that going from a failed query to a successful one is virtually instantaneous — there is no additional sleep statement. If the problem was that the sleep wasn't long enough I'd expect the 2nd query to fail sometimes, but I've never seen that.
I will explore boltkit — thanks for the tip
Stephen Betts
@thisisstephenbetts

I modified the code above to be (not an exact copy, but close enough) to

    Rake::Task['neo4j:start'].invoke(environment)
    sleep 1 while `curl localhost:7575 > /dev/null 2>&1 ; echo $?`.chomp != "0"

    tried_before = false
    begin
      ActiveGraph::Base.query("Match (n:ModelVersion) return n.version").entries
    rescue Neo4j::Driver::Exceptions::SessionExpiredException
      puts "retrying"
      raise if tried_before

      tried_before = true
      retry
    end

and I see the "retrying" output, exactly once and everything is fine after that.
As far as I'm concerned this is an okay workaround for now, so I'm mostly just posting here for your information, not to obtain an immediate fix. Thanks!

Heinrich Klobuczek
@klobuczek
@thisisstephenbetts I hope you are not trying to suggest that this not timing issue but number of attempts issue. This would be really bad.
Stephen Betts
@thisisstephenbetts
@klobuczek to me all the evidence seems to say it's not a timing issue — if nothing else I believe you'd get a different exception. If I had to guess I'd say whatever is supposed to detect expired sessions has a small bug, but — not knowing the underlying code — that's not based on much.
Stephen Betts
@thisisstephenbetts
Here you go — this is a compact script to demonstrate the problem (you may need to modify the http URL to test for availability, but apart from that it should be portable). Uses Neo4j 4.0.6, Ruby 2.6.3, Rails 5.2.3, and ActiveGraph 10.0.1
require 'active_graph/railtie'

Rake::Task['neo4j:start'].invoke('test')
Rake::Task['neo4j:start'].reenable
Timeout.timeout(120) do
  sleep 1 while `curl localhost:7575 > /dev/null 2>&1 ; echo $?`.chomp != "0"
end

ActiveGraph::Base.query("Match (n:ModelVersion) return n.version").entries

Rake::Task['neo4j:stop'].invoke('test')

Rake::Task['neo4j:start'].invoke('test')
Timeout.timeout(120) do
  sleep 1 while `curl localhost:7575 > /dev/null 2>&1 ; echo $?`.chomp != "0"
end

tried_before = false
begin
  ActiveGraph::Base.query("Match (n:ModelVersion) return n.version").entries
rescue Neo4j::Driver::Exceptions::SessionExpiredException
  puts 'Got SessionExpiredException'

  raise if tried_before

  tried_before = true
  retry
end

puts ActiveGraph::Base.query("Match (n:ModelVersion) return n.version").entries.length
Heinrich Klobuczek
@klobuczek
@thisisstephenbetts when you start or restart the neo4j server the connections in the driver pool become stale. The easiest workaround is to ActiveGraph::Base.driver = nil after start. You will still need to wait for the server to start. Open question: why is the driver initialized before server start? Are you making any queries before? Ideally the stale connection should be purged and new one created. This is working in the java based drivers 1.7 and 4.1, but seems not to be on the seabolt based driver 1.7.
Johan André
@johanandre
hello! anyone else have a problem with deploying a rails + neo4j application to heroku? I get "LoadError: Could not open library 'libseabolt17': libseabolt17: cannot open shared object file: No such file or directory." when builing the project...
Heinrich Klobuczek
@klobuczek
@johanandre if you scroll up there is some discussion about this and a success report
Johan André
@johanandre
@klobuczek thank you!
Johan André
@johanandre
@klobuczek it is kindof hard to follow what the actual solution is... is it using the apt-buildpack? i've tried it and when building on heroku it says that the buildpack is not compatible with the app.
Stephen Betts
@thisisstephenbetts
Hi @klobuczek — thanks for looking into this. That works! No, not making any queries after server start until the one you see causing the exception.
Johan André
@johanandre
I have documented my procedure for making Activegraph work on Heroku: neo4jrb/activegraph#1631
Jonathan Linowes
@linojon
hello i am trying to use jruby on windows10 with rails 6 and activegraph. When i try to generate my first scaffold it gives an error "ArgumentError: Can not transliterate strings with Windows-1252 encoding"
Jonathan Linowes
@linojon
$ jruby -S rails generate scaffold User name:string email:string
2020-11-13T11:37:59.585-05:00 [main] WARN FilenoUtil : Native subprocess control requires open access to the JDK IO subsystem
Pass '--add-opens java.base/sun.nio.ch=org.jruby.dist --add-opens java.base/java.io=org.jruby.dist' to enable.
2020-11-13T11:38:03.555-05:00 [main] WARN FilenoUtil : Native subprocess control requires open access to the JDK IO subsystem
Pass '--add-opens java.base/sun.nio.ch=org.jruby.dist --add-opens java.base/java.io=org.jruby.dist' to enable.
      invoke  active_graph
   identical    app/models/user.rb
ArgumentError: Can not transliterate strings with Windows-1252 encoding
             transliterate at D:/jruby-9.2.13.0/lib/ruby/gems/shared/gems/activesupport-6.0.3.4/lib/active_support/inflector/transliterate.rb:67
              parameterize at D:/jruby-9.2.13.0/lib/ruby/gems/shared/gems/activesupport-6.0.3.4/lib/active_support/inflector/transliterate.rb:123
              parameterize at D:/jruby-9.2.13.0/lib/ruby/gems/shared/gems/activesupport-6.0.3.4/lib/active_support/core_ext/string/inflections.rb:196
  base_migration_file_name at D:/jruby-9.2.13.0/lib/ruby/gems/shared/gems/activegraph-10.0.1/lib/rails/generators/active_graph_generator.rb:15
       migration_file_name at D:/jruby-9.2.13.0/lib/ruby/gems/shared/gems/activegraph-10.0.1/lib/rails/generators/active_graph_generator.rb:19
        migration_template at D:/jruby-9.2.13.0/lib/ruby/gems/shared/gems/activegraph-10.0.1/lib/rails/generators/active_graph_generator.rb:40
         create_model_file at D:/jruby-9.2.13.0/lib/ruby/gems/shared/gems/activegraph-10.0.1/lib/rails/generators/active_graph/model/model_generator.rb:21
                       run at D:/jruby-9.2.13.0/lib/ruby/gems/shared/gems/thor-1.0.1/lib/thor/command.rb:27
            invoke_command at D:/jruby-9.2.13.0/lib/ruby/gems/shared/gems/thor-1.0.1/lib/thor/invocation.rb:127
                invoke_all at D:/jruby-9.2.13.0/lib/ruby/gems/shared/gems/thor-1.0.1/lib/thor/invocation.rb:134
                      each at org/jruby/RubyHash.java:1415
                       map at org/jruby/RubyEnumerable.java:886
                invoke_all at D:/jruby-9.2.13.0/lib/ruby/gem
Jacob Ablowitz
@jacob-ablowitz
Has anyone gotten libseabolt17 to install to a debian container? Alternatively, has anyone gotten it to install to a CentOS 8 container? Those are the two we've set up our app to run upon and I'm really not excited about trying to get "yet another" container platform working...