New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clear and migration to version 2 #1015
Conversation
230c515
to
84617e0
Compare
This PR is now ready for reviews. It contains:
One issue is clearing the lru for the RO instance: (see commit dd3bcf6) |
After a clear, during a sync, the RO instance has to clear its lru as well, otherwise it will keep finding old values in the lru. To do this it check if the generation is updated in the pack IO. Contents, commits and nodes stores each have their own lru but share the same instance of pack IO. Therefore the first store to sync, updates pack IO and has to clear the lrus for all the other stores. This is achieved with a [clear_lru] callback.
abd10df
to
a6d1de4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I have a few nits, mostly about out-of-date comments.
|
||
val migrate : Irmin.config -> unit Lwt.t | ||
(** [migrate conf] migrates a store with configuration [conf] to the current | ||
version. Raises [RO_Not_Allowed] if called by a readonly instance. *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
version. Raises [RO_Not_Allowed] if called by a readonly instance. *) | |
version. *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it does raise this exception (https://github.com/mirage/irmin/pull/1015/files#diff-1beb7e2142825f197755316a39d00699R607). you think we shouldn't mention it?
if IO.version block <> current_version then | ||
Fmt.failwith "invalid version: got %S, expecting %S" (IO.version block) | ||
current_version; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check seems like it might still be worthwhile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use v
from irmin_pack and thus unsafe_v
from pack in the migrate function, so this needs to accept both V1 and V2. there is a check that files are in either V1 or V2 in IO (https://github.com/mirage/irmin/pull/1015/files#diff-8a044b6b9c9b0a69a5f770d759c9d1b9R264)
let cmd = Printf.sprintf "cp -rp %s %s" root_V1_source root_V1 in | ||
Fmt.epr "exec: %s\n%!" cmd; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to quote such commands with Filename.quote_command
for this to work with certain filepaths on Windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that this is only included in ocaml 4.10
test/irmin-pack/migration.ml
Outdated
| Some commit -> check r commit "check old values b" [ "b" ] "y" | ||
in | ||
(* dune removes the write permission from root_V1, we can only open it in | ||
readonly mode in the tests. We can migrate with a read-write pack, because |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can migrate with a read-write pack
Not sure what you mean here, since migrate
doesn't take a pack. Is this out-of-date?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the comment is not clear here indeed, I removed it
| None -> Alcotest.failf "branch foo not found" | ||
| Some commit -> check r commit "check old values b" [ "b" ] "y" | ||
in | ||
(* dune removes the write permission from root_V1, we can only open it in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dune removes the write permission from root_V1
We could use install
rather than cp
if this is a problem. I have no idea what the Windows portability is like for this though...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the issue is the copy from the deps source_tree
stanza, which removes the write permissions for testV1.
it's ok to open the store in the readonly mode in this test. and it made me realise that I only need to open it in RO in the migrate function too, so it is a good constraint from dune.
Co-authored-by: Craig Ferguson <me@craigfe.io>
I get the following exception when I try to migrate the archive store from comanche (The testing branch is here https://github.com/icristescu/tezos/tree/migrate).
so we shouldn't merge this for now. |
It depends on #1008 and #939. (I hesitated to add it in one of the two PR already opened, but it really needs both for the tests).
It's only the latest commit that is new w.r.t the two other PRs.
Clear is used when opening a fresh instance. Because of this an unrelated test is failing (it did not properly closed the store before) and so I commented out. I'll make a separate PR to remove and explain it.