Transactions - Bug when using transaction APIs explicitly (not through the context manager) #447
Labels
api: datastore
Issues related to the googleapis/python-datastore 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.
TL;DR : when using
trx.begin()
andtrx.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
andcurrent_transaction
Environment details
3.8.16
22.0.4
google-cloud-datastore
version:2.15.2
Steps to reproduce
client.transaction()
txn.begin()
entity_in_txn = client.get(key)
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
The text was updated successfully, but these errors were encountered: