WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

[Xen-API] [PATCH 4 of 7] CA-34933: gc intrapool sessions independently o

To: xen-api <xen-api@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-API] [PATCH 4 of 7] CA-34933: gc intrapool sessions independently of normal sessions
From: Marcus Granado <marcus.granado@xxxxxxxxxx>
Date: Fri, 21 May 2010 14:46:07 +0100
Delivery-date: Fri, 21 May 2010 06:56:43 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1274449563@localhost>
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
References: <patchbomb.1274449563@localhost>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.4.3
 ocaml/xapi/db_gc.ml |  19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)


# HG changeset patch
# User Marcus Granado <marcus.granado@xxxxxxxxxx>
# Date 1274449016 -3600
# Node ID 73391140afa5c39e819adcac880d385ca7b1a14c
# Parent  3678824a34447601d81a115c6e83b8e7b2b06c99
CA-34933: gc intrapool sessions independently of normal sessions

Signed-off-by: Marcus Granado <marcus.granado@xxxxxxxxxxxxx>

diff -r 3678824a3444 -r 73391140afa5 ocaml/xapi/db_gc.ml
--- a/ocaml/xapi/db_gc.ml
+++ b/ocaml/xapi/db_gc.ml
@@ -206,10 +206,8 @@
 let task_status_is_completed task_status =
     (task_status=`success) || (task_status=`failure) || 
(task_status=`cancelled)
 
-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 unused_sessions = List.filter (fun (_, y) -> List.for_all (fun t -> 
task_status_is_completed (Db.Task.get_status ~__context ~self:t)) 
y.Db_actions.session_tasks) not_intrapool_sessions in
+let timeout_sessions_common ~__context sessions =
+  let unused_sessions = List.filter (fun (_, y) -> List.for_all (fun t -> 
task_status_is_completed (Db.Task.get_status ~__context ~self:t)) 
y.Db_actions.session_tasks) sessions in
   let disposable_sessions = unused_sessions in
   (* Only keep a list of (ref, last_active, uuid) *)
   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
@@ -231,10 +229,21 @@
         ) sessions in
   (* Only the 'lucky' survive: the 'old' and 'unlucky' are destroyed *)
   if unlucky <> [] 
-  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;
+  then debug "Number of disposable sessions in database (%d/%d) exceeds limit 
(%d): will delete the oldest" (List.length disposable_sessions) (List.length 
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
 
+let timeout_sessions ~__context =
+  let all_sessions =
+    Db.Session.get_internal_records_where ~__context ~expr:Db_filter_types.True
+  in
+  let (intrapool_sessions, normal_sessions) =
+    List.partition (fun (_, y) -> y.Db_actions.session_pool) all_sessions
+  in begin
+    timeout_sessions_common ~__context normal_sessions;
+    timeout_sessions_common ~__context intrapool_sessions;
+  end
+
 let timeout_tasks ~__context =
   let all_tasks = Db.Task.get_internal_records_where ~__context 
~expr:Db_filter_types.True in
   let oldest_completed_time = Unix.time() -. Xapi_globs.completed_task_timeout 
(* time out completed tasks after 65 minutes *) in

Attachment: xen-api.hg-4.patch
Description: Text Data

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api