redis/tests/cluster/tests
Chen Tianjie 8527959598
Replace slots_to_channels radix tree with slot specific dictionaries for shard channels. (#12804)
We have achieved replacing `slots_to_keys` radix tree with key->slot
linked list (#9356), and then replacing the list with slot specific
dictionaries for keys (#11695).

Shard channels behave just like keys in many ways, and we also need a
slots->channels mapping. Currently this is still done by using a radix
tree. So we should split `server.pubsubshard_channels` into 16384 dicts
and drop the radix tree, just like what we did to DBs.

Some benefits (basically the benefits of what we've done to DBs):
1. Optimize counting channels in a slot. This is currently used only in
removing channels in a slot. But this is potentially more useful:
sometimes we need to know how many channels there are in a specific slot
when doing slot migration. Counting is now implemented by traversing the
radix tree, and with this PR it will be as simple as calling `dictSize`,
from O(n) to O(1).
2. The radix tree in the cluster has been removed. The shard channel
names no longer require additional storage, which can save memory.
3. Potentially useful in slot migration, as shard channels are logically
split by slots, thus making it easier to migrate, remove or add as a
whole.
4. Avoid rehashing a big dict when there is a large number of channels.

Drawbacks:
1. Takes more memory than using radix tree when there are relatively few
shard channels.

What this PR does:
1. in cluster mode, split `server.pubsubshard_channels` into 16384
dicts, in standalone mode, still use only one dict.
2. drop the `slots_to_channels` radix tree.
3. to save memory (to solve the drawback above), all 16384 dicts are
created lazily, which means only when a channel is about to be inserted
to the dict will the dict be initialized, and when all channels are
deleted, the dict would delete itself.
5. use `server.shard_channel_count` to keep track of the number of all
shard channels.

---------

Co-authored-by: Viktor Söderqvist <viktor.soderqvist@est.tech>
2023-12-27 17:40:45 +08:00
..
helpers Cluster test: helpers/onlydots.tcl: detect EOF and exit. 2014-10-08 10:17:01 +02:00
includes Harden init-tests for cluster tests (#11635) 2022-12-22 17:37:00 -08:00
00-base.tcl Add dummy CLUSTER SLAVES call tests to fix reply ci (#12224) 2023-05-24 09:28:38 +03:00
01-faildet.tcl Cluster test: more reliable 01-faildet unit. 2014-05-23 11:40:34 +02:00
02-failover.tcl Cluster test: 02 unit more reliable waiting for slave sync. 2014-06-10 15:01:52 +02:00
03-failover-loop.tcl Fix failing cluster tests (#9707) 2021-10-31 19:22:21 +02:00
04-resharding.tcl Fix failing cluster tests (#9707) 2021-10-31 19:22:21 +02:00
05-slave-selection.tcl Fix timing issue in CLUSTER SLAVE / REPLICAS consistent test (#12774) 2023-11-19 11:09:33 +02:00
06-slave-stop-cond.tcl Set repl-diskless-sync to yes by default, add repl-diskless-sync-max-replicas (#10092) 2022-01-17 14:11:11 +02:00
07-replica-migration.tcl Fix replica count check in migration tests. (#10140) 2022-01-19 11:36:24 +02:00
08-update-msg.tcl Fixed some typos, add a spell check ci and others minor fix (#8890) 2021-06-10 15:39:33 +03:00
09-pubsub.tcl Cluster test: unit 09, Pub/Sub across the cluster. 2014-09-15 18:11:45 +02:00
10-manual-failover.tcl Cluster: unit 10 modified to leave cluster in proper state. 2015-03-22 22:58:53 +01:00
11-manual-takeover.tcl Prevent replica failover during manual takeover test (#10499) 2022-03-31 08:15:00 +03:00
12-replica-migration-2.tcl Turn into replica on SETSLOT (#10489) 2022-04-02 14:58:07 -07:00
12.1-replica-migration-3.tcl Change replica migration tests to use continous slots to improve speed (#10215) 2022-01-30 22:44:32 -08:00
13-no-failover-option.tcl Cluster: add test for the nofailover flag. 2018-03-14 16:30:32 +01:00
14-consistency-check.tcl Set repl-diskless-sync to yes by default, add repl-diskless-sync-max-replicas (#10092) 2022-01-17 14:11:11 +02:00
15-cluster-slots.tcl Process loss of slot ownership in cluster bus (#12344) 2023-07-05 17:46:23 -07:00
16-transactions-on-replica.tcl Add reply_schema to command json files (internal for now) (#10273) 2023-03-11 10:14:16 +02:00
17-diskless-load-swapdb.tcl Replica keep serving data during repl-diskless-load=swapdb for better availability (#9323) 2021-11-04 10:46:50 +02:00
18-info.tcl Fixed some typos, add a spell check ci and others minor fix (#8890) 2021-06-10 15:39:33 +03:00
19-cluster-nodes-slots.tcl Sharded pubsub implementation (#8621) 2022-01-02 16:54:47 -08:00
20-half-migrated-slot.tcl Revert cluster slot migration tests. (#8806) 2021-04-18 20:51:08 +03:00
21-many-slot-migration.tcl tests: fix a typo (#9294) 2021-07-30 10:00:07 +03:00
22-replica-in-sync.tcl Fix race condition in cluster test 22-replica-in-sync (#9721) 2021-11-04 08:44:18 +02:00
25-pubsubshard-slot-migration.tcl Unsubscribe all clients from replica for shard channel if the master ownership changes (#12577) 2023-10-12 20:48:27 -07:00
26-pubsubshard.tcl Replace slots_to_channels radix tree with slot specific dictionaries for shard channels. (#12804) 2023-12-27 17:40:45 +08:00
28-cluster-shards.tcl Allow cluster slots/shards api to respond during loading (#12269) 2023-06-13 18:16:32 +03:00
29-slot-migration-response.tcl Add tests for error messages during slot migrations (#10449) 2022-07-04 10:31:12 -05:00