summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorClay Gerrard <clay.gerrard@gmail.com>2020-11-09 15:46:45 -0600
committerAlistair Coles <alistairncoles@gmail.com>2020-12-18 11:33:48 +0000
commitd277960161119face2eb9d617822b2645f19b2c1 (patch)
tree77ac530651547ee0a1fe39729604c5b451d8277c /bin
parent7a327f6285329aac55c02b0a7683c1de570b9328 (diff)
downloadswift-d277960161119face2eb9d617822b2645f19b2c1.tar.gz
Populate shrinking shards with shard ranges learnt from root
Shard shrinking can be instigated by a third party modifying shard ranges, moving one shard to shrinking state and expanding the namespace of one or more other shard(s) to act as acceptors. These state and namespace changes must propagate to the shrinking and acceptor shards. The shrinking shard must also discover the acceptor shard(s) into which it will shard itself. The sharder audit function already updates shards with their own state and namespace changes from the root. However, there is currently no mechanism for the shrinking shard to learn about the acceptor(s) other than by a PUT request being made to the shrinking shard container. This patch modifies the shard container audit function so that other overlapping shards discovered from the root are merged into the audited shard's db. In this way, the audited shard will have acceptor shards to cleave to if shrinking. This new behavior is restricted to when the shard is shrinking. In general, a shard is responsible for processing its own sub-shard ranges (if any) and reporting them to root. Replicas of a shard container synchronise their sub-shard ranges via replication, and do not rely on the root to propagate sub-shard ranges between shard replicas. The exception to this is when a third party (or auto-sharding) wishes to instigate shrinking by modifying the shard and other acceptor shards in the root container. In other circumstances, merging overlapping shard ranges discovered from the root is undesirable because it risks shards inheriting other unrelated shard ranges. For example, if the root has become polluted by split-brain shard range management, a sharding shard may have its sub-shards polluted by an undesired shard from the root. During the shrinking process a shard range's own shard range state may be either shrinking or, prior to this patch, sharded. The sharded state could occur when one replica of a shrinking shard completed shrinking and moved the own shard range state to sharded before other replica(s) had completed shrinking. This makes it impossible to distinguish a shrinking shard (with sharded state), which we do want to inherit shard ranges, from a sharding shard (with sharded state), which we do not want to inherit shard ranges. This patch therefore introduces a new shard range state, 'SHRUNK', and applies this state to shard ranges that have completed shrinking. Shards are now restricted to inherit shard ranges from the root only when their own shard range state is either SHRINKING or SHRUNK. This patch also: - Stops overlapping shrinking shards from generating audit warnings: overlaps are cured by shrinking and we therefore expect shrinking shards to sometimes overlap. - Extends an existing probe test to verify that overlapping shard ranges may be resolved by shrinking a subset of the shard ranges. - Adds a --no-auto-shard option to swift-container-sharder to enable the probe tests to disable auto-sharding. - Improves sharder logging, in particular by decrementing ranges_todo when a shrinking shard is skipped during cleaving. - Adds a ShardRange.sort_key class method to provide a single definition of ShardRange sort ordering. - Improves unit test coverage for sharder shard auditing. Co-Authored-By: Tim Burke <tim.burke@gmail.com> Co-Authored-By: Alistair Coles <alistairncoles@gmail.com> Change-Id: I9034a5715406b310c7282f1bec9625fe7acd57b6
Diffstat (limited to 'bin')
-rwxr-xr-xbin/swift-container-sharder4
1 files changed, 4 insertions, 0 deletions
diff --git a/bin/swift-container-sharder b/bin/swift-container-sharder
index 3e6551319..0374b8d91 100755
--- a/bin/swift-container-sharder
+++ b/bin/swift-container-sharder
@@ -29,5 +29,9 @@ if __name__ == '__main__':
help='Shard containers only in given partitions. '
'Comma-separated list. '
'Only has effect if --once is used.')
+ parser.add_option('--no-auto-shard', action='store_false',
+ dest='auto_shard', default=None,
+ help='Disable auto-sharding. Overrides the auto_shard '
+ 'value in the config file.')
conf_file, options = parse_options(parser=parser, once=True)
run_daemon(ContainerSharder, conf_file, **options)