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

Commit 9800504a authored by Olivier Gaillard's avatar Olivier Gaillard
Browse files

Make rate limiting less aggressive for recurrent crashes

Having long rate limit periods makes it more likely for crashes to get dropped if the crashes do not continue once the rate limit period is done.

Change-Id: Ied5aff84e93f298bffd05d143af32f1ee8c041c7
Bug: 283096542
parent 188de432
Loading
Loading
Loading
Loading
+1 −1
Original line number 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
    // more aggressively.
    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")
    private final ArrayMap<String, ErrorRecord> mErrorClusterRecords = new ArrayMap<>();
+5 −5
Original line number 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.
        assertTrue(mRateLimiter.shouldRateLimit("tag", "process").shouldRateLimit());

        // We now need to wait 61 minutes for the buffer should be empty again.
        mClock.setOffsetMillis(83 * 60 * 1000);
        // We now need to wait 21 minutes for the buffer should be empty again.
        mClock.setOffsetMillis(43 * 60 * 1000);
        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.
        mClock.setOffsetMillis(144 * 60 * 1000);
        mClock.setOffsetMillis(64 * 60 * 1000);
        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
        // 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.
        assertFalse(mRateLimiter.shouldRateLimit("tag", "process").shouldRateLimit());
        assertFalse(mRateLimiter.shouldRateLimit("tag", "process").shouldRateLimit());