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

fix: api lock on PaymentsCreate #2916

Merged
merged 2 commits into from
Nov 20, 2023
Merged

Conversation

dracarys18
Copy link
Member

@dracarys18 dracarys18 commented Nov 17, 2023

Type of Change

  • Bugfix

Description

Added API locking for PaymentsCreate and removed unnecessary get_or_generate_id calls.

Motivation and Context

This fixes race condition when you do PaymentsCreate with confirm=true. A scenario when this can happen is when
you do PaymentsCreate with confirm = true and while it's happening Connector sends a webhook and it updates PaymentAttempt but it hasn't send the response yet so the process is running with old PaymentAttempt state which causes inconsistency.

How did you test it?

  • PaymentsCreate with confirm = true to adyen connector which has the above behaviour.
  • Check for API locking.
{app=<app-name>} |= `unique_locking_key: \"<payment-id>\", api_identifier: Payments,` |= `src/core/api_locking.rs`
  • And sanity test all Payments API.

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code

@dracarys18 dracarys18 added A-core Area: Core flows S-waiting-on-review Status: This PR has been implemented and needs to be reviewed labels Nov 17, 2023
@dracarys18 dracarys18 added this to the November 2023 Release milestone Nov 17, 2023
@dracarys18 dracarys18 self-assigned this Nov 17, 2023
@dracarys18 dracarys18 requested review from a team as code owners November 17, 2023 14:34
jarnura
jarnura previously approved these changes Nov 20, 2023
@dracarys18 dracarys18 dismissed stale reviews from Abhicodes-crypto and jarnura via 1675b33 November 20, 2023 08:10
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Nov 20, 2023
Merged via the queue into main with commit cfabfa6 Nov 20, 2023
12 of 14 checks passed
@Gnanasundari24 Gnanasundari24 deleted the api_lock_on_payment_create branch November 20, 2023 15:41
@dracarys18 dracarys18 restored the api_lock_on_payment_create branch November 21, 2023 07:41
@SanchithHegde SanchithHegde deleted the api_lock_on_payment_create branch November 27, 2023 11:49
@SanchithHegde SanchithHegde removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Core flows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants