In the current code, primary initiates pglog trim or peers inform
primary to trim when finishing recovery of the last object on it.
However, the pg is still in degraded/recovering/backfilling state
at that time and then the max log entries are kept. If there are
no IOs on this pg, it will hold up to the max number of log entries
in the memory, even if it's totally recovered.
Signed-off-by: Zhiqiang Wang <zhiqiang@xsky.com>
dout(10) << *pg << " replica osd." << from << " lcod " << m->trim_to << dendl;
pg->peer_last_complete_ondisk[pg_shard_t(from, m->pgid.shard)] =
m->trim_to;
- if (pg->calc_min_last_complete_ondisk()) {
- dout(10) << *pg << " min lcod now " << pg->min_last_complete_ondisk << dendl;
- pg->trim_peers();
- }
+ // trim log when the pg is recovered
+ pg->calc_min_last_complete_ondisk();
} else {
// primary is instructing us to trim
ObjectStore::Transaction t;
pg->publish_stats_to_osd();
}
+ // trim pglog on recovered
+ pg->trim_log();
+
// adjust acting set? (e.g. because backfill completed...)
bool history_les_bound = false;
if (pg->acting != pg->up && !pg->choose_acting(auth_log_shard,
last_complete_ondisk),
get_osdmap()->get_epoch());
} else {
- // we are the primary. tell replicas to trim?
- if (calc_min_last_complete_ondisk())
- trim_peers();
+ calc_min_last_complete_ondisk();
}
}