Merge "Address a sharder/replicator race"
This commit is contained in:
commit
d50b50ba8d
@ -749,8 +749,9 @@ class ContainerSharder(ContainerReplicator):
|
|||||||
# root may not yet know about this shard container
|
# root may not yet know about this shard container
|
||||||
warnings.append('root has no matching shard range')
|
warnings.append('root has no matching shard range')
|
||||||
shard_range = None
|
shard_range = None
|
||||||
else:
|
elif not own_shard_range.deleted:
|
||||||
warnings.append('unable to get shard ranges from root')
|
warnings.append('unable to get shard ranges from root')
|
||||||
|
# else, our shard range is deleted, so root may have reclaimed it
|
||||||
else:
|
else:
|
||||||
errors.append('missing own shard range')
|
errors.append('missing own shard range')
|
||||||
|
|
||||||
@ -770,14 +771,16 @@ class ContainerSharder(ContainerReplicator):
|
|||||||
self.logger.debug('Updating shard from root %s', dict(shard_range))
|
self.logger.debug('Updating shard from root %s', dict(shard_range))
|
||||||
broker.merge_shard_ranges(shard_range)
|
broker.merge_shard_ranges(shard_range)
|
||||||
own_shard_range = broker.get_own_shard_range()
|
own_shard_range = broker.get_own_shard_range()
|
||||||
delete_age = time.time() - self.reclaim_age
|
|
||||||
if (own_shard_range.state == ShardRange.SHARDED and
|
delete_age = time.time() - self.reclaim_age
|
||||||
own_shard_range.deleted and
|
if (own_shard_range.state == ShardRange.SHARDED and
|
||||||
own_shard_range.timestamp < delete_age and
|
own_shard_range.deleted and
|
||||||
broker.empty()):
|
own_shard_range.timestamp < delete_age and
|
||||||
broker.delete_db(Timestamp.now().internal)
|
broker.empty()):
|
||||||
self.logger.debug('Deleted shard container %s (%s)',
|
broker.delete_db(Timestamp.now().internal)
|
||||||
broker.db_file, quote(broker.path))
|
self.logger.debug('Deleted shard container %s (%s)',
|
||||||
|
broker.db_file, quote(broker.path))
|
||||||
|
|
||||||
self._increment_stat('audit_shard', 'success', statsd=True)
|
self._increment_stat('audit_shard', 'success', statsd=True)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -4640,6 +4640,7 @@ class TestSharder(BaseTestSharder):
|
|||||||
own_shard_range.deleted = 1
|
own_shard_range.deleted = 1
|
||||||
own_shard_range.timestamp = Timestamp.now()
|
own_shard_range.timestamp = Timestamp.now()
|
||||||
broker.merge_shard_ranges([own_shard_range])
|
broker.merge_shard_ranges([own_shard_range])
|
||||||
|
del shard_ranges[:] # root responds with no shard ranges
|
||||||
assert_ok()
|
assert_ok()
|
||||||
self.assertTrue(broker.is_deleted())
|
self.assertTrue(broker.is_deleted())
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user