Skip to content
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

Closed
wants to merge 14 commits into from
Closed

Conversation

icristescu
Copy link
Contributor

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.

@icristescu
Copy link
Contributor Author

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_lrus callback.
Note that the stores cannot share the same lru, as they have different value types.

@icristescu icristescu changed the title Clear + ro Clear and migration to version 2 Jul 27, 2020
src/irmin-http/irmin_http_server.ml Outdated Show resolved Hide resolved
src/irmin-test/store.ml Outdated Show resolved Hide resolved
src/irmin-pack/dict.ml Outdated Show resolved Hide resolved
src/irmin-pack/pack.ml Outdated Show resolved Hide resolved
src/irmin-pack/inode.ml Outdated Show resolved Hide resolved
src/irmin-pack/irmin_pack.ml Outdated Show resolved Hide resolved
src/irmin-pack/irmin_pack.ml Outdated Show resolved Hide resolved
src/irmin-pack/irmin_pack.ml Outdated Show resolved Hide resolved
src/irmin-pack/irmin_pack.ml Outdated Show resolved Hide resolved
src/irmin-pack/pack.ml Outdated Show resolved Hide resolved
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.
@icristescu icristescu force-pushed the clear_ro branch 2 times, most recently from abd10df to a6d1de4 Compare July 29, 2020 13:05
Copy link
Member

@craigfe craigfe left a 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.

CHANGES.md Outdated Show resolved Hide resolved

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. *)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
version. Raises [RO_Not_Allowed] if called by a readonly instance. *)
version. *)

Copy link
Contributor Author

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?

Comment on lines -143 to -145
if IO.version block <> current_version then
Fmt.failwith "invalid version: got %S, expecting %S" (IO.version block)
current_version;
Copy link
Member

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.

Copy link
Contributor Author

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)

test/irmin-pack/migration.ml Outdated Show resolved Hide resolved
Comment on lines +28 to +29
let cmd = Printf.sprintf "cp -rp %s %s" root_V1_source root_V1 in
Fmt.epr "exec: %s\n%!" cmd;
Copy link
Member

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.

Copy link
Contributor Author

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

| 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
Copy link
Member

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?

Copy link
Contributor Author

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
Copy link
Member

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...

Copy link
Contributor Author

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.

@icristescu
Copy link
Contributor Author

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).

+613050987us irmin.pack 784k contents / 6198k nodes / 17k commits
Thread 13 killed on uncaught exception Unix.Unix_error(24, "write", "")
Raised by primitive operation at file "src/unix/syscalls.ml" (inlined), line 11, characters 2-49
Raised by primitive operation at file "src/unix/raw.ml", line 33, characters 12-73
Called from file "src/unix/raw.ml" (inlined), line 60, characters 2-27
Called from file "src/unix/index_unix.ml", line 54, characters 6-47
Called from file "src/index.ml", line 565, characters 14-99
Called from file "src/index.ml", line 649, characters 18-71
Called from file "src/stats.ml", line 92, characters 15-19
Called from file "src/unix/index_unix.ml", line 290, characters 29-34
Re-raised at file "src/unix/index_unix.ml", line 293, characters 8-17
Called from file "thread.ml", line 39, characters 8-14

so we shouldn't merge this for now.

samoht added a commit to icristescu/irmin that referenced this pull request Aug 11, 2020
samoht added a commit to samoht/irmin that referenced this pull request Aug 11, 2020
samoht added a commit to samoht/irmin that referenced this pull request Aug 11, 2020
samoht added a commit to icristescu/irmin that referenced this pull request Aug 11, 2020
samoht added a commit to icristescu/irmin that referenced this pull request Aug 13, 2020
samoht added a commit to samoht/irmin that referenced this pull request Aug 18, 2020
@craigfe craigfe self-assigned this Aug 19, 2020
@samoht
Copy link
Member

samoht commented Aug 27, 2020

Closing as this has been merged part of #1071 and #1070

@samoht samoht closed this Aug 27, 2020
@icristescu icristescu deleted the clear_ro branch August 30, 2020 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants