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

Thread-safe Neo4j.start #23

Merged
merged 1 commit into from
Jan 25, 2013
Merged

Conversation

dwbutler
Copy link
Contributor

As discussed in neo4jrb/activegraph#237, it seems Neo4j.start is not currently thread-safe. This fix solves the issue for me in both puma and torquebox-lite.

There were two problems:

  • There was no lock around Neo4j::Core::Database#start, which allowed other threads concurrent access to this method. This fix introduces a lock around the whole method.
  • @running was set to true in Neo4j::Core::Database before the database had actually completed start up. Since other threads check for db.running?, this caused these threads to access the database before it had actually completed initializing. This is now fixed by setting @running to true only after the database has finished initializing.

It turned out to be unnecessary to put a lock around Neo4j.start. In fact, doing so caused problems. (Please ignore the whitespace changes in neo4j.rb - I had trouble cleaning up my git history.)

andreasronge added a commit that referenced this pull request Jan 25, 2013
@andreasronge andreasronge merged commit 2c7f33e into neo4jrb:master Jan 25, 2013
@dwbutler dwbutler deleted the thread_safe_start branch January 25, 2013 07:55
@seenickcode
Copy link

Hello @dwbutler , it seems that this is still a problem at least with Heroku. Any insight into why? http://stackoverflow.com/questions/16246107/neo4j-doesnt-autostart-after-deploying-to-heroku

@dwbutler
Copy link
Contributor Author

This is likely because the fixes I submitted have not made it into an official release yet. I'll go ahead and write a detailed explanation over on stack overflow.

@seenickcode
Copy link

thanks!

On Fri, Apr 26, 2013 at 7:15 PM, David Butler notifications@github.comwrote:

This is likely because the fixes I submitted have not made it into an
official release yet. I'll go ahead and write a detailed explanation over
on stack overflow.


Reply to this email directly or view it on GitHubhttps://github.com//pull/23#issuecomment-17105111
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants