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

[SDP-1397] Circle Payouts pt2: error handling & retries #491

Merged
merged 13 commits into from
Dec 13, 2024

Conversation

marcelosalloum
Copy link
Collaborator

@marcelosalloum marcelosalloum commented Dec 11, 2024

What

Errors in the POST /recipient endpoint are not being properly handled. What;s missing?

  • When POST /recipient fails with ErrCircleRecipientCreationFailedTooManyTimes, we update the payments table with the failed status explaining the reason.
  • When a payment that failed due to recipient creation issues is retried, the recipient is reset with status=NULL and sync_attempts=0.
  • The method ensureRecipientIsReady was split into different sub-methods for better modularity and clarity, as suggested in [SDP-1397] Circle payouts pt1 #486 (comment).
Screenshot 2024-12-12 at 4 39 08 PM
  • Tested with scheduled jobs
  • Tested with Kafka

Why

To wrap up https://stellarorg.atlassian.net/browse/SDP-1397

Checklist

PR Structure

  • This PR has a reasonably narrow scope (if not, break it down into smaller PRs).
  • This PR title and description are clear enough for anyone to review it.
  • This PR does not mix refactoring changes with feature changes (split into two PRs otherwise).

Thoroughness

  • This PR adds tests for the new functionality or fixes.
  • This PR contains the link to the Jira ticket it addresses.

Configs and Secrets

  • No new CONFIG variables are required -OR- the new required ones were added to the helmchart's values.yaml file.
  • No new CONFIG variables are required -OR- the new required ones were added to the deployments (pr-preview, dev, demo, prd).
  • No new SECRETS variables are required -OR- the new required ones were mentioned in the helmchart's values.yaml file.
  • No new SECRETS variables are required -OR- the new required ones were added to the deployments (pr-preview secrets, dev secrets, demo secrets, prd secrets).

Release

  • This is not a breaking change.
  • This is ready for production.. If your PR is not ready for production, please consider opening additional complementary PRs using this one as the base. Only merge this into develop or main after it's ready for production!

Deployment

  • Does the deployment work after merging?

@marcelosalloum marcelosalloum self-assigned this Dec 11, 2024
@marcelosalloum marcelosalloum temporarily deployed to Anchor Integration Tests December 11, 2024 00:12 — with GitHub Actions Inactive
@marcelosalloum marcelosalloum temporarily deployed to Receiver Registration - E2E Integration Tests (Stellar) December 11, 2024 00:12 — with GitHub Actions Inactive
@marcelosalloum marcelosalloum temporarily deployed to Anchor Integration Tests December 12, 2024 21:14 — with GitHub Actions Inactive
@marcelosalloum marcelosalloum temporarily deployed to Receiver Registration - E2E Integration Tests (Stellar) December 12, 2024 21:14 — with GitHub Actions Inactive
@marcelosalloum marcelosalloum temporarily deployed to Anchor Integration Tests December 12, 2024 22:51 — with GitHub Actions Inactive
@marcelosalloum marcelosalloum temporarily deployed to Receiver Registration - E2E Integration Tests (Stellar) December 12, 2024 22:51 — with GitHub Actions Inactive
@marcelosalloum marcelosalloum force-pushed the feat/SDP-1397-pt2-retry-recipients branch from a1d17ec to e43fafa Compare December 13, 2024 00:31
@marcelosalloum marcelosalloum temporarily deployed to Receiver Registration - E2E Integration Tests (Stellar) December 13, 2024 00:31 — with GitHub Actions Inactive
@marcelosalloum marcelosalloum temporarily deployed to Anchor Integration Tests December 13, 2024 00:31 — with GitHub Actions Inactive
@marcelosalloum marcelosalloum force-pushed the feat/SDP-1397-pt2-retry-recipients branch from e43fafa to f15f82b Compare December 13, 2024 00:34
@marcelosalloum marcelosalloum temporarily deployed to Receiver Registration - E2E Integration Tests (Stellar) December 13, 2024 00:34 — with GitHub Actions Inactive
@marcelosalloum marcelosalloum temporarily deployed to Anchor Integration Tests December 13, 2024 00:34 — with GitHub Actions Inactive
@marcelosalloum marcelosalloum marked this pull request as ready for review December 13, 2024 00:40
@marcelosalloum marcelosalloum changed the title [SDP-1397] Circle Payouts error handling [SDP-1397] Circle Payouts pt2: error handling & retries Dec 13, 2024
Copy link
Collaborator

@marwen-abid marwen-abid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! This is great!

_, err = p.Models.CircleRecipient.ResetRecipientsForRetryIfNeeded(ctx, dbTx, reqBody.PaymentIDs...)
if err != nil {
return nil, fmt.Errorf("resetting circle recipients for retry if needed: %w", err)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Totally optional as it's not an expensive operation. But you can also add a check to only do this operation for Circle distribution accounts.

distAccount, err := p.DistributionAccountResolver.DistributionAccountFromContext(ctx)
if err != nil {
	return nil, fmt.Errorf("resolving distribution account: %w", err)
}

if distAccount.IsCircle() {
	_, err = p.Models.CircleRecipient.ResetRecipientsForRetryIfNeeded(ctx, dbTx, reqBody.PaymentIDs...)
	if err != nil {
		return nil, fmt.Errorf("resetting circle recipients for retry if needed: %w", err)
	}
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 83469c5.

@marcelosalloum marcelosalloum temporarily deployed to Anchor Integration Tests December 13, 2024 18:23 — with GitHub Actions Inactive
@marcelosalloum marcelosalloum temporarily deployed to Receiver Registration - E2E Integration Tests (Stellar) December 13, 2024 18:23 — with GitHub Actions Inactive
@marcelosalloum marcelosalloum temporarily deployed to Anchor Integration Tests December 13, 2024 18:52 — with GitHub Actions Inactive
@marcelosalloum marcelosalloum temporarily deployed to Receiver Registration - E2E Integration Tests (Stellar) December 13, 2024 18:52 — with GitHub Actions Inactive
@marcelosalloum marcelosalloum temporarily deployed to Anchor Integration Tests December 13, 2024 18:53 — with GitHub Actions Inactive
@marcelosalloum marcelosalloum temporarily deployed to Receiver Registration - E2E Integration Tests (Stellar) December 13, 2024 18:53 — with GitHub Actions Inactive
@stellar-jenkins
Copy link

Something went wrong with PR preview build please check

@marcelosalloum marcelosalloum temporarily deployed to Anchor Integration Tests December 13, 2024 19:07 — with GitHub Actions Inactive
@marcelosalloum marcelosalloum temporarily deployed to Receiver Registration - E2E Integration Tests (Stellar) December 13, 2024 19:07 — with GitHub Actions Inactive
@marcelosalloum marcelosalloum merged commit f9e2520 into develop Dec 13, 2024
13 checks passed
@marcelosalloum marcelosalloum deleted the feat/SDP-1397-pt2-retry-recipients branch December 13, 2024 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants