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

Marcel Reutegger commented on OAK-1167:
---------------------------------------

AFAICS this is caused by multiple threads concurrently calling 
RevisionComparator.add() through different methods. There are mainly two 
methods where add() is called for foreign revisions. The third, MongoNodeStore 
constructor, is a bit of a special case because it only calls add() once on 
startup.

- Revisions are added in MongoNodeStore.backgroundRead() by a dedicated 
background thread
- Revisions are added in MongoNodeStore.publishRevision() by a committing 
thread when a newer revision than the commit revision is seen.

The check whether to add the revision is implemented differently in the two 
methods. backgroundRead() keeps a {{lastKnownRevision}} map, which contains the 
most recent foreign revisions, while publishRevision() uses the head revision 
to perform the check.

Either both methods must use the same algorithm to decide whether to add a 
revision or RevisionComparator.add() must be more lenient when an attempt is 
made to add a earlier revision.

> Background read may cause IllegalArgumentException
> --------------------------------------------------
>
>                 Key: OAK-1167
>                 URL: https://issues.apache.org/jira/browse/OAK-1167
>             Project: Jackrabbit Oak
>          Issue Type: Bug
>          Components: core, mongomk
>    Affects Versions: 0.10
>            Reporter: Marcel Reutegger
>            Assignee: Marcel Reutegger
>
> When running Oak with MongoMK and multiple cluster nodes the background read 
> may sometimes cause an IllegalArgumentException like this:
> {noformat}
> 02:14:40.451 [MongoNodeStore background thread] WARN  
> o.a.j.o.p.mongomk.MongoNodeStore - Background operation failed: 
> java.lang.IllegalArgumentException: Can not add an earlier revision: 
> r14246a7ee62-0-3 > r14246a7ea36-0-3; current cluster node is 2
> java.lang.IllegalArgumentException: Can not add an earlier revision: 
> r14246a7ee62-0-3 > r14246a7ea36-0-3; current cluster node is 2
>       at 
> org.apache.jackrabbit.oak.plugins.mongomk.Revision$RevisionComparator.add(Revision.java:383)
>  ~[oak-run-0.11-SNAPSHOT.jar:0.11-SNAPSHOT]
>       at 
> org.apache.jackrabbit.oak.plugins.mongomk.MongoNodeStore.backgroundRead(MongoNodeStore.java:1044)
>  ~[oak-run-0.11-SNAPSHOT.jar:0.11-SNAPSHOT]
>       at 
> org.apache.jackrabbit.oak.plugins.mongomk.MongoNodeStore.runBackgroundOperations(MongoNodeStore.java:1000)
>  ~[oak-run-0.11-SNAPSHOT.jar:0.11-SNAPSHOT]
>       at 
> org.apache.jackrabbit.oak.plugins.mongomk.MongoNodeStore$BackgroundOperation.run(MongoNodeStore.java:1221)
>  [oak-run-0.11-SNAPSHOT.jar:0.11-SNAPSHOT]
>       at java.lang.Thread.run(Thread.java:679) [na:1.6.0_24]
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Reply via email to