[ 
https://issues.apache.org/jira/browse/OAK-9158?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Marcel Reutegger resolved OAK-9158.
-----------------------------------
    Fix Version/s: 1.40.0
       Resolution: Fixed

Committed changes to trunk: http://svn.apache.org/r1886954

Thank you for reporting this issue and providing a patch.

> Performance issue due to AbstractDocumentNodeState#equals
> ---------------------------------------------------------
>
>                 Key: OAK-9158
>                 URL: https://issues.apache.org/jira/browse/OAK-9158
>             Project: Jackrabbit Oak
>          Issue Type: Bug
>          Components: documentmk
>    Affects Versions: 1.10.8, 1.22.3
>            Reporter: Alexander Lüders
>            Assignee: Marcel Reutegger
>            Priority: Major
>             Fix For: 1.40.0
>
>         Attachments: inheritance.png, patch.txt, stacktrace.txt
>
>
> TL;DR: It seems like OAK-7401 broke the symmetry contract of 
> AbstractDocumentNodeState#equals method. This may lead to lots of expensive 
> queries during commit.
> ---
> We have a MongoDB as a backend of a Oak repository where we see hundreds of 
> expensive queries being executed during a rather simple operation.
> It happens when we are saving a session in which we added a child node to a 
> node already containing a very large number of children.
> This has not been the case with Jackrabbit Oak 1.4.8 and 1.4.26 but it is an 
> issue with 1.10.8 and 1.22.3.
> Newer versions have not been tested yet but looking at the source we believe 
> that they will show that performance issue too.
> +What we know so far:+
>  
>  * The queries against the _MongoDocumentStore_ are triggered via 
> _AbstractNodeState.equals_ (see attached stacktrace)
>  * A TODO "inefficient unless there are very few child nodes" in that method 
> indicates poor performance but this has been there since a long time and 
> cannot explain the issue
>  * OAK-7401 introduced the class _ModifiedDocumentNodeState_ class which is 
> not inheriting _ModifiedNodeState_ or _AbstractDocumentNodeState_ (see 
> attached class inheritance diagram)
>  * _AbstractDocumentNodeState#equals_ is checking against instances of 
> _ModifiedNodeState_ and _AbstractDocumentNodeState_ but not 
> _ModifiedDocumentNodeState_. 
>  * _AbstractDocumentNodeState#equals_ triggers the "slow" 
> _AbstractNodeState#equals_ as a last resort
>  
>  Guessing from a high-level perspective it looks like the introduction of 
> _ModifiedDocumentNodeState_ broke the equals logic in class 
> _AbstractDocumentNodeState_.
> We compiled a patch that solves the performance issue. All test and 
> integration tests of oak-document-store also passed.
> See corresponding attachment.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to