Closed Bug 1497960 Opened Last year Closed Last year

ProfileAge.jsm is a little racey

Categories

(Toolkit :: Telemetry, enhancement, P1)

enhancement

Tracking

()

RESOLVED FIXED
mozilla64
Tracking Status
firefox64 --- fixed

People

(Reporter: mossop, Assigned: mossop)

References

(Depends on 1 open bug)

Details

Attachments

(2 files)

Because we create multiple instances for a given profile directory and because reading the times.json is asynchronous for each we can end up with various races. For example:

let a = ProfileAge();
let b = ProfileAge();
a.created;
b.recordProfileReset();

Timeline:

* Instance A starts loading times.json.
* Instance B starts loading times.json.
* Instance A finishes loading times.json, created date is missing so starts scanning profile.
* Instance B finishes loading times.json, sets reset time and starts writing times.json.
* Instance B finishes writing times.json.
* Instance A finishes scanning profile, sets creation time and starts writing times.json.
* Instance A finishes writing times.json.

Now times.json exists with the creation time but the reset time has been lost.
ProfileAge now returns a promise that resolves to an instance that has already
loaded its times.json. This makes multiple attempts to update data in times.json
safer.
Marking P1 for "it's being worked on" and so it turns up in our dashboard.
Priority: -- → P1
Pushed by dtownsend@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/3edf43a3f1a4
Make ProfileAge return the same instances for the same profile directory and preload times.json to avoid data races. r=janerik
https://hg.mozilla.org/mozilla-central/rev/3edf43a3f1a4
Status: NEW → RESOLVED
Closed: Last year
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
Commit pushed to master at https://github.com/mozilla/activity-stream

https://github.com/mozilla/activity-stream/commit/92661f1b9b0d6577bd3cac00b6dcbed3c2284ca6
Port Bug 1497960: Make ProfileAge return the same instances for the same profile directory and preload times.json to avoid data races. r=janerik (#4500)
You need to log in before you can comment on or make changes to this bug.