Pregunta

I try to create an index with a Cypher query using py2neo 1.6.2 and neo4j 2.0.1:

graph_db = neo4j.GraphDatabaseService()
query = "CREATE INDEX ON :Label(prop)"
neo4j.CypherQuery(graph_db, query).run()

The query works fine in the neo4j web interface but throws a deadlock error in py2neo:


py2neo.neo4j.DeadlockDetectedException: Don't panic.

A deadlock scenario has been detected and avoided. This means that two or more transactions, which were holding locks, were wanting to await locks held by one another, which would have resulted in a deadlock between these transactions. This exception was thrown instead of ending up in that deadlock.

See the deadlock section in the Neo4j manual for how to avoid this: http://docs.neo4j.org/chunked/stable/transactions-deadlocks.html

Details: 'Transaction(15438, owner:"qtp1927594840-9525")[STATUS_ACTIVE,Resources=1] can't wait on resource RWLock[SchemaLock]since => Transaction(15438, owner:"qtp1927594840-9525")[STATUS_ACTIVE,Resources=1] <-[:HELD_BY]- RWLock[SchemaLock] <-[:WAITING_FOR]- Transaction(15233, owner:"qtp1927594840-9503")[STATUS_ACTIVE,Resources=1] <-[:HELD_BY]- RWLock[SchemaLock]'.


It doesn't make a difference if the label exists or not, the request usually fails.

¿Fue útil?

Solución

Judging from the deadlock graph in the details section, this looks like a bug in 2.0.1. Are you doing anything else to the database other than running this specific query, or is this just starting up a fresh database and running the code you provided?

In any case, since it works in the Neo4j Browser, I'd suggest swapping to use the transactional APIs, as that is what the browser uses. Py2neo supports this using the "Cypher Transactions" feature, documented here:

http://book.py2neo.org/en/latest/cypher/#id2

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top