move deletion of sstables generated by interrupted compaction

This deletion should be handled by sstables::compact_sstables, which
is the responsible for creation of new sstables.
It also simplifies the code.

Signed-off-by: Raphael S. Carvalho <raphaelsc@scylladb.com>
Message-Id: <541206be2e910ab4edb1500b098eb5ebf29c6509.1454110234.git.raphaelsc@scylladb.com>
This commit is contained in:
Raphael S. Carvalho
2016-01-29 21:35:31 -02:00
committed by Avi Kivity
parent 7214649b8a
commit ee84f310d9
2 changed files with 9 additions and 14 deletions

View File

@@ -777,19 +777,6 @@ column_family::compact_sstables(sstables::compaction_descriptor descriptor, bool
return sstables::compact_sstables(*sstables_to_compact, *this,
create_sstable, descriptor.max_sstable_bytes, descriptor.level, cleanup).then([this, new_tables, sstables_to_compact] {
this->rebuild_sstable_list(*new_tables, *sstables_to_compact);
}).then_wrapped([this, new_tables] (future<> f) {
try {
f.get();
} catch (...) {
// Delete either partially or fully written sstables of a compaction that
// was either stopped abruptly (e.g. out of disk space) or deliberately
// (e.g. nodetool stop COMPACTION).
for (auto& sst : *new_tables) {
dblog.debug("Deleting sstable {} of interrupted compaction for {}/{}", sst->get_filename(), _schema->ks_name(), _schema->cf_name());
sst->mark_for_deletion();
}
throw;
}
});
});
}

View File

@@ -272,6 +272,7 @@ future<> compact_sstables(std::vector<shared_sstable> sstables, column_family& c
output_reader->unread(std::move(*mut));
auto newtab = creator();
info->new_sstables.push_back(newtab);
newtab->get_metadata_collector().set_replay_position(rp);
newtab->get_metadata_collector().sstable_level(sstable_level);
for (auto ancestor : *ancestors) {
@@ -283,7 +284,6 @@ future<> compact_sstables(std::vector<shared_sstable> sstables, column_family& c
auto&& priority = service::get_local_compaction_priority();
return newtab->write_components(std::move(mutation_queue_reader), partitions_per_sstable, schema, max_sstable_size, backup, priority).then([newtab, info] {
return newtab->open_data().then([newtab, info] {
info->new_sstables.push_back(newtab);
info->end_size += newtab->data_size();
return make_ready_future<stop_iteration>(stop_iteration::no);
});
@@ -310,6 +310,14 @@ future<> compact_sstables(std::vector<shared_sstable> sstables, column_family& c
}
if (ex.size()) {
// Delete either partially or fully written sstables of a compaction that
// was either stopped abruptly (e.g. out of disk space) or deliberately
// (e.g. nodetool stop COMPACTION).
for (auto& sst : info->new_sstables) {
logger.debug("Deleting sstable {} of interrupted compaction for {}/{}", sst->get_filename(), info->ks, info->cf);
sst->mark_for_deletion();
}
throw std::runtime_error(ex);
}
}).then([start_time, info, cleanup] {