-
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
Transactions are commited in CommitRequest.NON_TRANSACTIONAL mode #903
Comments
We managed to get the correct behaviour by plumbing through File "~/src/python/improbable/db/common/transaction.py", line 15, in commit
response = self.connection.commit(self._dataset_id, self.mutation, self._id)
File "~/virtualenv/python/local/lib/python2.7/site-packages/gcloud/datastore/connection.py", line 324, in commit
datastore_pb.CommitResponse)
File "~/virtualenv/python/local/lib/python2.7/site-packages/gcloud/datastore/connection.py", line 108, in _rpc
data=request_pb.SerializeToString())
File "~/virtualenv/python/local/lib/python2.7/site-packages/gcloud/datastore/connection.py", line 85, in _request
raise make_exception(headers, content, use_json=False)
Conflict: 409 too much contention on these datastore entities. please try again. I think the right solution here would be to catch it in the |
#903: Ensure transaction ID is passed through to connection during commit.
What's the ETA on a version that supports it? :) Also, this currently has a very clunky API, since there is no |
@mwitkow-io I'm going to cut a release today (or tomorrow). |
RE: "opportunistic concurrency model of Datastore is poorly exposed to the end user." we expect the error status codes and error messages from the Datastore API (the RPC service) to be useful. If there are issues where they aren't useful, we should take it up with the API folks. The |
@mwitkow-io Also I'd love to chat about lack of thread-safety in We actually don't require use of it, but this is not at all clear from our docs (and may never be). |
1 similar comment
@mwitkow-io Also I'd love to chat about lack of thread-safety in We actually don't require use of it, but this is not at all clear from our docs (and may never be). |
Sure thing, would be great to chat! I'm in London though, so 8h diff to MTV. 5pm tomorrow BST? Please send a On Thu, 4 Jun 2015 18:47 Danny Hermes [email protected] wrote:
|
Invite sent for 4pm your time (if you're free). I assumed you use the email listed on your GitHub profile. If 4pm doesn't work I gave you edit privileges on the event. |
Thanks, that works great :-) On Thu, 4 Jun 2015 19:16 Danny Hermes [email protected] wrote:
|
This intentionally forces data contention in a transaction (by updating the entity outside of the transaction). This is to prevent regressions like googleapis#903.
This intentionally forces data contention in a transaction (by updating the entity outside of the transaction). This is to prevent regressions like googleapis#903.
We have just been bitten by this using the latest
0.5.0
.We had the following piece of code, run in two different threads:
We've seen two copies of the
archived_entity
for the sameentity
. We've managed to reproduce it with two threads performing this concurrently (running separate Connections each, because httplib2 is not thread safe).Having used Datastore's underlying technology before, I expected to get a
ConcurrentModificationException
on delete, and one of the threads throwing it, similar to what the Java API for AppEngine describes:https://cloud.google.com/appengine/docs/java/datastore/transactions#Java_Uses_for_transactions
However, both of them succeed creating two copies of
archived_entity
, and there's noConcurrentModificationException
anywhere ingcloud-python
code.We've tracked down to the following:
Transaction#commit
calls theBatch#commit
https://github.com/GoogleCloudPlatform/gcloud-python/blob/master/gcloud/datastore/transaction.py#L177Batch#commit
is unaware of theTransaction#id
, callsConnection#commit
without thetransaction_id
parameter https://github.com/GoogleCloudPlatform/gcloud-python/blob/master/gcloud/datastore/batch.py#L214Connection#commit
getstransaction_id
, and sets the REST request's mode todatastore_pb.CommitRequest.NON_TRANSACTIONAL
in https://github.com/GoogleCloudPlatform/gcloud-python/blob/master/gcloud/datastore/connection.py#L321Impact: This means that all transactions made through
python-gcloud
are non-transactional. Please treat it as a P0 bug.The text was updated successfully, but these errors were encountered: