diff options
author | Tom Cherry <tomcherry@google.com> | 2020-07-23 09:40:51 -0700 |
---|---|---|
committer | Tom Cherry <tomcherry@google.com> | 2020-07-27 16:26:31 +0000 |
commit | 4b4e781943cb1f3a5f95e93ff34ddf6bcf563d8b (patch) | |
tree | d9679913ea8dbce2cbf5d5eba76937d13cf9f345 /services/backup/java | |
parent | 9012bb9d95f13506fcd7f7924961a762797620bd (diff) |
Log only a summary 'Found stale backup journal' message.
With the goal of reducing log spam, print only a summary 'Found stale
backup journal' messages instead of logging within the inner loop.
Previously, over 12k messages could be printed at a time from this
function.
Before this CL:
- a backup was scheduled for each packageName from each stale
journal
- one (or two, if MORE_DEBUG) message was logged for each
packageName in each journal file.
After this CL:
- packageNames are de-duplicated before scheduling backups or logging
(it's not clear to me whether duplicate packageNames previously
occurred, in practice).
- one message is logged for the number (if > 0) of stale journals.
- one message is logged for the number (including their names, if
MORE_DEBUG) of packages.
Bug: 161940947
Test: fewer 'Found state backup journal' messages printed
Merged-In: Ia1343e4cea31feb1eba9da561d20736eb5df0a14
Change-Id: Ia1343e4cea31feb1eba9da561d20736eb5df0a14
(cherry picked from commit 112e3c2d049d304b0aa57750fcaa6415ea2b6fef)
Diffstat (limited to 'services/backup/java')
-rw-r--r-- | services/backup/java/com/android/server/backup/UserBackupManagerService.java | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/services/backup/java/com/android/server/backup/UserBackupManagerService.java b/services/backup/java/com/android/server/backup/UserBackupManagerService.java index f6c4918a7dfe..0493b84997d9 100644 --- a/services/backup/java/com/android/server/backup/UserBackupManagerService.java +++ b/services/backup/java/com/android/server/backup/UserBackupManagerService.java @@ -155,6 +155,7 @@ import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Objects; @@ -1109,23 +1110,31 @@ public class UserBackupManagerService { private void parseLeftoverJournals() { ArrayList<DataChangedJournal> journals = DataChangedJournal.listJournals(mJournalDir); + // TODO(b/162022005): Fix DataChangedJournal implementing equals() but not hashCode(). + journals.removeAll(Collections.singletonList(mJournal)); + if (!journals.isEmpty()) { + Slog.i(TAG, addUserIdToLogMessage(mUserId, + "Found " + journals.size() + " stale backup journal(s), scheduling.")); + } + Set<String> packageNames = new LinkedHashSet<>(); for (DataChangedJournal journal : journals) { - if (!journal.equals(mJournal)) { - try { - journal.forEach(packageName -> { - Slog.i( - TAG, - addUserIdToLogMessage( - mUserId, "Found stale backup journal, scheduling")); - if (MORE_DEBUG) { - Slog.i(TAG, addUserIdToLogMessage(mUserId, " " + packageName)); - } + try { + journal.forEach(packageName -> { + if (packageNames.add(packageName)) { dataChangedImpl(packageName); - }); - } catch (IOException e) { - Slog.e(TAG, addUserIdToLogMessage(mUserId, "Can't read " + journal), e); - } + } + }); + } catch (IOException e) { + Slog.e(TAG, addUserIdToLogMessage(mUserId, "Can't read " + journal), e); + } + } + if (!packageNames.isEmpty()) { + String msg = "Stale backup journals: Scheduled " + packageNames.size() + + " package(s) total"; + if (MORE_DEBUG) { + msg += ": " + packageNames; } + Slog.i(TAG, addUserIdToLogMessage(mUserId, msg)); } } |