Closed Bug 1148504 Opened 9 years ago Closed 9 years ago

Protect Firefox Account state with a critical section

Categories

(Android Background Services Graveyard :: Reading List Sync, defect)

All
Android
defect
Not set
normal

Tracking

(firefox38 fixed, firefox39 fixed)

RESOLVED FIXED
Firefox 39
Tracking Status
firefox38 --- fixed
firefox39 --- fixed

People

(Reporter: nalexander, Assigned: nalexander)

References

Details

Attachments

(1 file)

We now have two (background) Firefox Account consumers, Sync and RL.  Due to time pressure, we haven't implemented a nice API for them both to update the account state; instead, they both try to own the state, resulting in races.  The effect is most noticeable when an account is created or re-connected: it's frequent that both consumers will try to fetch keys using the same keyFetchToken; one will win the race and proceed to start syncing; the other will fail to fetch keys and drive the account to Separated (in order to fetch keys).  Result: a terrible user experience.

As a step towards a better API, we need to protect the Account state with a critical section.  Eventually, we transition Sync to requesting token server tokens from the FxAccountAuthenticator using Android's APIs, which makes this much cleaner (since there's then a single consumer to handle locking).
Assignee: nobody → nalexander
Status: NEW → ASSIGNED
rnewman: how do you feel about this?  It's working well locally.

I intended to include telemetry for how long we wait and how long we hold the lock, but I then observed (and explained in the second commit comment) that we should very rarely wait.
Attachment #8584688 - Flags: review?(rnewman)
Summary: Protected Firefox Account state with a critical section → Protect Firefox Account state with a critical section
https://hg.mozilla.org/mozilla-central/rev/2c562029850b
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 39
Attachment #8584688 - Flags: review?(rnewman) → review+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: