Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dab9fe86 authored by Olivier Gaillard's avatar Olivier Gaillard Committed by Android (Google) Code Review
Browse files

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

parents f8e8d3f1 9800504a
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -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<>();
+5 −5
Original line number Original line Diff line number Diff line
@@ -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());