From 39b71c582628d26e749c23343aa69db079ee40a1 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 8 Jul 2013 21:38:11 -0700 Subject: [PATCH] mon/PaxosService: trim periodically instead of via propose_pending 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 Reviewed-by: Joao Eduardo Luis --- src/mon/Monitor.cc | 1 + src/mon/PaxosService.cc | 19 ++++++++++++++----- src/mon/PaxosService.h | 5 +++++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index df09ff84799e..76efc6c21e45 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -4139,6 +4139,7 @@ void Monitor::tick() for (vector::iterator p = paxos_service.begin(); p != paxos_service.end(); ++p) { (*p)->tick(); + (*p)->maybe_trim(); } // trim sessions diff --git a/src/mon/PaxosService.cc b/src/mon/PaxosService.cc index fcfc3c88b53f..7be5f9f6b1c3 100644 --- a/src/mon/PaxosService.cc +++ b/src/mon/PaxosService.cc @@ -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()) diff --git a/src/mon/PaxosService.h b/src/mon/PaxosService.h index 18d95307ef42..3d9d8acd00fe 100644 --- a/src/mon/PaxosService.h +++ b/src/mon/PaxosService.h @@ -468,6 +468,11 @@ public: */ virtual void tick() {} + /** + * called at same interval as tick. consider a trim. + */ + void maybe_trim(); + /** * Get health information * -- 2.47.3