[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-API] [PATCH] Fix deadlock in RRD code



# HG changeset patch
# User Jonathan Ludlam <jonathan.ludlam@xxxxxxxxxxxxx>
# Date 1268068602 0
# Node ID 793489e20822ab8f58e3770f847490f030fb26b3
# Parent  10ddf24a5547597a839e47eb43d101a48370c83e
CA-36940: Fix a deadlock in the RRD code

Signed-off-by: Jonathan Ludlam <jonathan.ludlam@xxxxxxxxxxxxx>

diff -r 10ddf24a5547 -r 793489e20822 ocaml/xapi/monitor_rrds.ml
--- a/ocaml/xapi/monitor_rrds.ml        Mon Mar 08 17:15:17 2010 +0000
+++ b/ocaml/xapi/monitor_rrds.ml        Mon Mar 08 17:16:42 2010 +0000
@@ -108,6 +108,19 @@
     Unixext.read_whole_file_to_string path 
   end
 
+
+let use_min_max = ref false 
+
+let update_use_min_max () =
+  Server_helpers.exec_with_new_task "rrd_update_min_max" (fun __context -> 
+    let oc = Db.Pool.get_other_config ~__context ~self:(Helpers.get_pool 
~__context) in
+    let new_use_min_max =  (List.mem_assoc 
Xapi_globs.create_min_max_in_new_VM_RRDs oc) && 
+      (List.assoc Xapi_globs.create_min_max_in_new_VM_RRDs oc = "true")
+    in
+    debug "Updating use_min_max: New value=%b" new_use_min_max;
+    use_min_max := new_use_min_max)
+
+    
 
 (** Here is the only place where RRDs are created. The timescales are fixed. 
If other timescales
     are required, this could be done externally. The types of archives created 
are also fixed.
@@ -676,12 +689,8 @@
              with
                | Not_found ->
                    debug "Creating fresh RRD for VM uuid=%s" vm_uuid;
-                   let use_min_max = 
-                     let oc = Db.Pool.get_other_config ~__context 
~self:(Helpers.get_pool ~__context) in
-                     (List.mem_assoc Xapi_globs.create_min_max_in_new_VM_RRDs 
oc) && 
-                       (List.assoc Xapi_globs.create_min_max_in_new_VM_RRDs oc 
= "true")
-                   in
-                   let rrd = create_fresh_rrd use_min_max dss in
+
+                   let rrd = create_fresh_rrd (!use_min_max) dss in
                    Hashtbl.replace vm_rrds vm_uuid {rrd=rrd; dss=dss}
                | e ->
                    raise e
diff -r 10ddf24a5547 -r 793489e20822 ocaml/xapi/rrd_shared.ml
--- a/ocaml/xapi/rrd_shared.ml  Mon Mar 08 17:15:17 2010 +0000
+++ b/ocaml/xapi/rrd_shared.ml  Mon Mar 08 17:16:42 2010 +0000
@@ -34,6 +34,12 @@
 (* strings are uuids *)
 type ds_type = VM of string | Host | SR of string
 
+(* Mutex to protect the shared data.
+ *
+ * Warning: Do not do any DB calls with this mutex held! A possible side effect
+ * of a DB call will be resetting the 'dirty' status below, requiring 
acquisition
+ * of this lock, resulting in a deadlock! 
+ *) 
 let mutex = Mutex.create ()
 
 (* RRDs *)               
diff -r 10ddf24a5547 -r 793489e20822 ocaml/xapi/xapi.ml
--- a/ocaml/xapi/xapi.ml        Mon Mar 08 17:15:17 2010 +0000
+++ b/ocaml/xapi/xapi.ml        Mon Mar 08 17:16:42 2010 +0000
@@ -815,8 +815,9 @@
        Master_connection.restart_on_connection_timeout := true;
        Master_connection.on_database_connection_established := (fun () -> 
on_master_restart ~__context);
     end;
-                                                                               
            
+ 
     Startup.run ~__context [
+      "Initialise Monitor_rrds.use_min_max", [], 
Monitor_rrds.update_use_min_max;
       "Initialising licensing", [], handle_licensing;
       "control domain memory", [ Startup.OnThread ], control_domain_memory;
       "message_hook_thread", [ Startup.NoExnRaising ], 
Xapi_message.start_message_hook_thread;
diff -r 10ddf24a5547 -r 793489e20822 ocaml/xapi/xapi_periodic_scheduler_init.ml
--- a/ocaml/xapi/xapi_periodic_scheduler_init.ml        Mon Mar 08 17:15:17 
2010 +0000
+++ b/ocaml/xapi/xapi_periodic_scheduler_init.ml        Mon Mar 08 17:16:42 
2010 +0000
@@ -99,4 +99,5 @@
   Xapi_periodic_scheduler.add_to_queue "Logrotate" 
(Xapi_periodic_scheduler.Periodic logrotate_timer) 120.0 logrotate_func;
   Xapi_periodic_scheduler.add_to_queue "Network bridge GC" 
(Xapi_periodic_scheduler.Periodic networkgc_timer) networkgc_timer 
networkgc_func;
   Xapi_periodic_scheduler.add_to_queue "Periodic scheduler heartbeat" 
(Xapi_periodic_scheduler.Periodic hb_timer) 240.0 hb_func;
+  Xapi_periodic_scheduler.add_to_queue "Query use_min_max for RRDs" 
(Xapi_periodic_scheduler.Periodic 3600.0) 3600.0 Monitor_rrds.update_use_min_max
 
4 files changed, 24 insertions(+), 7 deletions(-)
ocaml/xapi/monitor_rrds.ml                 |   21 +++++++++++++++------
ocaml/xapi/rrd_shared.ml                   |    6 ++++++
ocaml/xapi/xapi.ml                         |    3 ++-
ocaml/xapi/xapi_periodic_scheduler_init.ml |    1 +


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

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

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.