Multiple Services Modifying same graph

Hello,

I have 4 separate microservices that query/modify the same graph in Neo4j. They all key off of the same parent node and are supposed to create their own child nodes. My queries work fine when developing locally and just calling the DB API with Postman, but when I spin up all services I get inconsistent behavior. Sometimes I get 2 parent nodes with only 3 children each, other times it's 4 parent nodes with one child, etc.

The way I was trying to write the query is that the first service that "checks in", creates the parent node.

MERGE(server:Server {name: $server_name})

I tried following these tips but none seem to work.

What's the best way to handle different services modifying the same graph? I'm using Go for all services involved.

I solved this with Go using a Mutex around this specific query

Did you have a unique constraint on the lookup key property? If not you could create multiple copies if multiple calls are made concurrently. Merge will work to create the first copy and match afterwards.