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

test: add test to reproduce https://github.com/ory/hydra/issues/1719 #1734

Closed
wants to merge 2 commits into from

Conversation

aaslamin
Copy link
Contributor

@aaslamin aaslamin commented Feb 19, 2020

Related issue

#1719

What's going on here...

This PR adds a test that consistently reproduces the bug identified in the linked issue. To run locally, navigate to the oauth2 directory and run:

go test -run=TestCreateRefreshTokenSessionBug -count=1 -v

⚠️ Note: this is an integration test and requires you to have Docker running locally as it will bring up a Postgres container

Checklist

  • I have read the contributing 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 green light (please contact security@ory.sh) 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 necessary documentation within the code base (if appropriate)
  • I have documented my changes in the developer guide (if appropriate)

@aaslamin aaslamin requested a review from aeneasr February 19, 2020 09:55
@aaslamin aaslamin force-pushed the oauth2/reproduce-1719 branch from de933f5 to 6b4a79e Compare February 19, 2020 10:00
stopWorkers()
successCh <- struct{}{}
return
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is where you want to end up in! (to reproduce the 🐛)

image

// race again!
postgresRegistry.OAuth2Storage().CreateRefreshTokenSession(ctx, tokenSignature, request)
stopWorkers()
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

😭 try again!

image

@aeneasr
Copy link
Member

aeneasr commented Feb 19, 2020

Yo, this is a sweet test case! If you'd be up for fixing the issue as well I think this can be merged right away!

@aaslamin
Copy link
Contributor Author

Yo, this is a sweet test case! If you'd be up for fixing the issue as well I think this can be merged right away!

@aeneasr I'll take a look at this later in the week when I get a free cycle. However, I think the solution lies in fosite as the errors in the refresh flow are encapsulated as a server error which is not what we want.

We may need to handle this on a DB by DB basis as the error copy returned by Postgres, MySQL and CockroachDB could be different when an outdated read is done in a transaction utilizing the repeatable read iso level. Alternatively, we could return the raw error from fosite and let the Hydra deal with it via the sqlx package.

@aeneasr
Copy link
Member

aeneasr commented Feb 28, 2020

You're the best man!

I think we can generally enforce one transaction type for all databases, and release a beta to see if it has negative performance impacts for people. What do you think?

@CLAassistant
Copy link

CLA assistant check
All committers have signed the CLA.

@aaslamin aaslamin force-pushed the oauth2/reproduce-1719 branch from 6b4a79e to 5b485db Compare March 21, 2020 10:01
@aaslamin
Copy link
Contributor Author

Closing in favour of #1766 which has a better implementation.

@aaslamin aaslamin closed this Mar 22, 2020
@aaslamin aaslamin deleted the oauth2/reproduce-1719 branch March 22, 2020 10:48
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