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

Cloud NDB - global cache lock entry deleted on put when in transaction - Regression from Legacy NDB #650

Closed
justinkwaugh opened this issue May 17, 2021 · 0 comments · Fixed by #660
Labels
api: datastore Issues related to the googleapis/python-ndb API. priority: p3 Desirable enhancement or fix. May not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@justinkwaugh
Copy link

justinkwaugh commented May 17, 2021

cloud-ndb v 1.8.0

In the legacy NDB client the library correctly attempts to lock keys in memcache for the duration of the transaction. In this library _cache.delete() is incorrectly called in _datastore_api.put() even when in a transaction which results in the lock being immediately deleted post put() but pre-transaction commit.

The lines:

        if use_global_cache:
            yield _cache.global_delete(cache_key)

should be

        if use_global_cache and not transaction:
            yield _cache.global_delete(cache_key)

EDIT (@chrisrossi ): Per discussion from #657, we actually want to move when this delete occurs to the end of the transaction, post-commit, so the fix will be somewhat more than a one-liner.

@product-auto-label product-auto-label bot added the api: datastore Issues related to the googleapis/python-ndb API. label May 17, 2021
@crwilcox crwilcox added priority: p3 Desirable enhancement or fix. May not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels May 17, 2021
chrisrossi pushed a commit to chrisrossi/python-ndb that referenced this issue May 20, 2021
When in a transaction, keys should only be cleared from the global cache
after transaction has been committed.

Fixes googleapis#650 googleapis#657
chrisrossi pushed a commit that referenced this issue Jun 7, 2021
* fix: defer clearing global cache when in transaction

When in a transaction, keys should only be cleared from the global cache
after the transaction has been committed.

Fixes #650 #657
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the googleapis/python-ndb API. priority: p3 Desirable enhancement or fix. May not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants