-
Notifications
You must be signed in to change notification settings - Fork 21
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
xen-api-client.lwt leaks file descriptors in xapi #45
Comments
The following program using open Lwt;;
let host = "..."
let uname = "..."
let pwd = "..."
let rpc =
let host_uri = "http://" ^ host in
Xen_api_lwt_unix.make host_uri;;
let rec loop n =
if (n > 0) then begin
Lwt_io.printlf "logging in %d" n >>= fun () ->
Xen_api_lwt_unix.Session.login_with_password ~rpc ~uname ~pwd ~version:"1.0" ~originator:"leak_test" >>= fun session_id ->
Xen_api_lwt_unix.Session.logout ~rpc ~session_id >>= fun () ->
loop (n - 1)
end else Lwt.return_unit
in
Lwt_main.run (loop 1030);;
(* Compile with:
ocamlfind ocamlc -o test_xen_xapi_client -linkpkg -package lwt -package xen-api-client.lwt test_xen_api_client.ml
*) On the XenServer host, the file descriptor usage of xapi can be monitored using the following command:
The following program using let () =
let host = "..." in
let uname = "..." in
let pwd = "..." in
let rpc xml =
let open Xmlrpc_client in
let http = xmlrpc ~version:"1.0" "/" in
XMLRPC_protocol.rpc ~srcstr:"test" ~dststr:"xapi"
~transport:(TCP (host, 80)) ~http xml
in
for i = 1 to 1030 do
Printf.printf "logging in %d\n%!" i;
let session_id = Client.Client.Session.login_with_password ~rpc ~uname ~pwd ~version:"1.0" ~originator:"leak_test" in
Client.Client.Session.logout ~rpc ~session_id
done
(* Compile with:
ocamlfind ocamlc -o test_xapi_client -linkpkg -package lwt -package xapi-client -thread test_xapi_client.ml
*) |
Isn't that a problem of the library user instead of the library? I guess we could provide a with_session helper that takes care of logging out, but it should really be whomever uses the library that takes care of reusing a session or opening/closing them |
I think we have an issue if the following leaks file descriptors open Lwt;;
let host = "..."
let uname = "..."
let pwd = "..."
let rpc =
let host_uri = "http://" ^ host in
Xen_api_lwt_unix.make host_uri;;
let rec loop n =
if (n > 0) then begin
Lwt_io.printlf "logging in %d" n >>= fun () ->
Xen_api_lwt_unix.Session.login_with_password ~rpc ~uname ~pwd ~version:"1.0" ~originator:"leak_test" >>= fun _session_id ->
Lwt_io.printlf "logged in %d" n >>= fun () ->
Lwt_io.printlf "loggin out %d" n >>= fun () ->
Xen_api_lwt_unix.Session.logout ~rpc ~session_id >>= fun () ->
Lwt_io.printlf "logged out %d" n >>= fun () ->
loop (n - 1)
end else Lwt.return_unit
in
Lwt_main.run (loop 1000);; |
@mseri the above does leak, I posted the wrong snippet, sorry, that code shouldn't have been commented out. I've updated my comment. |
Then we have a problem :P |
This has caused an issue in xapi-nbd as well, where after about 190 connect/disconnect loops it broke xapi, which could not process subsequent commands due to too many open files:
The error in
|
Interestingly, I saw the same behaviour when I commented out the |
Tried with xapi-nbd and Lwt 2.7.1, still failed. xapi-nbd reported:
xapi essentially stopped working:
It had 1051 open file descriptors:
The interesting thing is, that in case of the above repro, xapi can clean up the leaked file descriptors somehow, and any further connection from the client, while with xapi-nbd, it doesn't do that, it just stops working. |
The source of the problem is the difference in the behaviour of the |
When the xen-api-client client library is used, instead of xapi's built-in xapi-client library, as a client keeps logging in and then logging out, the file descriptors of xapi will keep increasing until about 1000, when it will drop back to 80, and the client will get the following error:
When using xapi-client, the number of file descriptors used by xapi stays at about 81.
Might be related to #31
The text was updated successfully, but these errors were encountered: