mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-26 03:20:37 +00:00
Merge '[Backport 6.2] split: run set_split_mode() on all storage groups during all_storage_groups_split()' from Scylladb[bot]
`tablet_storage_group_manager::all_storage_groups_split()` calls `set_split_mode()` for each of its storage groups to create split ready compaction groups. It does this by iterating through storage groups using `std::ranges::all_of()` which is not guaranteed to iterate through the entire range, and will stop iterating on the first occurrence of the predicate (`set_split_mode()`) returning false. `set_split_mode()` creates the split compaction groups and returns false if the storage group's main compaction group or merging groups are not empty. This means that in cases where the tablet storage group manager has non-empty storage groups, we could have a situation where split compaction groups are not created for all storage groups. The missing split compaction groups are later created in `tablet_storage_group_manager::split_all_storage_groups()` which also calls `set_split_mode()`, and that is the reason why split completes successfully. The problem is that `tablet_storage_group_manager::all_storage_groups_split()` runs under a group0 guard, but `tablet_storage_group_manager::split_all_storage_groups()` does not. This can cause problems with operations which should exclude with compaction group creation. i.e. DROP TABLE/DROP KEYSPACE Fixes #22431 This is a bugfix and should be back ported to versions with tablets: 6.1 6.2 and 2025.1 - (cherry picked from commit24e8d2a55c) - (cherry picked from commit8bff7786a8) Parent PR: #22330 Closes scylladb/scylladb#22559 * github.com:scylladb/scylladb: test: add reproducer and test for fix to split ready CG creation table: run set_split_mode() on all storage groups during all_storage_groups_split()
This commit is contained in:
@@ -377,6 +377,59 @@ async def test_read_of_pending_replica_during_migration(manager: ManagerClient,
|
||||
assert len(list(rows)) == 1
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@skip_mode('release', 'error injections are not supported in release mode')
|
||||
async def test_drop_keyspace_while_split(manager: ManagerClient):
|
||||
|
||||
# Reproducer for: https://github.com/scylladb/scylladb/issues/22431
|
||||
# This tests if the split ready compaction groups are correctly created
|
||||
# on a shard with several storage groups for the same table
|
||||
|
||||
logger.info("Bootstrapping cluster")
|
||||
cmdline = [ '--target-tablet-size-in-bytes', '8192',
|
||||
'--smp', '2' ]
|
||||
config = { 'error_injections_at_startup': ['short_tablet_stats_refresh_interval'],
|
||||
'enable_tablets': True }
|
||||
servers = [await manager.server_add(config=config, cmdline=cmdline)]
|
||||
|
||||
s0_log = await manager.server_open_log(servers[0].server_id)
|
||||
|
||||
cql = manager.get_cql()
|
||||
await wait_for_cql_and_get_hosts(cql, [servers[0]], time.time() + 60)
|
||||
|
||||
await manager.api.disable_tablet_balancing(servers[0].ip_addr)
|
||||
|
||||
# create a table so that it has at least 2 tablets (and storage groups) per shard
|
||||
await cql.run_async("CREATE KEYSPACE test WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1} AND tablets = {'initial': 4};")
|
||||
await cql.run_async("CREATE TABLE test.test (pk int PRIMARY KEY, c int);")
|
||||
|
||||
await manager.api.disable_autocompaction(servers[0].ip_addr, 'test')
|
||||
|
||||
keys = range(2048)
|
||||
await asyncio.gather(*[cql.run_async(f'INSERT INTO test.test (pk, c) VALUES ({k}, {k});') for k in keys])
|
||||
await manager.api.flush_keyspace(servers[0].ip_addr, 'test')
|
||||
|
||||
await manager.api.enable_injection(servers[0].ip_addr, 'truncate_compaction_disabled_wait', one_shot=False)
|
||||
await manager.api.enable_injection(servers[0].ip_addr, 'split_storage_groups_wait', one_shot=False)
|
||||
|
||||
# enable the load balancer which should emmit a tablet split
|
||||
await manager.api.enable_tablet_balancing(servers[0].ip_addr)
|
||||
|
||||
# wait for compaction groups to be created and split to begin
|
||||
await s0_log.wait_for('split_storage_groups_wait: wait')
|
||||
|
||||
# start a DROP and wait for it to disable compaction
|
||||
drop_ks_task = cql.run_async('DROP KEYSPACE test;')
|
||||
await s0_log.wait_for('truncate_compaction_disabled_wait: wait')
|
||||
|
||||
# release split
|
||||
await manager.api.message_injection(servers[0].ip_addr, "split_storage_groups_wait")
|
||||
|
||||
# release drop and wait for it to complete
|
||||
await manager.api.message_injection(servers[0].ip_addr, "truncate_compaction_disabled_wait")
|
||||
await drop_ks_task
|
||||
|
||||
|
||||
# This test checks that --enable-tablets option and the TABLETS parameters of the CQL CREATE KEYSPACE
|
||||
# statemement are mutually correct from the "the least surprising behavior" concept. See comments inside
|
||||
# the test code for more details.
|
||||
|
||||
Reference in New Issue
Block a user