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 "Stefan Egli (Jira)" <ji...@apache.org> on 2024/10/10 17:31:00 UTC

[jira] [Commented] (OAK-11184) Reading root with an unmerged revision results in previous document scan

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

Stefan Egli commented on OAK-11184:
-----------------------------------

Working on reproducing this in a branch (see [this draft PR|https://github.com/apache/jackrabbit-oak/pull/1779])

> Reading root with an unmerged revision results in previous document scan
> ------------------------------------------------------------------------
>
>                 Key: OAK-11184
>                 URL: https://issues.apache.org/jira/browse/OAK-11184
>             Project: Jackrabbit Oak
>          Issue Type: Bug
>          Components: documentmk
>            Reporter: Stefan Egli
>            Priority: Major
>
> Consider a scenario with 2 cluster nodes (running DocumentNodeStore):
> * cluster node A with cluster node id 1
> * cluster node B with cluster node id 2
> Now cluster node A is doing a merge that includes changes (eg a property) on root. Such a merge includes two updates towards DocumentStore:
> * the first update has the actual changes on the properties (that would include any other document other than root - but that's not so relevant here). Say that happens with revision {{"rn-0-1"}}
> * the second update is marking the revision as committed - which is done by adding an entry to "_revisions" with {{"rn-0-1" : "c"}}
> If cluster node B reads the root document ("0:/") between the above two steps, it will read {{"rn-0-1"}} in an unmerged state (it has no commit value yet). 
> When B tries to resolve the commit value of {{"rn-0-1"}} it can't find it in the main root document and thus, if there are any, it has to go through the previous documents to see if the revision is there.
> In other words: B is taking a performance hit when resolving {{"rn-0-1"}} as it has to go through previous documents.
> The root document is read by backgroundRead. So B will take the performance hit until another backgroundRead succeeds.
> backgroundRead requires the exclusive lock on the backgroundOperationLock as part of updating a fresh main root. If B happens to have that exclusive lock occupied by anyone else, it has to wait.
> As part of a regular merge though, the "read/non-exclusive" lock of backgroundOperationLock is acquired. 
> If there are a number of threads "ahead" of backgroundRead all acquiring the read-lock of backgroundOperationLock, the backgroundRead will have to wait until all commits are done.
> If B is in the initially mentioned situation where it has an unmerged revision, this will mean that all merge operations will update root - and as part of that read root again - and as part of that they will thus need to go through (all) previous documents to confirm the unmerged revision is ... unmerged.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)