Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8642491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:47:25+00:00 2026-06-12T11:47:25+00:00

I’m using Neo4j in a concurrent environment and I have graph that looks like

  • 0

I’m using Neo4j in a concurrent environment and I have graph that looks like this:

Graph

Each item can be in none or at most one of 3 states (S1, S2 and S3). An item can change its state and the flow goes this way: item is not present in any state, then S1, S2 and finally S3.

This means that when adding an item I will have to check whether it’s already present in S1, S2 or S3. If it is, then I shouldn’t add it again. Additionally, if the item is in S1 and is requested to go to the next state in the flow then the item must be first removed from S1 and then added to S2.

Having an index on each of the states wouldn’t solve this issue because all of these operations must happen atomically as it is a concurrent environment. I’ve checked this link and I could only think about going for the Pessimistic locking approach. The pseudocode to add a new item, based on the example, should be something like:

search for node in all states
if node is present in any state
    return node
else
    begin transaction
        get a write lock on #lockNode#
        create node
        add node to initial state
    commit
    return node
end

The pseudocode to change from a state to another state should be very similar to the previous one.

So the questions are:

  1. What is #lockNode# in my pseudocode? I can’t figure it out from the example. Sounds like it similar to a synchronized (lockNode) {} but I need a little exaplanation to go on with this solution
  2. What would be the impact of using the reference node as #lockNode#?
  3. Is it possible to atomically and in a sychronized way perform the searches in the three indexes and then add/move the node to a state?

I could easily solve this by using Java synchronization but the documentation clearly states this should not be done. Any help for a Neo4j newbie like me would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T11:47:27+00:00Added an answer on June 12, 2026 at 11:47 am

    As an item can only be in one state, you can have only one index and use the “Get or create” technique in the link you provided. To know the state of an item you can traverse the dingle relationship then the state node. Or you can index using 2 properties (name & state). Or have 4 indexes

    Locking the reference node will create a bottleneck (a bit less if you lock only the s1 node), and for unique node creation I think the best way is the get-or-create thing, I don’t know any other good way

    Synchronization is also a big no-no as it can “conflict” with the neo4j internal locking system and create dead-locks

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I would like to run a str_replace or preg_replace which looks for certain words

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.