I tried to delete a node with its relations but I get this error
Relationship[332147,used=false,source=-1,target=-1,type=-1,sCount=1,sNext=-1,tCount=1,tNext=-1,prop=-1,secondaryUnitId=-1, sFirst, tFirst] not in use
I tried to Match or Delete this 332147 relation but in every query, I get not found
Node/Relationship[...] not in use means that your database is corrupted. (see related ticket) Probably due to an unexpected shutdown/interrupt.
You need to either restore from backup, or go through a data recovery process.
The solution recommended in that ticket is
You can copy the store using store-utils which will skip over broken
nodes and rels.
Related
I am using an apoc.periodic.iterate query to store millions of data . Since the data may contain duplicates I am using MERGE action to create nodes but unfortunately whenever the data is duplicated the whole batch is getting with error like this
"LockClient[200] can't wait on resource RWLock[NODE(14), hash=1645803399] since => LockClient[200] <-[:HELD_BY]- RWLock[NODE(101)"
Changing parallel as false works fine
Also by removing duplicates the query is passed successfully
But both of the above solution takes more time since dealing with millions of data . Is there any alternate solution like making a it to wait for the lock
You cannot use parallel:true, because you are creating relationships in your query. Every time you want to add a relationship to a node, the cypher engine adds a write lock to a node, and other processes can't add to that particular node. That is why you have the write lock exception. Not much you can do except to run it with parallel:false setting.
To avoid deadlocks, concurrent requests that update the DB should avoid touching the same nodes or relationships (including the nodes on both ends of those relationships). One way to achieve this is to figure out a way to have the concurrent requests work on disjoint subgraphs.
Or, you can retry queries that throw a DeadlockDetectedException. The docs show an example of how to do that.
I'm using Neo4j Enterprise Edition. I want to clear the whole database I have created before . I mean Every single Node and it's relationships and also properties So I found this syntax on Neo4j book I ran the syntax :
MATCH (a)
OPTIONAL MATCH (a)-[r]-()
DELETE a, r
But still can see the properties on the property keys part
what's wrong?
What should I do so that even properties get deleted?
Neo4j Browser just show the data returned from CALL db.propertyKeys(). Currently the procedure db.propertyKeys() is returning unused properties, as you can see in this GitHub issue at Neo4j Repo.
That is: your database is totally empty, but Neo4j Browser still showing the properties that existed in your database at some point of time.
Since you are deleting all your nodes and relationships, you can alternatively delete all content of <neo4j-home>/data/databases/graph.db/ folder and restart Neo4j service. But you will need to recreate all indexes, constraints and do authentication again.
Tip: Currently you can use DETACH DELETE to delete a node and any relationship going to or from it. So instead of the query yo wrote you can use:
match (node)
detach delete node
I deleted the reference node. So I need to recreate the reference node.
Using cypher how to create a node with id 0?
thanks.
The short answer is you can't, and you don't need to. Do you have a specific problem without that node? If so, maybe you can elaborate, chances are there is something else that answers your problem better than trying to recreate a node with a specific id.
The long answer is you can't assign id:s to nodes with cypher. The id is an index or offset into the node storage on disk, so it makes sense to let Neo4j worry about it and not try to manipulate it or include it in any application logic. See Node identifiers in neo4j and Has anyone used Neo4j node IDs as foreign keys to other databases for large property sets?.
You also most likely don't need a reference node. It is created by default in a new database, but it's use is deprecated and it won't exist in future releases. See Is concept of reference node in neo4j still used or deprecated?.
If you still want to assign id to nodes you create, it is accidentally possible in a roundabout way with with the CSV batch importer (1,2) and, I believe, with the Java API batch inserter.
If you still want to recreate or simulate the reference node you can either delete the database data files and let Neo4j recreate the the database, or you can try what this person did: Recreate reference node in a Neo4j database. You can also force Neo4j to recycle the ids of deleted nodes faster, so that new nodes that you create receive those ids that have been freed up and not yet reassigned.
Using Neo 2.0 through REST API /cypher I'm trying to build a rooted tree like structure.
I currently have an indexed start node, I want to attach a unique path of nodes which may already exist. How can I get cypher to create and set or just update if its already in the database but missing certain properties.
Cypher's MERGE command does this, see http://docs.neo4j.org/chunked/milestone/query-merge.html.
I have the same issue currently. I'm looking into CREATE UNIQUE might be what you are after.
http://neo4j.com/docs/stable/query-create-unique.html
edited: actually I think CREATE UNIQUE might be deprecated.
Is there a possibility to reset the indices once I deleted the nodes just as if deleted the whole folder manually?
I am deleting the whole database with node.delete() and relation.delete() and just want the indices to start at 1 again and not where I had actually stopped...
I assume you are referring to the node and relationship IDs rather than the indexes?
Quick answer: You cannot explicitly force the counter to reset.
Slightly longer answer: Generally speaking, these IDs should not carry any relevance within your application. There have been a number of discussions about this within the Neo4j mailing list and Stack Overflow as the ID is an internal artifact and should not be used like a primary key. It's purpose is more akin to an in-memory address and if you require unique identifiers, you are better off considering something like a UUID.
You can stop your database, delete all the files in the database folder, and start it again.
This way, the ID generation will start back from 1.
This procedure completely wipes your data, so handle with care.
Now you certainly can do this using Python.
see https://stackoverflow.com/a/23310320