From 0c376043ebe0d72364ed45763b0717aa4bd1955e Mon Sep 17 00:00:00 2001 From: Gleb Natapov Date: Mon, 26 Feb 2024 15:49:31 +0200 Subject: [PATCH] migration_manager: take group0 lock during raft snapshot taking Group0 state machine access atomicity is guaranteed by a mutex in group0 client. A code that reads or writes the state needs to hold the log. To transfer schema part of the snapshot we used existing "migration request" verb which did not follow the rule. Fix the code to take group0 lock before accessing schema in case the verb is called as part of group0 snapshot transfer. Fixes scylladb/scylladb#16821 --- service/migration_manager.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/service/migration_manager.cc b/service/migration_manager.cc index e6992812942c..ad1d9ede486b 100644 --- a/service/migration_manager.cc +++ b/service/migration_manager.cc @@ -156,6 +156,10 @@ void migration_manager::init_messaging_service() auto features = self._feat.cluster_schema_features(); auto& proxy = self._storage_proxy.container(); auto& db = proxy.local().get_db(); + semaphore_units<> guard; + if (options->group0_snapshot_transfer) { + guard = co_await self._group0_client.hold_read_apply_mutex(self._as); + } auto cm = co_await db::schema_tables::convert_schema_to_mutations(proxy, features); if (options->group0_snapshot_transfer) { cm.emplace_back(co_await db::system_keyspace::get_group0_history(db));