mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-26 03:20:37 +00:00
Schema digest is calculated by querying for mutations of all schema tables, then compacting them so that all tombstones in them are dropped. However, even if the mutation becomes empty after compaction, we still feed its partition key. If the same mutations were compacted prior to the query, because the tombstones expire, we won't get any mutation at all and won't feed the partition key. So schema digest will change once an empty partition of some schema table is compacted away. Tombstones expire 7 days after schema change which introduces them. If one of the nodes is restarted after that, it will compute a different table schema digest on boot. This may cause performance problems. When sending a request from coordinator to replica, the replica needs schema_ptr of exact schema version request by the coordinator. If it doesn't know that version, it will request it from the coordinator and perform a full schema merge. This adds latency to every such request. Schema versions which are not referenced are currently kept in cache for only 1 second, so if request flow has low-enough rate, this situation results in perpetual schema pulls. Afterae8d2a550d(5.2.0), it is more liekly to run into this situation, because table creation generates tombstones for all schema tables relevant to the table, even the ones which will be otherwise empty for the new table (e.g. computed_columns). This change inroduces a cluster feature which when enabled will change digest calculation to be insensitive to expiry by ignoring empty partitions in digest calculation. When the feature is enabled, schema_ptrs are reloaded so that the window of discrepancy during transition is short and no rolling restart is required. A similar problem was fixed for per-node digest calculation in c2ba94dc39e4add9db213751295fb17b95e6b962. Per-table digest calculation was not fixed at that time because we didn't persist enabled features and they were not enabled early-enough on boot for us to depend on them in digest calculation. Now they are enabled before non-system tables are loaded so digest calculation can rely on cluster features. Fixes #4485. Manually tested using ccm on cluster upgrade scenarios and node restarts. Closes #14441 * github.com:scylladb/scylladb: test: schema_change_test: Verify digests also with TABLE_DIGEST_INSENSITIVE_TO_EXPIRY enabled schema_mutations, migration_manager: Ignore empty partitions in per-table digest migration_manager, schema_tables: Implement migration_manager::reload_schema() schema_tables: Avoid crashing when table selector has only one kind of tables (cherry picked from commitcf81eef370)
45 lines
1.2 KiB
C++
45 lines
1.2 KiB
C++
/*
|
|
* Copyright (C) 2019-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "enum_set.hh"
|
|
|
|
namespace db {
|
|
|
|
enum class schema_feature {
|
|
VIEW_VIRTUAL_COLUMNS,
|
|
|
|
// When set, the schema digest is calcualted in a way such that it doesn't change after all
|
|
// tombstones in an empty partition expire.
|
|
// See https://github.com/scylladb/scylla/issues/4485
|
|
DIGEST_INSENSITIVE_TO_EXPIRY,
|
|
COMPUTED_COLUMNS,
|
|
CDC_OPTIONS,
|
|
PER_TABLE_PARTITIONERS,
|
|
SCYLLA_KEYSPACES,
|
|
SCYLLA_AGGREGATES,
|
|
|
|
// When enabled, schema_mutations::digest() will skip empty mutations (with only tombstones),
|
|
// so that the digest remains the same after schema tables are compacted.
|
|
TABLE_DIGEST_INSENSITIVE_TO_EXPIRY,
|
|
};
|
|
|
|
using schema_features = enum_set<super_enum<schema_feature,
|
|
schema_feature::VIEW_VIRTUAL_COLUMNS,
|
|
schema_feature::DIGEST_INSENSITIVE_TO_EXPIRY,
|
|
schema_feature::COMPUTED_COLUMNS,
|
|
schema_feature::CDC_OPTIONS,
|
|
schema_feature::PER_TABLE_PARTITIONERS,
|
|
schema_feature::SCYLLA_KEYSPACES,
|
|
schema_feature::SCYLLA_AGGREGATES,
|
|
schema_feature::TABLE_DIGEST_INSENSITIVE_TO_EXPIRY
|
|
>>;
|
|
|
|
}
|