-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix (wallet-race-condition): Retry wallet update upon race condition (#…
…2664) ## Context Recently, feature for updating wallet balance upon successful payment was introduced. ## Description If multiple paid credits are issues, there is a chance that after successful payment processing we will receive all events from payment provider in the same request. Multiple events will schedule multiple jobs for increasing wallet balance and each job is updating the same resource so there is a high chance of race condition. This PR introduced optimistic locking approach with 1 additional retry if multiple processes are updating the same resource.
- Loading branch information
1 parent
f02d6fe
commit 4229e44
Showing
4 changed files
with
42 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
class AddLockVersionToWallets < ActiveRecord::Migration[7.1] | ||
def change | ||
add_column :wallets, :lock_version, :integer, default: 0, null: false | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.