# HG changeset patch # User Marcus Granado # Date 1274449016 -3600 # Node ID d14022d7376eae45eb056c5c9caa61eadb883358 # Parent 96d378af31d020fa0b3a961fbe6904618254de6d CA-34933: do not gc intrapool sessions Signed-off-by: Marcus Granado diff -r 96d378af31d0 -r d14022d7376e ocaml/xapi/db_gc.ml --- a/ocaml/xapi/db_gc.ml +++ b/ocaml/xapi/db_gc.ml @@ -205,11 +205,13 @@ let timeout_sessions ~__context = let all_sessions = Db.Session.get_internal_records_where ~__context ~expr:Db_filter_types.True in + let not_intrapool_sessions = List.filter (fun (_, y) -> not y.Db_actions.session_pool) all_sessions in + let disposable_sessions = not_intrapool_sessions in (* Only keep a list of (ref, last_active, uuid) *) - let all_sessions = List.map (fun (x, y) -> x, Date.to_float y.Db_actions.session_last_active, y.Db_actions.session_uuid) all_sessions in + let disposable_sessions = List.map (fun (x, y) -> x, Date.to_float y.Db_actions.session_last_active, y.Db_actions.session_uuid) disposable_sessions in (* Definitely invalidate sessions last used long ago *) let threshold_time = Unix.time () -. Xapi_globs.inactive_session_timeout in - let young, old = List.partition (fun (_, y, _) -> y > threshold_time) all_sessions in + let young, old = List.partition (fun (_, y, _) -> y > threshold_time) disposable_sessions in (* If there are too many young sessions then we need to delete the oldest *) let lucky, unlucky = if List.length young <= Xapi_globs.max_sessions @@ -225,7 +227,7 @@ ) sessions in (* Only the 'lucky' survive: the 'old' and 'unlucky' are destroyed *) if unlucky <> [] - then debug "Number of sessions in database (%d) exceeds limit (%d): will delete the oldest" (List.length all_sessions) Xapi_globs.max_sessions; + then debug "Number of disposable sessions in database (%d/%d) exceeds limit (%d): will delete the oldest" (List.length disposable_sessions) (List.length all_sessions) Xapi_globs.max_sessions; cancel "Timed out session because of its age" old; cancel "Timed out session because max number of sessions was exceeded" unlucky