neo4jrb / activegraph

An active model wrapper for the Neo4j Graph Database for Ruby.
http://neo4jrb.io
MIT License
1.4k stars 276 forks source link

Failure to connect #732

Closed Tenari closed 9 years ago

Tenari commented 9 years ago

I have a very simple api written in grape, and it needs to connect to a neo4j db

my connection code (in config.ru):

ENV['RACK_ENV'] ||= 'development'
require 'grape'
require 'neo4j'

if ENV['RACK_ENV'] == 'development'
  Neo4j::Session.open(:server_db, 'http://ec2-IP ADDRESS.compute-1.amazonaws.com:7475')
else
end

Dir[File.expand_path('../../app/models/*.rb', __FILE__)].each do |f|
  require f
end
Dir[File.expand_path('../../app/resources/*.rb', __FILE__)].each do |f|
  require f
end

require './app/api.rb'

(with the IP ADDRESS filled in above, of course.) The ec2 instance which owns the Neo4j database is up and accepting connections, as verified by going to it in the browser and running a query through the /browser/ ui

then I run rackup to start the server. the error:

/Users/tenari/.rvm/gems/ruby-2.2.0-preview1/gems/neo4j-core-4.0.5/lib/neo4j-server/cypher_response.rb:161:in `raise_error': LockClient[5] can't wait on resource RWLock[SCHEMA(0), hash=1585398576] since => LockClient[5] <-[:HELD_BY]- RWLock[SCHEMA(0), hash=1585398576] <-[:WAITING_FOR]- LockClient[3] <-[:HELD_BY]- RWLock[SCHEMA(0), hash=1585398576] (Neo4j::Server::CypherResponse::ResponseError)

Now, it is known that this database has another api connecting to it, and serving requests, but it doesn't seem like that should be a problem considering that the /browser/ thing is able to function.

Googling has failed me. anyone have ideas?

subvertallchris commented 9 years ago

Editing out my question here, can save you some time and give some troubleshooting steps...

Setup your Gemfile to use the master branches of both this gem and neo4j-core:

gem 'neo4j', github: 'neo4jrb/neo4j'
gem 'neo4j-core', github: 'neo4jrb/neo4j-core'

I patched what I think might be causing your problem just the other day. Let me know if it helps.

Tenari commented 9 years ago

No, I don't see how that could be happening as I am running this locally and, only running rackup once, and it works fine if I connect to a local database.

Tenari commented 9 years ago

If it is relevant, this is the exact versions of things that I am using. (but I have also tried it with v4.1.5 of neo4j.rb)

Using rake 10.4.2
Using i18n 0.7.0
Using json 1.8.2
Using minitest 5.5.1
Using thread_safe 0.3.4
Using tzinfo 1.2.2
Using activesupport 4.2.0
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile 0.6.2
Using nokogiri 1.6.6.2
Using rails-deprecated_sanitizer 1.0.3
Using rails-dom-testing 1.0.5
Using loofah 2.0.1
Using rails-html-sanitizer 1.0.1
Using actionview 4.2.0
Using rack 1.6.0
Using rack-test 0.6.3
Using actionpack 4.2.0
Using activemodel 4.2.0
Using active_attr 0.8.5
Using descendants_tracker 0.0.4
Using ice_nine 0.11.1
Using axiom-types 0.1.1
Using coercible 1.0.0
Using daemons 1.1.9
Using equalizer 0.0.9
Using eventmachine 1.0.6
Using multipart-post 2.0.0
Using faraday 0.9.1
Using faraday_middleware 0.9.1
Using hashie 3.4.0
Using multi_json 1.10.1
Using multi_xml 0.5.5
Using rack-accept 0.4.5
Using rack-mount 0.8.3
Using virtus 1.0.4
Using grape 0.10.1
Using httparty 0.13.3
Using httpclient 2.6.0.1
Using net-http-persistent 2.9.4
Using os 0.9.6
Using zip 2.0.2
Using neo4j-core 4.0.2
Using orm_adapter 0.5.0
Using thor 0.19.1
Using railties 4.2.0
Using neo4j 4.1.2
Using thin 1.6.3
Using bundler 1.7.4
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
subvertallchris commented 9 years ago

But have you tried it from the master branch of both gems? There are a few unreleased commits that deal with this error.

Tenari commented 9 years ago

You sir, make me feel like an idiot.

Thank you.

subvertallchris commented 9 years ago

Hahaha! No no no, please don't feel bad! It's easy to overlook that. So this did fix the problem? The database you're connecting to... does it have a lot of data in it? I think you could have this problem if it was trying to create a constraint and it took a moment to scan lots of nodes. The changes in the master branches make the gems able to deal with that error.

Tenari commented 9 years ago

this fixed it. the db has >54million nodes and some large amount of connections.

subvertallchris commented 9 years ago

Well... yeah, that'd do it. :-) Awesome! Let us know if you have any more trouble. Brian and I usually hang out in a Gitter room during the week. https://gitter.im/neo4jrb/neo4j

Tenari commented 9 years ago

totally unrelated, is there some limit on the ActiveNode usage of property :id, type: String

Tenari commented 9 years ago

I can read, nevermind https://github.com/neo4jrb/neo4j/wiki/Neo4j-v3-Unique-IDs

Tenari commented 9 years ago

@subvertallchris https://github.com/neo4jrb/neo4j/wiki/Neo4j-v3-Unique-IDs contains links to 404 pages. they seem to have been pointing to some example/blog/config/application.rb file and another similar model file.