mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-12 19:02:12 +00:00
database: Make add_sstable() have strong exception guarantees
If insert() fails, we left the database with stats updated, but sstable not being attached.
This commit is contained in:
@@ -785,7 +785,7 @@ void column_family::load_sstable(sstables::shared_sstable& sst, bool reset_level
|
||||
add_sstable(sst, std::move(shards));
|
||||
}
|
||||
|
||||
void column_family::update_stats_for_new_sstable(uint64_t disk_space_used_by_sstable, std::vector<unsigned>&& shards_for_the_sstable) {
|
||||
void column_family::update_stats_for_new_sstable(uint64_t disk_space_used_by_sstable, std::vector<unsigned>&& shards_for_the_sstable) noexcept {
|
||||
assert(!shards_for_the_sstable.empty());
|
||||
if (*boost::min_element(shards_for_the_sstable) == engine().cpu_id()) {
|
||||
_stats.live_disk_space_used += disk_space_used_by_sstable;
|
||||
@@ -796,9 +796,10 @@ void column_family::update_stats_for_new_sstable(uint64_t disk_space_used_by_sst
|
||||
|
||||
void column_family::add_sstable(lw_shared_ptr<sstables::sstable> sstable, std::vector<unsigned>&& shards_for_the_sstable) {
|
||||
// allow in-progress reads to continue using old list
|
||||
_sstables = make_lw_shared(*_sstables);
|
||||
auto new_sstables = make_lw_shared(*_sstables);
|
||||
new_sstables->insert(sstable);
|
||||
_sstables = std::move(new_sstables);
|
||||
update_stats_for_new_sstable(sstable->bytes_on_disk(), std::move(shards_for_the_sstable));
|
||||
_sstables->insert(std::move(sstable));
|
||||
}
|
||||
|
||||
future<>
|
||||
|
||||
@@ -438,12 +438,13 @@ private:
|
||||
// have to get. It will be closed by stop().
|
||||
seastar::gate _async_gate;
|
||||
private:
|
||||
void update_stats_for_new_sstable(uint64_t disk_space_used_by_sstable, std::vector<unsigned>&& shards_for_the_sstable);
|
||||
void update_stats_for_new_sstable(uint64_t disk_space_used_by_sstable, std::vector<unsigned>&& shards_for_the_sstable) noexcept;
|
||||
// Adds new sstable to the set of sstables
|
||||
// Doesn't update the cache. The cache must be synchronized in order for reads to see
|
||||
// the writes contained in this sstable.
|
||||
// Cache must be synchronized atomically with this, otherwise write atomicity may not be respected.
|
||||
// Doesn't trigger compaction.
|
||||
// Strong exception guarantees.
|
||||
void add_sstable(lw_shared_ptr<sstables::sstable> sstable, std::vector<unsigned>&& shards_for_the_sstable);
|
||||
// returns an empty pointer if sstable doesn't belong to current shard.
|
||||
future<lw_shared_ptr<sstables::sstable>> open_sstable(sstables::foreign_sstable_open_info info, sstring dir,
|
||||
|
||||
Reference in New Issue
Block a user