Fix a bug in background updates wherein background updates are never run using the default batch size (#12157)

This commit is contained in:
Shay 2022-03-07 09:44:33 -08:00 committed by GitHub
parent f63bedef07
commit 26211fec24
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 15 deletions

View file

@ -102,10 +102,12 @@ class BackgroundUpdatePerformance:
Returns:
A duration in ms as a float
"""
if self.avg_duration_ms == 0:
return 0
elif self.total_item_count == 0:
# We want to return None if this is the first background update item
if self.total_item_count == 0:
return None
# Avoid dividing by zero
elif self.avg_duration_ms == 0:
return 0
else:
# Use the exponential moving average so that we can adapt to
# changes in how long the update process takes.