Merge "Make rate limiting less aggressive for recurrent crashes" into udc-dev

This commit is contained in:
Olivier Gaillard
2023-05-18 09:19:03 +00:00
committed by Android (Google) Code Review
2 changed files with 6 additions and 6 deletions

View File

@@ -40,7 +40,7 @@ public class DropboxRateLimiter {
// If a process is rate limited twice in a row we consider it crash-looping and rate limit it // If a process is rate limited twice in a row we consider it crash-looping and rate limit it
// more aggressively. // more aggressively.
private static final int STRICT_RATE_LIMIT_ALLOWED_ENTRIES = 1; private static final int STRICT_RATE_LIMIT_ALLOWED_ENTRIES = 1;
private static final long STRICT_RATE_LIMIT_BUFFER_DURATION = 60 * DateUtils.MINUTE_IN_MILLIS; private static final long STRICT_RATE_LIMIT_BUFFER_DURATION = 20 * DateUtils.MINUTE_IN_MILLIS;
@GuardedBy("mErrorClusterRecords") @GuardedBy("mErrorClusterRecords")
private final ArrayMap<String, ErrorRecord> mErrorClusterRecords = new ArrayMap<>(); private final ArrayMap<String, ErrorRecord> mErrorClusterRecords = new ArrayMap<>();

View File

@@ -140,19 +140,19 @@ public class DropboxRateLimiterTest {
// Repeated crashes after the last reset being rate limited should be restricted faster. // Repeated crashes after the last reset being rate limited should be restricted faster.
assertTrue(mRateLimiter.shouldRateLimit("tag", "process").shouldRateLimit()); assertTrue(mRateLimiter.shouldRateLimit("tag", "process").shouldRateLimit());
// We now need to wait 61 minutes for the buffer should be empty again. // We now need to wait 21 minutes for the buffer should be empty again.
mClock.setOffsetMillis(83 * 60 * 1000); mClock.setOffsetMillis(43 * 60 * 1000);
assertFalse(mRateLimiter.shouldRateLimit("tag", "process").shouldRateLimit()); assertFalse(mRateLimiter.shouldRateLimit("tag", "process").shouldRateLimit());
// After yet another 61 minutes, this time without triggering rate limiting, the strict // After yet another 21 minutes, this time without triggering rate limiting, the strict
// limiting should be turnd off. // limiting should be turnd off.
mClock.setOffsetMillis(144 * 60 * 1000); mClock.setOffsetMillis(64 * 60 * 1000);
assertFalse(mRateLimiter.shouldRateLimit("tag", "process").shouldRateLimit()); assertFalse(mRateLimiter.shouldRateLimit("tag", "process").shouldRateLimit());
assertFalse(mRateLimiter.shouldRateLimit("tag", "process").shouldRateLimit()); assertFalse(mRateLimiter.shouldRateLimit("tag", "process").shouldRateLimit());
// As rate limiting was not triggered in the last reset, after another 11 minutes the // As rate limiting was not triggered in the last reset, after another 11 minutes the
// buffer should still act as normal. // buffer should still act as normal.
mClock.setOffsetMillis(155 * 60 * 1000); mClock.setOffsetMillis(75 * 60 * 1000);
// The first 6 entries should not be rate limited. // The first 6 entries should not be rate limited.
assertFalse(mRateLimiter.shouldRateLimit("tag", "process").shouldRateLimit()); assertFalse(mRateLimiter.shouldRateLimit("tag", "process").shouldRateLimit());
assertFalse(mRateLimiter.shouldRateLimit("tag", "process").shouldRateLimit()); assertFalse(mRateLimiter.shouldRateLimit("tag", "process").shouldRateLimit());