Merge "sharder: stall cleaving at shard range gaps"

This commit is contained in:
Zuul 2021-04-30 17:32:10 +00:00 committed by Gerrit Code Review
commit c5fe114c96
2 changed files with 11 additions and 5 deletions

View File

@ -1706,6 +1706,8 @@ class ContainerSharder(ContainerReplicator):
quote(broker.path)) quote(broker.path))
else: else:
cleaving_context.start() cleaving_context.start()
own_shard_range = broker.get_own_shard_range()
cleaving_context.cursor = own_shard_range.lower_str
cleaving_context.ranges_todo = len(ranges_todo) cleaving_context.ranges_todo = len(ranges_todo)
self.logger.debug('Starting to cleave (%s todo): %s', self.logger.debug('Starting to cleave (%s todo): %s',
cleaving_context.ranges_todo, quote(broker.path)) cleaving_context.ranges_todo, quote(broker.path))
@ -1722,6 +1724,11 @@ class ContainerSharder(ContainerReplicator):
if len(ranges_done) == self.cleave_batch_size: if len(ranges_done) == self.cleave_batch_size:
break break
if shard_range.lower > cleaving_context.cursor:
self.logger.info('Stopped cleave at gap: %r - %r' %
(cleaving_context.cursor, shard_range.lower))
break
if shard_range.state not in (ShardRange.CREATED, if shard_range.state not in (ShardRange.CREATED,
ShardRange.CLEAVED, ShardRange.CLEAVED,
ShardRange.ACTIVE): ShardRange.ACTIVE):

View File

@ -1878,14 +1878,13 @@ class TestSharder(BaseTestSharder):
do_test(ShardRange.CLEAVED, (('d', 'k'), ('k', 't')), expect_delete) do_test(ShardRange.CLEAVED, (('d', 'k'), ('k', 't')), expect_delete)
# shrinking to incomplete acceptors, gap at start and end of namespace # shrinking to incomplete acceptors, gap at start and end of namespace
do_test(ShardRange.CREATED, (('k', 't'),), expect_delete, do_test(ShardRange.CREATED, (('k', 't'),), expect_delete,
exp_progress_bounds=(('k', 't'),)) exp_progress_bounds=())
# shrinking to incomplete acceptors, gap at start of namespace # shrinking to incomplete acceptors, gap at start of namespace
expect_delete = True
do_test(ShardRange.CLEAVED, (('k', 't'), ('t', '')), expect_delete, do_test(ShardRange.CLEAVED, (('k', 't'), ('t', '')), expect_delete,
exp_progress_bounds=(('k', 't'), ('t', ''))) exp_progress_bounds=())
# shrinking to incomplete acceptors, gap in middle # shrinking to incomplete acceptors, gap in middle - some progress
do_test(ShardRange.CLEAVED, (('d', 'k'), ('t', '')), expect_delete, do_test(ShardRange.CLEAVED, (('d', 'k'), ('t', '')), expect_delete,
exp_progress_bounds=(('d', 'k'), ('t', ''))) exp_progress_bounds=(('d', 'k'),))
def test_cleave_repeated(self): def test_cleave_repeated(self):
# verify that if new objects are merged into retiring db after cleaving # verify that if new objects are merged into retiring db after cleaving