Skip to content

Commit

Permalink
partition_version: make partition_entry::upgrade() gentle
Browse files Browse the repository at this point in the history
Preceding commits in this patch series have extended the MVCC
mechanism to allow for versions with different schemas
in the same entry/snapshot, with on-the-fly and background
schema upgrades to the most recent version in the chain.

Given that, we can perform gentle schema upgrades by simply
adding an empty version with the target schema to the front
of the entry.

This patch is intended to be the first and only behaviour-changing patch in the
series. Previous patches added code paths for multi-schema snapshots, but never
exercised them, because before this patch two different schemas within a single
MVCC chain never happened. This patch makes it happen and thus exercises all the
code in the series up until now.

Fixes scylladb#2577
  • Loading branch information
michoecho committed Mar 7, 2023
1 parent 175bdb0 commit f3985b2
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions mutation/partition_version.cc
Original file line number Diff line number Diff line change
Expand Up @@ -587,15 +587,16 @@ mutation_partition partition_entry::squashed(const schema& s, is_evictable evict

void partition_entry::upgrade(logalloc::region& r, schema_ptr to, mutation_cleaner& cleaner, cache_tracker* tracker)
{
with_allocator(r.allocator(), [&] {
auto new_version = r.allocator().construct<partition_version>(squashed_v2(*to, is_evictable(bool(tracker))), to);
auto old_version = &*_version;
set_version(new_version);
if (tracker) {
tracker->insert(*new_version);
}
remove_or_mark_as_unique_owner(old_version, &cleaner);
});
with_allocator(r.allocator(), [&] {
auto phase = partition_snapshot::max_phase;
if (_snapshot) {
phase = _snapshot->_phase;
}
// The destruction of this snapshot pointer will trigger a background merge
// of the old version into the new version.
partition_snapshot_ptr snp = read(r, cleaner, tracker, phase);
add_version(*to, tracker);
});
}

partition_snapshot_ptr partition_entry::read(logalloc::region& r,
Expand Down

0 comments on commit f3985b2

Please sign in to comment.