-
Notifications
You must be signed in to change notification settings - Fork 42
Closed
Labels
api: datastoreIssues related to the googleapis/python-datastore API.Issues related to the googleapis/python-datastore API.priority: p3Desirable enhancement or fix. May not be included in next release.Desirable enhancement or fix. May not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
TL;DR : when using trx.begin() and trx.commit() the transactions don't behave as expected.
Please refer to this merge request to see the bug highlighted in the test.
From a quick look at the code, the problem seems to be the transaction is not added to the client._batch_stack when the APIs are called explicitly.
_push_batch an _pop_batch are called only through the context manager __enter__ and __exit__.
Because of this
client.current_batch and current_transaction
Environment details
- OS type and version: MacOs Ventura 13.1
- Python version:
3.8.16 - pip version:
22.0.4 google-cloud-datastoreversion:2.15.2
Steps to reproduce
- Create a transaction
client.transaction() - Start a transaction
txn.begin() - Get an object
entity_in_txn = client.get(key) - Update and put the same entity outside of the transaction.
- Update the entity and put the entity within the transaction
- Commit the transaction
txn.commit()
The transaction should raise a Conflit but it doesn't.
(When doing the same with the context manager the Exeption is raised, see here
Code example
See here
Stack trace
# example
N/A
artoale
Metadata
Metadata
Assignees
Labels
api: datastoreIssues related to the googleapis/python-datastore API.Issues related to the googleapis/python-datastore API.priority: p3Desirable enhancement or fix. May not be included in next release.Desirable enhancement or fix. May not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.