database: change find_column_families signature so it returns a lw_shared_ptr
There are places in which we need to use the column family object many times, with deferring points in between. Because the column family may have been destroyed in the deferring point, we need to go and find it again. If we use lw_shared_ptr, however, we'll be able to at least guarantee that the object will be alive. Some users will still need to check, if they want to guarantee that the column family wasn't removed. But others that only need to make sure we don't access an invalid object will be able to avoid the cost of re-finding it just fine. Signed-off-by: Glauber Costa <glauber@scylladb.com> Message-Id: <722bf49e158da77ff509372c2034e5707706e5bf.1478111467.git.glauber@scylladb.com>
This commit is contained in:
committed by
Tomasz Grabiec
parent
75706c0a26
commit
f3528ede65
@@ -251,25 +251,25 @@ future<> db::commitlog_replayer::impl::process(stats* s, temporary_buffer<char>
|
||||
// TODO: might need better verification that the deserialized mutation
|
||||
// is schema compatible. My guess is that just applying the mutation
|
||||
// will not do this.
|
||||
auto& cf = db.find_column_family(fm.column_family_id());
|
||||
auto cf = db.find_column_family(fm.column_family_id());
|
||||
|
||||
if (logger.is_enabled(logging::log_level::debug)) {
|
||||
logger.debug("replaying at {} v={} {}:{} at {}", fm.column_family_id(), fm.schema_version(),
|
||||
cf.schema()->ks_name(), cf.schema()->cf_name(), rp);
|
||||
cf->schema()->ks_name(), cf->schema()->cf_name(), rp);
|
||||
}
|
||||
// Removed forwarding "new" RP. Instead give none/empty.
|
||||
// This is what origin does, and it should be fine.
|
||||
// The end result should be that once sstables are flushed out
|
||||
// their "replay_position" attribute will be empty, which is
|
||||
// lower than anything the new session will produce.
|
||||
if (cf.schema()->version() != fm.schema_version()) {
|
||||
if (cf->schema()->version() != fm.schema_version()) {
|
||||
const column_mapping& cm = cm_it->second;
|
||||
mutation m(fm.decorated_key(*cf.schema()), cf.schema());
|
||||
converting_mutation_partition_applier v(cm, *cf.schema(), m.partition());
|
||||
mutation m(fm.decorated_key(*cf->schema()), cf->schema());
|
||||
converting_mutation_partition_applier v(cm, *cf->schema(), m.partition());
|
||||
fm.partition().accept(cm, v);
|
||||
cf.apply(std::move(m));
|
||||
cf->apply(std::move(m));
|
||||
} else {
|
||||
cf.apply(fm, cf.schema());
|
||||
cf->apply(fm, cf->schema());
|
||||
}
|
||||
s->applied_mutations++;
|
||||
return make_ready_future<>();
|
||||
|
||||
Reference in New Issue
Block a user