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

get_or_create gets twice (docs deficiency?) #89

Closed
sqlalchemy-bot opened this issue Nov 4, 2015 · 3 comments
Closed

get_or_create gets twice (docs deficiency?) #89

sqlalchemy-bot opened this issue Nov 4, 2015 · 3 comments

Comments

@sqlalchemy-bot
Copy link

Migrated issue, originally created by jvanasco (jvanasco)

Looking at some performance logs during an audit, it appeared that our dogpile implementation was broken -- there would often be two identical cache misses in a row.

After stacktracing and looking through source, the issue was simple enough and a non-issue -- dogpile.core.dogpile.Lock is implemented in such a way that the logic flows on a get/create like this:

• get
• create
• get again (protect against race conditions)
• set

I think it would be helpful to just add a line to the API docs about this, as I couldn't find anything in dogpile.cache addressing it -- and it sure looks like I broke something, even when everything is working exactly as it should.

Note: `get_or_create` utilizes the `Lock` mechanism from `dogpile.core`. In order to protect against race conditions, a secondary call to 'get' is made before the call to `set`.
@sqlalchemy-bot
Copy link
Author

jvanasco (jvanasco) wrote:

looking back on this, i think there is a bug. reopening with more info.

@sqlalchemy-bot
Copy link
Author

Changes by jvanasco (jvanasco):

  • changed status to closed

@sqlalchemy-bot
Copy link
Author

Changes by jvanasco (jvanasco):

  • edited description

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant