]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/PaxosService: trim periodically instead of via propose_pending
authorSage Weil <sage@inktank.com>
Tue, 9 Jul 2013 04:38:11 +0000 (21:38 -0700)
committerSage Weil <sage@inktank.com>
Tue, 9 Jul 2013 04:38:11 +0000 (21:38 -0700)
We want to trim old states even if there is no update activity.  For
example, if a long-running rebalance finishes all osdmap updates will
stop and we won't trim out old maps to free space.

Instead, trim at the same time as tick().  Remove the trim during
propose_pending() to force all trims through this path and avoid
introducing a new and rarely-exercised behavior.

Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Joao Eduardo Luis <joao.luis@inktank.com>
src/mon/Monitor.cc
src/mon/PaxosService.cc
src/mon/PaxosService.h

index df09ff84799ef393897bbc4464449f492ebea326..76efc6c21e45a719862d78a17332775750e9b1c6 100644 (file)
@@ -4139,6 +4139,7 @@ void Monitor::tick()
   
   for (vector<PaxosService*>::iterator p = paxos_service.begin(); p != paxos_service.end(); ++p) {
     (*p)->tick();
+    (*p)->maybe_trim();
   }
   
   // trim sessions
index fcfc3c88b53f991d9dcb00d32b11242c46a0f09a..7be5f9f6b1c3c4236ce364506ec9ffb1363bb2b7 100644 (file)
@@ -185,14 +185,9 @@ void PaxosService::propose_pending()
   MonitorDBStore::Transaction t;
   bufferlist bl;
 
-  update_trim();
   if (should_stash_full())
     encode_full(&t);
 
-  if (should_trim()) {
-    encode_trim(&t);
-  }
-
   encode_pending(&t);
   have_pending = false;
 
@@ -326,6 +321,20 @@ void PaxosService::shutdown()
   finish_contexts(g_ceph_context, waiting_for_finished_proposal, -EAGAIN);
 }
 
+void PaxosService::maybe_trim()
+{
+  if (is_writeable() && should_trim()) {
+    dout(10) << __func__ << " trimming" << dendl;
+
+    MonitorDBStore::Transaction t;
+    encode_trim(&t);
+    bufferlist bl;
+    t.encode(bl);
+
+    paxos->propose_new_value(bl, new C_Committed(this));
+  }
+}
+
 bool PaxosService::should_trim()
 {
   if (!service_should_trim())
index 18d95307ef4234f25f1261c7fcdef806dce490ed..3d9d8acd00fe7a0225c6fe73897a91e35b552802 100644 (file)
@@ -468,6 +468,11 @@ public:
    */
   virtual void tick() {}
 
+  /**
+   * called at same interval as tick.  consider a trim.
+   */
+  void maybe_trim();
+
   /**
    * Get health information
    *