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

Marcel Reutegger commented on OAK-1056:
---------------------------------------

Michael and I discussed this issue offline this morning.

In general the requirement is there to create a new and independent builder 
whenever NodeState.builder() is called. Most of the time however, the full 
potential of this requirement is not used by client code. E.g. CommitHook 
implementations do create a builder from the after state, but effectively they 
are all based on the state returned by the previous hook, thus each builder is 
simply based on the current branch head. In general this may not be the case 
and in fact a commit hook may even create a builder from a before state and use 
it in the builder created from the after state.

For the latter case, the implementation could still return a MemoryNodeBuilder, 
but for the cases were a builder is obtained for the current branch head, the 
implementation could return a builder instance, which persists to the branch. 
It gets a bit tricky when there are multiple of those builders based on some 
branch state. Only a builder with a base state equal to the head of the 
persisted branch must be allowed to persist further changes and it may even be 
desirable to immediately fail an attempt to work with a builder, which is not 
based on the head of a branch anymore.

> Transient changes contributed by commit hooks are kept in memory
> ----------------------------------------------------------------
>
>                 Key: OAK-1056
>                 URL: https://issues.apache.org/jira/browse/OAK-1056
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: core
>            Reporter: Michael Dürig
>             Fix For: 1.0
>
>
> With the {{KernelNodeStore}}, transient changes contributed by commit hooks 
> are currently kept in memory instead of being written ahead to the private 
> branch. The reason for this is that we need to be able to undo such changes 
> if a commit hook later in the process fails the commit. Doing this 
> efficiently would need some support from the persistent layer. Either the 
> ability for branching from a branch or the ability to roll back to a previous 
> state. 
> See the TODOs in {{KernelNodeState.builder()}}, which returns a 
> MemoryNodeBuilder (instead of a KernelNodeBuilder when the current state is 
> on a branch. This is the workaround to avoid branching form a branch and has 
> the effect that commit hooks currently run against a MemoryNodeBuilder and 
> limits the amount of changes commit hooks can add.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to