-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Transaction does not get rolled back if exception happens during commit. #457
Comments
Hmm, DJH NOTE: This was in reference to #488 |
I think DJH NOTE: This was in reference to #488 |
I just realized this was filed and closed as #136. However, I think it should be addressed as discussed by Tres. |
@tseaver This will probably be fixed as part of #514. This only causes failure of future code because the cleanup self.connection.transaction(None) doesn't get a chance to occur either in Once we rely on However, it's unclear to me if we need to Working code to re-create this bug (as of 0525530): >>> from gcloud import datastore
>>> from gcloud.datastore import _implicit_environ
>>> from gcloud.datastore.key import Key
>>> from gcloud.datastore.transaction import Transaction
>>>
>>> print _implicit_environ.CONNECTION
None
>>>
>>> datastore.set_default_connection()
>>> datastore.set_default_dataset_id('foo')
>>>
>>> print _implicit_environ.CONNECTION
<gcloud.datastore.connection.Connection object at 0x7f64c2577190>
>>> print _implicit_environ.CONNECTION.transaction()
None
>>>
>>> with Transaction():
... partial_key = Key('Knd')
... partial_key.delete()
...
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
File "gcloud/datastore/batch.py", line 277, in __exit__
self.commit()
File "gcloud/datastore/transaction.py", line 182, in commit
super(Transaction, self).commit()
File "gcloud/datastore/batch.py", line 252, in commit
response = self.connection.commit(self._dataset_id, self.mutation)
File "gcloud/datastore/connection.py", line 376, in commit
datastore_pb.CommitResponse)
File "gcloud/datastore/connection.py", line 100, in _rpc
data=request_pb.SerializeToString())
File "gcloud/datastore/connection.py", line 77, in _request
raise six.moves.http_client.HTTPException(message)
httplib.HTTPException: Request failed with status code 400. Error was: Key path element must not be incomplete: [Knd: ]
>>> print _implicit_environ.CONNECTION
<gcloud.datastore.connection.Connection object at 0x7f64c2577190>
>>> print _implicit_environ.CONNECTION.transaction()
<gcloud.datastore.transaction.Transaction object at 0x7f64c2464510> |
If the back-end returns an error in our call to its |
I'm not clear why the "token" for the transaction is known to be valid. I'd like to get input from someone on the datastore team to see if |
I cannot see any possible way to reuse the opaque |
I wasn't sure that
is actually true. I just tried to commit twice and it clearly fails. I was "distracted" by the fact that a transaction can have multiple |
To summarize all that just happened, the only thing left to fix this bug is the removal of self.connection.transaction(None) which will happen by the end of #514. |
Fixed as of #550 |
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
This snippet provides an example of how to extract SessionInfo from WebhookRequests. Co-authored-by: Anthonios Partheniou <partheniou@google.com>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 459095142 Source-Link: googleapis/googleapis@4f1be99 Source-Link: googleapis/googleapis-gen@ae686d9 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYWU2ODZkOWNkZTRmYzNlMzZkMGFjMDJlZmI4NjQzYjE1ODkwYzFlZCJ9 feat: add audience parameter PiperOrigin-RevId: 456827138 Source-Link: googleapis/googleapis@23f1a15 Source-Link: googleapis/googleapis-gen@4075a85 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDA3NWE4NTE0ZjY3NjY5MWVjMTU2Njg4YTViYmYxODNhYTk4OTNjZSJ9
* fix(deps): allow protobuf 3.19.5 * explicitly exclude protobuf 4.21.0
* fix(deps): Require google-api-core >=1.34.0, >=2.11.0 fix: Drop usage of pkg_resources fix: Fix timeout default values docs(samples): Snippetgen should call await on the operation coroutine before calling result PiperOrigin-RevId: 493260409 Source-Link: googleapis/googleapis@fea4387 Source-Link: googleapis/googleapis-gen@387b734 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMzg3YjczNDRjNzUyOWVlNDRiZTg0ZTYxM2IxOWE4MjA1MDhjNjEyYiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * add gapic_version.py Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <partheniou@google.com>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
For example:
Maybe this isn't such a big deal since most code will stop working after the first uncaught exception? The only reason I noticed is because using a test-runner, the exception is caught and printed, but the process just moves on to the next.
The text was updated successfully, but these errors were encountered: