sstable_directory: Keep files_for_removal on scan_state
This list is the list of on-disk files, which is the property of filesystem scan state. When committing directory changes (read: removing those files) the list can be moved-from the state. Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
This commit is contained in:
@@ -77,7 +77,7 @@ sstable_directory::handle_component(components_lister::scan_state& state, sstabl
|
||||
// for instance on mutate_level. We should delete it - so we mark it for deletion
|
||||
// here, but just the component. The old statistics file should still be there
|
||||
// and we'll go with it.
|
||||
_files_for_removal.insert(filename.native());
|
||||
state.files_for_removal.insert(filename.native());
|
||||
break;
|
||||
case component_type::TOC:
|
||||
state.descriptors.emplace(desc.generation, std::move(desc));
|
||||
@@ -213,7 +213,7 @@ sstable_directory::process_sstable_dir(process_flags flags) {
|
||||
for (auto it = range.first; it != range.second; ++it) {
|
||||
auto& path = it->second;
|
||||
dirlog.trace("Scheduling to remove file {}, from an SSTable with a Temporary TOC", path.native());
|
||||
_files_for_removal.insert(path.native());
|
||||
state.files_for_removal.insert(path.native());
|
||||
}
|
||||
state.generations_found.erase(range.first, range.second);
|
||||
state.descriptors.erase(desc.generation);
|
||||
@@ -244,16 +244,17 @@ sstable_directory::process_sstable_dir(process_flags flags) {
|
||||
throw sstables::malformed_sstable_exception(format("At directory: {}: no TOC found for SSTable {}!. Refusing to boot", _sstable_dir.native(), path.native()));
|
||||
} else {
|
||||
dirlog.info("Found incomplete SSTable {} at directory {}. Removing", path.native(), _sstable_dir.native());
|
||||
_files_for_removal.insert(path.native());
|
||||
state.files_for_removal.insert(path.native());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
future<>
|
||||
sstable_directory::commit_directory_changes() {
|
||||
auto files_for_removal = std::exchange(_lister->_state->files_for_removal, {});
|
||||
_lister.reset();
|
||||
// Remove all files scheduled for removal
|
||||
return parallel_for_each(std::exchange(_files_for_removal, {}), [] (sstring path) {
|
||||
return parallel_for_each(std::move(files_for_removal), [] (sstring path) {
|
||||
dirlog.info("Removing file {}", path);
|
||||
return remove_file(std::move(path));
|
||||
});
|
||||
|
||||
@@ -74,6 +74,12 @@ public:
|
||||
scan_multimap generations_found;
|
||||
scan_descriptors temp_toc_found;
|
||||
scan_descriptors_map descriptors;
|
||||
|
||||
// SSTable files to be deleted: things with a Temporary TOC, missing TOC files,
|
||||
// TemporaryStatistics, etc. Not part of the scan state, because we want to do a 2-phase
|
||||
// delete: maybe one of the shards will have signaled an error. And in the case of an error
|
||||
// we don't want to delete anything.
|
||||
std::unordered_set<sstring> files_for_removal;
|
||||
};
|
||||
|
||||
directory_lister _lister;
|
||||
@@ -87,12 +93,6 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
// SSTable files to be deleted: things with a Temporary TOC, missing TOC files,
|
||||
// TemporaryStatistics, etc. Not part of the scan state, because we want to do a 2-phase
|
||||
// delete: maybe one of the shards will have signaled an error. And in the case of an error
|
||||
// we don't want to delete anything.
|
||||
std::unordered_set<sstring> _files_for_removal;
|
||||
|
||||
// prevents an object that respects a phaser (usually a table) from disappearing in the middle of the operation.
|
||||
// Will be destroyed when this object is destroyed.
|
||||
std::optional<utils::phased_barrier::operation> _operation_barrier;
|
||||
|
||||
Reference in New Issue
Block a user