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

Manfred Baedke commented on OAK-10812:
--------------------------------------

The problem is the following method, which is called in 
DocumentNodeStore#diffManyChildren():
{code:java}
    public static long getMinTimestampForDiff(@NotNull RevisionVector fromRev,
                                              @NotNull RevisionVector toRev,
                                              @NotNull RevisionVector 
minRevisions) {
        // make sure we have minimum revisions for all known cluster nodes
        fromRev = fromRev.pmax(minRevisions);
        toRev = toRev.pmax(minRevisions);
        // keep only revision entries that changed
        RevisionVector from = fromRev.difference(toRev);
        RevisionVector to = toRev.difference(fromRev);
        // now calculate minimum timestamp
        long min = Long.MAX_VALUE;
        for (Revision r : from) {
            min = Math.min(r.getTimestamp(), min);
        }
        for (Revision r : to) {
            min = Math.min(r.getTimestamp(), min);
        }
        return min;
    }
{code}
where the minRevisions is derived from the start time of the *external* cluster 
nodes.
So the statement
{code}
fromRev = fromRev.pmax(minRevisions);
{code}
may yield a revision which is newer than the original starting point of the 
diff, apparently assuming that external cluster nodes have synced after 
startup. The internal cluster node is excluded, because it might have been 
restarted after the timestamp corresponding to the original fromRevision.
In readonly mode, the DocumentNodeStore has cluster id 0, so all cluster nodes 
are considered external and the exclusion is not working. 
Since we don't even know which cluster node is the one to exclude, I think that 
we have to use the parallel minimum instead of the parallel maximum in this 
case. 

See attached PR#1465 for a unit test and a fix proposal.

cc [~stefanegli]

> DocumentNodeStore#diffManyChildren(...) may produce incorrect results in 
> readonly mode
> --------------------------------------------------------------------------------------
>
>                 Key: OAK-10812
>                 URL: https://issues.apache.org/jira/browse/OAK-10812
>             Project: Jackrabbit Oak
>          Issue Type: Bug
>          Components: documentmk
>            Reporter: Manfred Baedke
>            Assignee: Manfred Baedke
>            Priority: Major
>




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

Reply via email to