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

Closing merge file_descr when aborting #326

Merged
merged 7 commits into from
Jul 15, 2021
Merged

Conversation

mattiasdrp
Copy link
Contributor

Fixes #325

src/index.ml Outdated Show resolved Hide resolved
@mattiasdrp
Copy link
Contributor Author

dune exec test/unix/main.exe -- test "close" 8

Gives

┌──────────────────────────────────────────────────────────┐
│ [FAIL]        close                   8   aborted merge. │
└──────────────────────────────────────────────────────────┘
FAIL Too many file descriptors opened for merge files
──────────────────────────────────────────────────────────

Without this PR and

[OK]          close                   8   aborted merge.

with this PR.

It actually made me realise that there's another file descriptor that's not closed, log_async:

File descriptors:
  _tests/unix.main/index_1/index/data (deleted)
  _tests/unix.main/index_1/index/log_async (deleted)
  _tests/unix.main/index_1/index/log_async

test/unix/main.ml Outdated Show resolved Hide resolved
@@ -714,6 +714,8 @@ module Close = struct
let* Context.{ rw; _ } =
Context.with_full_index ~throttle:`Block_writes ~size:100 ()
in
let root = Index.root rw in
Copy link
Contributor

Choose a reason for hiding this comment

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

there is a root global variable already defined in this file, can you reuse it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, yes, don't know how I missed it, thanks! And thanks for the review :-)

@@ -188,3 +188,48 @@ let check_disjoint index htbl =
Alcotest.failf "Found value %a when checking for the absence of %a"
(Repr.pp Value.t) v' pp_binding (k, v))
htbl

let get_open_fd root =
Copy link
Contributor

Choose a reason for hiding this comment

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

there is a bit of code duplication with test_fd in the force_merge tests, can you maybe combine the two functions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. I replaced the /tmp directory used to look for the files with root since all the files are created there from what I can see

src/index.ml Outdated
@@ -1034,6 +1036,9 @@ struct

let close = close' ~hook:(fun _ -> ())

let root it =
Copy link
Contributor

Choose a reason for hiding this comment

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

you don't need this function anymore, no?

let lsof_command = "lsof -a -s -p " ^ pid ^ " > " ^ fd_file in
let lines = Common.get_open_fd root in
(* Not sure that looking in /tmp is correct since all the writes
* are done in root *)
Copy link
Contributor

Choose a reason for hiding this comment

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

good catch! let's remove this comment, it does not make sense now.

Copy link
Contributor

@icristescu icristescu left a comment

Choose a reason for hiding this comment

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

Thanks!

@icristescu icristescu merged commit 1132a0b into mirage:master Jul 15, 2021
@samoht samoht mentioned this pull request Jul 15, 2021
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.

Close fd when aborting a merge
2 participants