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
That's the one for the query
Thanks very much for the help!
MATCH queries seem okay — but CREATE queries cause errors
This message was deleted

That's not true — it's the MATCH query it fails on:

ActiveGraph::Base.query("MATCH (n:ModelVersion) DELETE n")

Heinrich Klobuczek
@klobuczek
that’s a write query after all
can you run any query?
have you configured encryption: false?
Stephen Betts
@thisisstephenbetts
Oh you're right — sorry
I have configured that. Was getting an error before I did that, and found that fix in here
Just checking on a read query
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.