partition_version: make partition_entry::upgrade() gentle

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 #2577
This commit is contained in:
Michał Chojnowski
2023-03-01 02:57:09 +01:00
parent fe576f8f29
commit 80c8a6d0e6

View File

@@ -630,15 +630,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,