deleteAll() of repository not working for me

3,295 views
Skip to first unread message

Abdul Azeez Shaik

unread,
May 18, 2012, 2:17:02 AM5/18/12
to ne...@googlegroups.com
Dear all,

I have used repo.findByboutiqueName() which succesfully returned my node and then i did
repo.deleteAll()
And then again tried repo.findByboutiqueName() which again worked succesfully whereas Expected behavior must be null.

Do i need to add anything else to make this deleteAll() work?

Please let me know your comments on this.

Thanks,
 Abdul

Marc de Verdelhan

unread,
May 18, 2012, 2:49:28 AM5/18/12
to ne...@googlegroups.com
Please, could you post your repository source code?

Cheers,

Marc

Abdul Azeez Shaik

unread,
May 18, 2012, 2:58:08 AM5/18/12
to ne...@googlegroups.com
My repository Code,

public interface BoutiqueRepository extends GraphRepository<Boutique>{

Boutique findByboutiqueName(String boutiqueName);

}

From service code, where am calling deleteall function,

@Autowired BoutiqueRepository boutiqueRepo;

public ResultStatus deleteAll() {

boutiqueRepo.deleteAll();

return ResultStatus.SUCCESS;

Abdul Azeez Shaik

unread,
May 18, 2012, 3:05:52 AM5/18/12
to ne...@googlegroups.com
This time i tried with Cypher query to delete the nodes, am getting below errors.
Here is code for calling cypher query,

public ResultStatus deleteAll() {

//boutiqueRepo.deleteAll();

Map<String, Object> temp = new HashMap<String, Object>();

Result<Map<String, Object>> result = neo4jTemplate.query("START n = node(*) DELETE n", temp);

return ResultStatus.SUCCESS;

}


Here is the error,

Exception in thread "main" org.neo4j.rest.graphdb.RestResultException: Unable to begin transaction at

org.neo4j.graphdb.TransactionFailureException: Unable to begin transaction

   org.neo4j.kernel.AbstractGraphDatabase.beginTx(AbstractGraphDatabase.java:771)

   org.neo4j.kernel.TransactionBuilderImpl.begin(TransactionBuilderImpl.java:39)

   org.neo4j.kernel.AbstractGraphDatabase.beginTx(AbstractGraphDatabase.java:749)

   org.neo4j.cypher.internal.pipes.TransactionStartPipe.createResults(TransactionStartPipe.scala:26)

   org.neo4j.cypher.internal.pipes.ExecuteUpdateCommandsPipe.createResults(ExecuteUpdateCommandsPipe.scala:35)

   org.neo4j.cypher.internal.pipes.EmptyResultPipe.createResults(EmptyResultPipe.scala:28)

   org.neo4j.cypher.internal.pipes.EmptyResultPipe.createResults(EmptyResultPipe.scala:24)

   org.neo4j.cypher.internal.pipes.CommitPipe.createResults(CommitPipe.scala:30)

   org.neo4j.cypher.internal.executionplan.ExecutionPlanImpl$$anonfun$5$$anonfun$apply$3.apply(ExecutionPlanImpl.scala:104)

   org.neo4j.cypher.internal.executionplan.ExecutionPlanImpl$$anonfun$5$$anonfun$apply$3.apply(ExecutionPlanImpl.scala:104)

   org.neo4j.cypher.PipeExecutionResult.immutableResult(PipeExecutionResult.scala:36)

   org.neo4j.cypher.EagerPipeExecutionResult.<init>(PipeExecutionResult.scala:171)

   org.neo4j.cypher.internal.executionplan.ExecutionPlanImpl$$anonfun$5.apply(ExecutionPlanImpl.scala:104)

   org.neo4j.cypher.internal.executionplan.ExecutionPlanImpl$$anonfun$5.apply(ExecutionPlanImpl.scala:102)

   org.neo4j.cypher.internal.executionplan.ExecutionPlanImpl.execute(ExecutionPlanImpl.scala:34)

   org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:55)

   org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:58)

   org.neo4j.cypher.javacompat.ExecutionEngine.execute(ExecutionEngine.java:86)

   org.neo4j.server.rest.web.CypherService.cypher(CypherService.java:67)

   java.lang.reflect.Method.invoke(Method.java:597)

   org.neo4j.server.statistic.StatisticFilter.doFilter(StatisticFilter.java:62)


at org.neo4j.rest.graphdb.query.RestCypherQueryEngine.query(RestCypherQueryEngine.java:60)

at org.springframework.data.neo4j.rest.SpringRestCypherQueryEngine.query(SpringRestCypherQueryEngine.java:41)

at org.springframework.data.neo4j.rest.SpringRestCypherQueryEngine.query(SpringRestCypherQueryEngine.java:27)

at org.springframework.data.neo4j.support.Neo4jTemplate.query(Neo4jTemplate.java:519)

at org.tieup.server.neo4japi.service.BoutiqueServiceImpl.deleteAll(BoutiqueServiceImpl.java:60)

at org.tieup.server.neo4japi.core.start.main(start.java:37)


Could anyone me throw me some pointers to resolve these two issues?


Thanks,

 Abdul

Abdul Azeez Shaik

unread,
May 18, 2012, 3:34:07 AM5/18/12
to ne...@googlegroups.com
I tried giving following command on Neo4j Shell, however it too returns same error,
TransactionFailureException: Unable to begin transaction

However following command works perfectly without issues, START n = node(*) RETURN n;

Do i need to do something else to enable delete operations on 1.8M02.
Kindly let me know.

Thanks,
 Abdul

Abdul Azeez Shaik

unread,
May 18, 2012, 4:48:02 AM5/18/12
to ne...@googlegroups.com
It seems the cypher query is failing, as repo.deleteall() has acquired lock on that.
After starting new database, i could successfully run the cypher delete query. However, repo.deleteall() still gives me problem. Moreever, its acquiring lock on the entities.

Could anyone suggest any workaround for this?

Thanks,
 Abdul

Michael Hunger

unread,
May 18, 2012, 7:15:28 AM5/18/12
to ne...@googlegroups.com
What is interesting are your transactional scopes,

if you have a tx around your deleteAll then it should not be findable after.

If you are inside the tx you can still find it, as the deletes are executed at the end of the tx.

Michael

Michael Hunger

unread,
May 18, 2012, 7:18:50 AM5/18/12
to ne...@googlegroups.com
Please always state if you are running these things against an embedded database or a remote one.

It would be helpful if you could share your graph.db/messages.log which should contain information about the transaction issue.

deleteAll just iterates over all results of an index query (the index that stores the instances of the type) and deletes the nodes one by one.

So, the cypher approach is faster anyway, especially remotely.

Please raise an issue about this at http://spring.neo4j.org/issues and link to this discussion, I look into it after my vacation.

Cheers

Michael

Abdul Azeez Shaik

unread,
May 18, 2012, 8:08:27 AM5/18/12
to ne...@googlegroups.com
Hi Micheal,

Thanks for the reply. I was using server remotely and here is the messages.log file. I haven't used any transactions for this. Would try using it once again. Neo4jTemplate.beginTx() seems to be deprecated, will go through the documentation on how to use this.

Regarding the index query, i read in the documentation 'Good Relationships' that @Indexed annotation will by-default create the index with 'class name'. However, i have noticed in graphDB, that there is one Extra Index created with 'class name' apart from the the properties for which i have used @annotation (Apart from _TYPE_ index). What is the purpose of this extra index and on which property has this been created?

Following is given in Good Relationships doc -  "The @Indexed annotation also provides the option of using a custom index name. The default index name is the simple class name of the entity, so that each class typically gets its own index."
Thanks in advance.

Regards,
 Abdul
messages.log

Mattias Persson

unread,
May 20, 2012, 2:04:34 PM5/20/12
to ne...@googlegroups.com, Peter Neubauer
From messages.log:

javax.transaction.HeuristicMixedException: Unable to rollback ---> error in commit: java.lang.RuntimeException: org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out: NativeFSLock@/Azeez/Softwares/neo4j-community-1.8.M02/data/graph.db/index/lucene/node/BoutiqueRefNode/write.lock ---> error code for rollback: 0
    at org.neo4j.kernel.impl.transaction.TxManager.commit(TxManager.java:492) [neo4j-kernel-1.8.M02.jar:1.8.M02]
    at org.neo4j.kernel.impl.transaction.TxManager.commit(TxManager.java:406) [neo4j-kernel-1.8.M02.jar:1.8.M02]
    at org.neo4j.kernel.impl.transaction.TransactionImpl.commit(TransactionImpl.java:117) [neo4j-kernel-1.8.M02.jar:1.8.M02]

    ...

I remember a previous issue someone else had where this was caused by a classloader issue, where there were a lucene index requested from two different classloaders inherently causing two IndexWriter instances to try to access the same Lucene index, which isn't allowed. This looks a lot like that, but I don't know much about your environment to be sure though.

Peter N, do you recall?



2012/5/18 Abdul Azeez Shaik <azeezte...@gmail.com>



--
Mattias Persson, [mat...@neotechnology.com]
Hacker, Neo Technology
www.neotechnology.com

Peter Neubauer

unread,
May 23, 2012, 10:26:21 AM5/23/12
to ne...@googlegroups.com
I don't really recall.

Abdul, could you share your setup code via dropbox or so, so we could
rerun this locally? Also what FileSystem are you running on?

Cheers,

/peter neubauer

G:  neubauer.peter
S:  peter.neubauer
P:  +46 704 106975
L:   http://www.linkedin.com/in/neubauer
T:   @peterneubauer

If you can write, you can code - @coderdojomalmo
If you can sketch, you can use a graph database - @neo4j

Abdul Azeez Shaik

unread,
May 24, 2012, 3:33:54 AM5/24/12
to ne...@googlegroups.com
Hi Peter,

I am running this on MAC OSX 10.5. Sure, will share the code with you. I am using 1.8M02, REST, simple object mapping of SDN.

I cant delete it using Cypher as well After using repo.deleteAll(). . I need to delete whole data and start the server once again to make it work.

Can i share the code in dropbox to peter.n...@neotechnology.com id? Or shall i send it to some other id?

Thanks,
 Abdul

Peter Neubauer

unread,
May 24, 2012, 3:44:13 AM5/24/12
to ne...@googlegroups.com

Neubaue...@gmail.com works best. Thanks!

Send from mobile.

Reply all
Reply to author
Forward
0 new messages