repair: Sync schema from follower nodes before repair

Since commit "repair: Use the same schema version for repair master and
followers", repair master and followers uses the same schema version
that master decides to use during the whole repair operation. If master
has older version of schema, repair could ignore the data which makes use
of the new schema, e.g., writes to new columns.

To fix, always sync the schema agreement before repair.

The master node pulls schema from followers and applies locally. The
master then uses the "merged" schema. The followers use
get_schema_for_write() to pull the "merged" schema.

Fixes #4575
Backports: 3.1
This commit is contained in:
Asias He
2019-06-24 09:51:45 +08:00
parent 14c1a71860
commit bb5665331c

View File

@@ -941,6 +941,7 @@ static future<> repair_cf_range(repair_info& ri,
static future<> repair_range(repair_info& ri, const dht::token_range& range) {
auto id = utils::UUID_gen::get_time_UUID();
return do_with(get_neighbors(ri.db.local(), ri.keyspace, range, ri.data_centers, ri.hosts), [&ri, range, id] (const auto& neighbors) {
return ::service::get_local_migration_manager().sync_schema(ri.db.local(), neighbors).then([&neighbors, &ri, range, id] {
rlogger.debug("[repair #{}] new session: will sync {} on range {} for {}.{}", id, neighbors, range, ri.keyspace, ri.cfs);
return do_for_each(ri.cfs.begin(), ri.cfs.end(), [&ri, &neighbors, range] (auto&& cf) {
ri._sub_ranges_nr++;
@@ -950,6 +951,7 @@ static future<> repair_range(repair_info& ri, const dht::token_range& range) {
return repair_cf_range(ri, cf, range, neighbors);
}
});
});
});
}