Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a subscriptions sync algorithm between auth-server and subhub? #1148

Open
lmorchard opened this issue May 17, 2019 · 4 comments

Comments

@lmorchard
Copy link
Member

commented May 17, 2019

While working through #719, it occurred to me that we could implement a small "sync" algorithm to help make subscriptions consistent between FxA, subhub, and Stripe:

  1. Fetch all the subscription rows for a user from FxA database
  2. Fetch the customer record from subhub, which includes current subscriptions
  3. Compare the two lists
  4. Where subhub reports a subscription ID that FxA doesn't have, create the corresponding FxA subscription
  5. Where FxA reports a subscription ID that subhub doesnt have, delete the corresponding FxA subscription

I imagine this wouldn't run very frequently per user, but it would be interesting to work out where it would be useful to do so. For example, on a visit to the payment pages with a fresh access token might be a good point to run it - that might help resolve any inconsistencies just before a user tries to manage subscription.

This would be in addition to #713 as a kind of belt-and-suspenders way to maintain consistency

@lmorchard

This comment has been minimized.

Copy link
Member Author

commented May 17, 2019

@ian and @bbangert might have thoughts on this.

@bbangert

This comment has been minimized.

Copy link
Contributor

commented May 18, 2019

I think this makes sense to do on-demand during login and/or visiting the Account Management page. This provides another way to ensure any event handling mismatches repair themselves quickly.

  1. On account management load, if SubHub subscription status doesn't match local, then
  2. Generate subscription state change event (#1103) to force RP syncs

We should also ensure that any means we have that a user can trigger to force sync should be known by Support so that any issues a user may experience with inconsistent subscription status propagation can be easily resolved for the few users that may be affected.

@lmorchard

This comment has been minimized.

Copy link
Member Author

commented Sep 10, 2019

Haven't looked at this issue in awhile, but the thing I've been thinking lately: We probably want to drop the subscriptions table in FxA auth-server altogether.

All the relevant information for subscriptions is in the subhub customer record. So, auth-server should just cache this resource to save traffic against subhub & stripe, then use that data to calculate subscription capabilities. That way, there's no granular sync per se, just cache revalidation

@bbangert

This comment has been minimized.

Copy link
Contributor

commented Sep 13, 2019

I'm fine caching it, though just like with the other cache issue in profile-server, we need some fairly well defined policies for when the cache is cleared, and mechanisms that will guarantee a clearing of it if a user experiences a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.