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: do not retry sending responses #3764

Merged
merged 1 commit into from
May 8, 2024
Merged

Conversation

aeneasr
Copy link
Member

@aeneasr aeneasr commented May 8, 2024

Related issue(s)

Checklist

  • I have read the contributing guidelines.
  • I have referenced an issue containing the design document if my change
    introduces a new feature.
  • I am following the
    contributing code guidelines.
  • I have read the security policy.
  • I confirm that this pull request does not address a security
    vulnerability. If this pull request addresses a security vulnerability, I
    confirm that I got the approval (please contact
    [email protected]) from the maintainers to push
    the changes.
  • I have added tests that prove my fix is effective or that my feature
    works.
  • I have added or changed the documentation.

Further Comments

@aeneasr aeneasr requested review from hperl and alnr as code owners May 8, 2024 09:07
if err != nil {
return err
}
if accessRequest.GetGrantTypes().ExactOne(string(fosite.GrantTypeClientCredentials)) ||
Copy link
Member Author

@aeneasr aeneasr May 8, 2024

Choose a reason for hiding this comment

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

@hperl in 67a85cc you added this transaction wrapper. The transaction handler does two things:

  • Keeps the SQL connection reserved for the transaction (I think!)
  • Retries the SQL statements on specific errors (like ERR_SERIALIZABLE)

Adding a lot of logic to a transaction can be very bad, because (a) it retries all the code, (b) it blocks a SQL connection.

When using a Transaction, please only wrap the code that does indeed execute SQL statements.

}
}

for _, hook := range h.r.AccessRequestHooks() {
if err = hook(ctx, accessRequest); err != nil {
Copy link
Member Author

Choose a reason for hiding this comment

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

Waiting for an external system as part of a SQL transaction is an absolute no-go

}
}

accessResponse, err := h.r.OAuth2Provider().NewAccessResponse(ctx, accessRequest)
Copy link
Member Author

Choose a reason for hiding this comment

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

This writes the response as often as it retries the SQL transaction.

@aeneasr aeneasr merged commit 1bbfdb5 into master May 8, 2024
30 checks passed
@aeneasr aeneasr deleted the fix-duplicate-responses branch May 8, 2024 09:41
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.

2 participants