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

Jukka Zitting commented on OAK-1357:
------------------------------------

-0 I don't think the use case is strong enough to justify a separate method for 
now.

Note that a typical restore from backup involves recreating the entire 
repository from scratch, not moving back in time within an existing and fully 
functional repository. Such a [point-in-time 
recovery|http://en.wikipedia.org/wiki/Point-in-time_recovery] feature is of 
course nice, but it doesn't address the stated use case of recovering from an 
external backup.

Further, the following piece of code should already achieve the suggested 
feature (though you're right in that an explicit method could additionally 
guarantee the failing of any other pending transactions):

{code}
NodeStore store = ...;
String checkpoint = ...;
NodeState before = store.retrieve(checkpoint);
NodeState after = store.getRoot();
NodeBuilder builder = root.builder();
before.compareAgainstBaseState(after, new ApplyDiff(builder));
store.merge(builder, EmptyHook.INSTANCE, null);
{code}

The benefit of using the above pattern instead of the proposed {{restore()}} 
method is that it's possible to selectively revert just parts of the repository 
to an earlier, known good state. That's what point-in-time recovery systems 
(Time Machine, etc.) are typically used for.

> Add 'restore' method to NodeStore apis
> --------------------------------------
>
>                 Key: OAK-1357
>                 URL: https://issues.apache.org/jira/browse/OAK-1357
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: core
>            Reporter: Alex Parvulescu
>            Assignee: Alex Parvulescu
>
> OAK-762 introduced a checkpoint mechanism which allows for the creation of a 
> snapshot of the current state, referenced by a string.
> Other than internally for the async indexing I'd like to leverage this in the 
> case of an external (non blocking!) backup process (for both mongomk and 
> rdbstore) and probably for the tarmk simple failover scenario.
> What is currently missing is an option to restore the current state to a 
> captured snapshot, which is the point of this issue.
> I'm proposing we add a _ #restore(String checkpoint)_ method to the NodeStore 
> apis which resets the current head to the provided state. 
> This could probably throw an exception in the case the provided checkpoint 
> doesn't exist, and it would also fail ongoing transactions as they don't 
> apply anymore.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to