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))
else:
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)
self.logger.debug('Starting to cleave (%s todo): %s',
cleaving_context.ranges_todo, quote(broker.path))
@ -1722,6 +1724,11 @@ class ContainerSharder(ContainerReplicator):
if len(ranges_done) == self.cleave_batch_size:
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,
ShardRange.CLEAVED,
ShardRange.ACTIVE):

View File

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