From 47516d9c4b7f023f3a16e166749fa7b1c7b3b24c Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Thu, 18 Jul 2013 19:26:02 -0700 Subject: [PATCH] ReplicatedPG: track temp collection contents, clear during on_change We also assert in on_flushed() that the temp collection is actually empty. Fixes: #5670 Signed-off-by: Samuel Just Reviewed-by: Sage Weil --- src/osd/ReplicatedPG.cc | 34 +++++++++++++++++++++++++++++++--- src/osd/ReplicatedPG.h | 3 +++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 60b59738d533f..9c8d42dbf3c67 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -5517,10 +5517,14 @@ void ReplicatedPG::submit_push_data( ObjectStore::Transaction *t) { coll_t target_coll; - if (first && complete) + if (first && complete) { target_coll = coll; - else + } else { + dout(10) << __func__ << ": Creating oid " + << recovery_info.soid << " in the temp collection" << dendl; + temp_contents.insert(recovery_info.soid); target_coll = get_temp_coll(t); + } if (first) { pg_log.revise_have(recovery_info.soid, eversion_t()); @@ -5547,8 +5551,13 @@ void ReplicatedPG::submit_push_data( attrs); if (complete) { - if (!first) + if (!first) { + assert(temp_contents.count(recovery_info.soid)); + dout(10) << __func__ << ": Removing oid " + << recovery_info.soid << " from the temp collection" << dendl; + temp_contents.erase(recovery_info.soid); t->collection_move(coll, target_coll, recovery_info.soid); + } submit_push_complete(recovery_info, t); } @@ -6702,6 +6711,15 @@ void ReplicatedPG::on_shutdown() void ReplicatedPG::on_flushed() { assert(object_contexts.empty()); + if (have_temp_coll() && + !osd->store->collection_empty(get_temp_coll())) { + vector objects; + osd->store->collection_list(get_temp_coll(), objects); + derr << __func__ << ": found objects in the temp collection: " + << objects << ", crashing now" + << dendl; + assert(0 == "found garbage in the temp collection"); + } } void ReplicatedPG::on_activate() @@ -6751,6 +6769,16 @@ void ReplicatedPG::on_change(ObjectStore::Transaction *t) pulling.clear(); pull_from_peer.clear(); + // clear temp + for (set::iterator i = temp_contents.begin(); + i != temp_contents.end(); + ++i) { + dout(10) << __func__ << ": Removing oid " + << *i << " from the temp collection" << dendl; + t->remove(get_temp_coll(t), *i); + } + temp_contents.clear(); + // clear snap_trimmer state snap_trimmer_machine.process_event(Reset()); diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index 8fc21a8806806..0d4867f6e6ded 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -551,6 +551,9 @@ protected: }; map pulling; + // Track contents of temp collection, clear on reset + set temp_contents; + ObjectRecoveryInfo recalc_subsets(const ObjectRecoveryInfo& recovery_info); static void trim_pushed_data(const interval_set ©_subset, const interval_set &intervals_received, -- 2.39.5