From 09ee4fcde8e94af7b6a4813f126d7c15f662d8f7 Mon Sep 17 00:00:00 2001 From: Amith Yamasani Date: Wed, 20 Jan 2021 08:50:02 -0800 Subject: [PATCH] Throttle error messages about mismatched bucket There is a mismatch in active UID versus standby bucket for some system apps, especially gms. Exact reason could be a race or some other initialization bug, but the mismatch wtf message is spamming the logs and DropBox resulting in potential DOSing of gms handling the drop box entries. Throttle back the number of wtf logs to one per job until the issue is root-caused. Bug: 177396523 Test: Manual flash and verify reduced logs Change-Id: I7d8911e034f9467ac627437a966248426ee6a1c7 --- .../controllers/BackgroundJobsController.java | 2 +- .../server/job/controllers/JobStatus.java | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/apex/jobscheduler/service/java/com/android/server/job/controllers/BackgroundJobsController.java b/apex/jobscheduler/service/java/com/android/server/job/controllers/BackgroundJobsController.java index 04d694778e1a3..58396eb69d14d 100644 --- a/apex/jobscheduler/service/java/com/android/server/job/controllers/BackgroundJobsController.java +++ b/apex/jobscheduler/service/java/com/android/server/job/controllers/BackgroundJobsController.java @@ -203,7 +203,7 @@ public final class BackgroundJobsController extends StateController { isActive = (activeState == KNOWN_ACTIVE); } if (isActive && jobStatus.getStandbyBucket() == NEVER_INDEX) { - Slog.wtf(TAG, "App " + packageName + " became active but still in NEVER bucket"); + jobStatus.maybeLogBucketMismatch(); } boolean didChange = jobStatus.setBackgroundNotRestrictedConstraintSatisfied(canRun); didChange |= jobStatus.setUidActive(isActive); diff --git a/apex/jobscheduler/service/java/com/android/server/job/controllers/JobStatus.java b/apex/jobscheduler/service/java/com/android/server/job/controllers/JobStatus.java index 51525e0c38f50..09dc7d281cb4c 100644 --- a/apex/jobscheduler/service/java/com/android/server/job/controllers/JobStatus.java +++ b/apex/jobscheduler/service/java/com/android/server/job/controllers/JobStatus.java @@ -205,6 +205,11 @@ public final class JobStatus { */ private int standbyBucket; + /** + * Whether we've logged an error due to standby bucket mismatch with active uid state. + */ + private boolean mLoggedBucketMismatch; + /** * Debugging: timestamp if we ever defer this job based on standby bucketing, this * is when we did so. @@ -805,6 +810,18 @@ public final class JobStatus { } standbyBucket = newBucket; + mLoggedBucketMismatch = false; + } + + /** + * Log a bucket mismatch if this is the first time for this job. + */ + public void maybeLogBucketMismatch() { + if (!mLoggedBucketMismatch) { + Slog.wtf(TAG, + "App " + getSourcePackageName() + " became active but still in NEVER bucket"); + mLoggedBucketMismatch = true; + } } // Called only by the standby monitoring code