Skip to content

Commit

Permalink
db: system_distributed_keyspace: use current time when creating mutat…
Browse files Browse the repository at this point in the history
…ions in `start()`

When creating internal distributed tables in
`system_distributed_keyspace::start()`, hardcoded timestamps were used.
This was to protect against issue scylladb#2129, where nodes would start without
synchronizing schema with the existing cluster, creating the tables
again, which would override any manual user changes to these tables.
The solution was to use small timestamps (like api::min_timestamp) - the
user-created schema mutations would always 'win' (because when they were
created, they used current time).

This workaround is no longer necessary: when nodes start they always
have to sync schema with existing nodes; we also don't allow
bootstrapping nodes in parallel.

When schema changes are performed by Raft group 0, certain constraints
are placed on the timestamps used for mutations. For this we'll need to
be able to use timestamps which are generated based on current time.
  • Loading branch information
kbr-scylla committed Jan 8, 2022
1 parent aa30149 commit a9834a1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions db/system_distributed_keyspace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ static future<> add_new_columns_if_missing(database& db, ::service::migration_ma
if (updated) {
schema_ptr table = b.build();
try {
co_return co_await mm.announce(co_await mm.prepare_column_family_update_announcement(table, false, std::vector<view_ptr>(), api::timestamp_type(1)));
co_return co_await mm.announce(co_await mm.prepare_column_family_update_announcement(table, false, std::vector<view_ptr>(), api::new_timestamp()));
} catch (...) {}
}
} catch (...) {
Expand Down Expand Up @@ -298,7 +298,7 @@ future<> system_distributed_keyspace::start() {
auto m = co_await map_reduce(tables,
/* Mapper */ [this] (auto&& table) -> future<std::vector<mutation>> {
try {
co_return co_await _mm.prepare_new_column_family_announcement(std::move(table), api::min_timestamp);
co_return co_await _mm.prepare_new_column_family_announcement(std::move(table), api::new_timestamp());
} catch (exceptions::already_exists_exception&) {
co_return std::vector<mutation>();
}
Expand Down

0 comments on commit a9834a1

Please sign in to comment.