Stray objects should have been cleaned up in the merge_log
transactions. Only on the primary have those operations
necessarily been flushed at activate().
Fixes: 5084
Signed-off-by: Samuel Just <sam.just@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
(cherry picked from commit
278c7b59228f614addf830cb0afff4988c9bc8cb)
OPTION(osd_debug_drop_op_probability, OPT_DOUBLE, 0) // probability of stalling/dropping a client op
OPTION(osd_debug_op_order, OPT_BOOL, false)
OPTION(osd_debug_verify_snaps_on_info, OPT_BOOL, false)
+OPTION(osd_debug_verify_stray_on_activate, OPT_BOOL, false)
OPTION(osd_debug_skip_full_check_in_backfill_reservation, OPT_BOOL, false)
OPTION(osd_op_history_size, OPT_U32, 20) // Max number of completed ops to track
OPTION(osd_op_history_duration, OPT_U32, 600) // Oldest completed op to track
dirty_info = true;
dirty_big_info = true; // maybe
- // clean up stray objects
- clean_up_local(t);
+ // verify that there are no stray objects
+ if (is_primary())
+ check_local();
// find out when we commit
tfin.push_back(new C_PG_ActivateCommitted(this, query_epoch));
return missing.num_missing() - missing_loc.size();
}
- virtual void clean_up_local(ObjectStore::Transaction& t) = 0;
+ virtual void check_local() = 0;
virtual int start_recovery_ops(int max, RecoveryCtx *prctx) = 0;
}
-/** clean_up_local
- * remove any objects that we're storing but shouldn't.
- * as determined by log.
+/** check_local
+ *
+ * verifies that stray objects have been deleted
*/
-void ReplicatedPG::clean_up_local(ObjectStore::Transaction& t)
+void ReplicatedPG::check_local()
{
- dout(10) << "clean_up_local" << dendl;
+ dout(10) << __func__ << dendl;
assert(info.last_update >= log.tail); // otherwise we need some help!
+ if (!g_conf->osd_debug_verify_stray_on_activate)
+ return;
+
// just scan the log.
set<hobject_t> did;
for (list<pg_log_entry_t>::reverse_iterator p = log.log.rbegin();
did.insert(p->soid);
if (p->is_delete()) {
- dout(10) << " deleting " << p->soid
- << " when " << p->version << dendl;
- remove_snap_mapped_object(t, p->soid);
+ dout(10) << " checking " << p->soid
+ << " at " << p->version << dendl;
+ struct stat st;
+ int r = osd->store->stat(coll, p->soid, &st);
+ if (r != -ENOENT) {
+ dout(10) << "Object " << p->soid << " exists, but should have been "
+ << "deleted" << dendl;
+ assert(0 == "erroneously present object");
+ }
} else {
- // keep old(+missing) objects, just for kicks.
+ // ignore old(+missing) objects
}
}
}
int prepare_transaction(OpContext *ctx);
// pg on-disk content
- void clean_up_local(ObjectStore::Transaction& t);
+ void check_local();
void _clear_recovery_state();