You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-issues@jackrabbit.apache.org by "Mete Atamel (JIRA)" <ji...@apache.org> on 2013/01/23 12:00:12 UTC

[jira] [Comment Edited] (OAK-566) MongoMK throws exception when adding nodes concurrently

    [ https://issues.apache.org/jira/browse/OAK-566?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13560553#comment-13560553 ] 

Mete Atamel edited comment on OAK-566 at 1/23/13 10:58 AM:
-----------------------------------------------------------

> I mean, is commit1 really valid at that time? If the commit indeed is valid at that time, why can it be changed to invalid later on?

Yes it was valid but in-progress at that time and it can be changed to invalid and finalized before headRevision is incremented if there has been a concurrent update. The headRevision in sync collection is supposed to prevent in-progress commits from being treated as finalized but as Marcel pointed out, the problem in multiple threads is that headRevision can be incremented beyond an in-progress commit and hence making the commit appear as finalized when it's actually in-progress.
                
      was (Author: meteatamel):
    > I mean, is commit1 really valid at that time? If the commit indeed is valid at that time, why can it be changed to invalid later on?

Yes it was valid but in-progress at that time and it can be changed to invalid and finalized before headRevision is incremented if there has been a concurrent update. The headRevision in sync collection is supposed to prevent in-progress commits from being treated as finalized but as Marcel pointed out, the problem in multiple threads is that headRevision can be incremented beyond an in-progress commit and hence making the commit appear as finalized when it's actually in-progress. 

Marcel, maybe this is why we had FetchCommitsAction follow the baseRevisionId chain before?
                  
> MongoMK throws exception when adding nodes concurrently
> -------------------------------------------------------
>
>                 Key: OAK-566
>                 URL: https://issues.apache.org/jira/browse/OAK-566
>             Project: Jackrabbit Oak
>          Issue Type: Bug
>          Components: mongomk
>            Reporter: Damien Obrist
>            Priority: Minor
>         Attachments: MongoMKConcurrentAddTest.java
>
>
> It seems that there is a problem in the MongoDB microkernel when lots of threads try to commit new nodes concurrently. I have attached a JUnit test which reproduces the error. The test creates 16 microkernels, each committing two nodes in a separate thread. Some threads will throw an exception saying that the node they're trying to commit already exists:
> java.lang.RuntimeException: There's already a child node with name 'node6'
> at org.apache.jackrabbit.mongomk.impl.instruction.CommitCommandInstructionVisitor.visit(CommitCommandInstructionVisitor.java:97)
> at org.apache.jackrabbit.mongomk.impl.instruction.AddNodeInstructionImpl.accept(AddNodeInstructionImpl.java:40)
> at org.apache.jackrabbit.mongomk.impl.command.CommitCommandNew.createMongoNodes(CommitCommandNew.java:155)
> at org.apache.jackrabbit.mongomk.impl.command.CommitCommandNew.execute(CommitCommandNew.java:97)
> at org.apache.jackrabbit.mongomk.impl.command.CommitCommandNew.execute(CommitCommandNew.java:1)
> at org.apache.jackrabbit.mongomk.impl.command.DefaultCommandExecutor.execute(DefaultCommandExecutor.java:38)
> at org.apache.jackrabbit.mongomk.impl.MongoNodeStore.commit(MongoNodeStore.java:110)
> at org.apache.jackrabbit.mongomk.impl.MongoMicroKernel.commit(MongoMicroKernel.java:112)
> ... 7 more
> This cannot be the case however, as the nodes added by the different threads do not overlap / conflict. No exceptions are thrown if setting the number of threads to some lower number, but I have observed that in this case the problem still exists when trying to add a larger number of nodes (more than just 2).

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira