mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-21 15:22:13 +00:00
Starting from 2024.2, schema versions are assigned by group0 using raft state IDs instead of being calculated by hashing schema mutations with MD5. The assigned version is persisted in system.scylla_local as 'group0_schema_version'. When this value is present, it is used as the schema version; otherwise, the legacy calculate_schema_digest() hash is used as a fallback. If a cluster was upgraded from a version before 2024.2 and no schema change was performed after the upgrade, group0_schema_version will never have been written, keeping the cluster permanently dependent on the legacy hashing code path. This prevents us from dropping that code. Add migration_manager::ensure_group0_schema_version_is_set() which is called during join_cluster after finish_setup_after_join completes (in both the raft-topology and non-raft-topology paths). It checks whether group0_schema_version is set. If not, and the GROUP0_SCHEMA_VERSIONING feature is enabled, it performs a no-op schema change through group0 (announce with an empty mutation set). The announce() function automatically appends the group0_schema_version mutation, so this is sufficient to persist the version on all nodes via raft. A double-check is performed: once before acquiring the group0 guard (to avoid unnecessary work), and once after (since start_group0_operation includes a raft barrier, ensuring any concurrently committed changes from other nodes are applied locally). This handles the case where multiple nodes restart simultaneously and race to set the version. Closes scylladb/scylladb#29858