OSDN Git Service

Persisted jobs versus incorrect boot-time RTC
authorChristopher Tate <ctate@google.com>
Wed, 26 Jul 2017 21:27:38 +0000 (14:27 -0700)
committerChristopher Tate <ctate@google.com>
Mon, 31 Jul 2017 23:26:01 +0000 (16:26 -0700)
commit616541d7016ee4440051738a8f0c7c3b7086d375
treeeab22ee64d991da5cda03a49a682f932a6906910
parent56bd583162d1e1a60d54bf58fb7b1200b77212f3
Persisted jobs versus incorrect boot-time RTC

Devices routinely boot in a state where the RTC is wildly incorrect
in the past (2009, 1999, or even at Unix epoch zero).  When we have
persistent jobs to be scheduled at boot, this presents a problem: when
should those jobs run, given that our idea of "now" is incorrect?

The previous implementation fell back to rescheduling these jobs
"from scratch" in this situation, as though they were newly-introduced,
but this turns out to have some emergent pathologies when the jobs
were intended to become runnable after long initial delays: the
rescheduling behavior could wind up starving jobs out entirely,
never running them regardless of how much real uptime the device
had, given the "wrong" pattern of reboots.

We now preserve the original nominal schedule, but recognize when we
have booted in a pathological situation, and correct the schedule for
these jobs when the system clock becomes sensible.

Bug 63817592
Test: JobScheduler test suite plus manual bogus-boot-time repro

Change-Id: Ia36fc5298b68db74e4e07e973b68e68e66206b43
core/java/android/util/AtomicFile.java
services/core/java/com/android/server/job/JobSchedulerService.java
services/core/java/com/android/server/job/JobServiceContext.java
services/core/java/com/android/server/job/JobStore.java
services/core/java/com/android/server/job/controllers/JobStatus.java
services/tests/servicestests/src/com/android/server/job/JobStoreTest.java