From 11440ff7922a5367cfa80beec2123c6de643aea2 Mon Sep 17 00:00:00 2001 From: Tomasz Grabiec Date: Wed, 25 Sep 2019 11:27:06 +0200 Subject: [PATCH] mvcc: Fix incorrect schema verison being used to copy the mutation when applying Currently affects only counter tables. Introduced in 27014a2. mutation_partition(s, mp) is incorrect, because it uses s to interpret mp, while it should use mp_schema. We may hit this if the current node has a newer schema than the incoming mutation. This can happen during alter when we receive the mutation from a node which hasn't processed the schema change yet. This is undefined behavior in general. If the alter was adding or removing columns, this may result in corruption of the write where values of one column are inserted into a different column. Fixes #5095. --- partition_version.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/partition_version.cc b/partition_version.cc index 9272821e67..cba9e3f39c 100644 --- a/partition_version.cc +++ b/partition_version.cc @@ -338,7 +338,7 @@ partition_version& partition_entry::add_version(const schema& s, cache_tracker* void partition_entry::apply(const schema& s, const mutation_partition& mp, const schema& mp_schema) { - apply(s, mutation_partition(s, mp), mp_schema); + apply(s, mutation_partition(mp_schema, mp), mp_schema); } void partition_entry::apply(const schema& s, mutation_partition&& mp, const schema& mp_schema)