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

hotfix: Subscription upgrade #1366

Merged
merged 1 commit into from
Oct 5, 2023
Merged

Conversation

vincent-pochet
Copy link
Collaborator

@vincent-pochet vincent-pochet commented Oct 3, 2023

Context

Some issues were recently reported with subscription upgrade with subscriptions attached to a plan payed in advance,

After investigation it appears that the issue is related to some jobs enqueued during the database transaction dealing with the upgrade process. As the jobs might be performed by sidekiq before the commit of the transaction, the result is unpredictable (subscription status in particular might not be the expected one) and the issue hard to reproduce.

Description

The fix is to add all jobs in a queue and perform them only when the DB transaction lock is released.

For that purpose a new reusable utility concern was created named Utils::TransactionalJobs. It exposes two methods: perform_later to push the job into a queue and perform_pending_jobs to run all jobs when the transaction is released.

@vincent-pochet vincent-pochet added the 🐞 Bug Something isn't working label Oct 3, 2023
@vincent-pochet vincent-pochet self-assigned this Oct 3, 2023
@jdenquin
Copy link
Contributor

jdenquin commented Oct 4, 2023

it looks like we should start thinking about batches?

@vincent-pochet
Copy link
Collaborator Author

@jdenquin indeed, that would be great for some scenarios!

@vincent-pochet vincent-pochet merged commit 66ff323 into main Oct 5, 2023
5 checks passed
@vincent-pochet vincent-pochet deleted the fix-subscription-upgrade branch October 5, 2023 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants