Repository navigation
Closed
Labels
api: datastoreIssues related to the Datastore API.Issues related to the Datastore API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.status: awaiting informationtype: 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
I am getting intermittent ServiceUnavailable: 503 error messages when doing datastore operations with the google cloud client library. The stack trace is below. I am running Python 2.7 on Ubuntu, within a Docker container on a small Kubernetes cluster.
Traceback (most recent call last):
...
File "/home/speedplane/DA/djangoappengine/db_gcl/compiler.py", line 345, in get_matching_pk
self.client.get_multi(self.included_pks, **config)
File "/usr/local/lib/python2.7/dist-packages/google/cloud/datastore/client.py", line 307, in get_multi
transaction_id=transaction and transaction.id,
File "/usr/local/lib/python2.7/dist-packages/google/cloud/datastore/client.py", line 124, in _extended_lookup
transaction_id=transaction_id,
File "/usr/local/lib/python2.7/dist-packages/google/cloud/datastore/_http.py", line 519, in lookup
lookup_response = self._datastore_api.lookup(project, lookup_request)
File "/usr/local/lib/python2.7/dist-packages/google/cloud/datastore/_http.py", line 304, in lookup
return self._stub.Lookup(request_pb)
File "/usr/lib/python2.7/contextlib.py", line 35, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/local/lib/python2.7/dist-packages/google/cloud/datastore/_http.py", line 260, in _grpc_catch_rendezvous
raise error_class(exc.details())
ServiceUnavailable: 503 {"created":"@1489111389.496403106","description":"Endpoint read failed","file":"src/core/ext/transport/chttp2/transport/chttp2_transport.c","file_line":1851,"grpc_status":14,"occurred_during_write":0,"referenced_errors":[{"created":"@1489111389.496341023","description":"Secure read failed","file":"src/core/lib/security/transport/secure_endpoint.c","file_line":166,"referenced_errors":[{"created":"@1489111389.496338171","description":"Socket closed","fd":25,"file":"src/core/lib/iomgr/tcp_posix.c","file_line":249,"target_address":"ipv4:173.194.192.95:443"}]}]}
For ease of reading, that last line is expanded:
ServiceUnavailable: 503 {
"created":"@1489111389.496403106",
"description":"Endpoint read failed",
"file":"src/core/ext/transport/chttp2/transport/chttp2_transport.c",
"file_line":1851,
"grpc_status":14,"occurred_during_write":0,
"referenced_errors":[{"created":"@1489111389.496341023",
"description":"Secure read failed",
"file":"src/core/lib/security/transport/secure_endpoint.c","file_line":166,
"referenced_errors":[{"created":"@1489111389.496338171",
"description":"Socket closed",
"fd":25,"file":"src/core/lib/iomgr/tcp_posix.c",
"file_line":249,"target_address":"ipv4:173.194.192.95:443"}]
}]
}
I am running this within a Docker container orchestrated by Kubernetes. My Dockerfile inherits from ubuntu:trusty. Below is version information:
# lsb_release
LSB Version: core-2.0-amd64:core-2.0-noarch:core-3.0-amd64:core-3.0-noarch:core-3.1-amd64:core-3.1-noarch:core-3.2-amd64:core-3.2-noarch:core-4.0-amd64:core-4.0-noarch:core-4.1-amd64:core-4.1-noarch:security-4.0-amd64:security-4.0-noarch:security-4.1-amd64:security-4.1-noarch
# python --version
Python 2.7.6
Metadata
Metadata
Assignees
Labels
api: datastoreIssues related to the Datastore API.Issues related to the Datastore API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.status: awaiting informationtype: 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.
Activity
cobookman commentedon Mar 10, 2017
Is there a chance that this is related: #2896
cobookman commentedon Mar 10, 2017
Also the
Socket closederror makes it seem like gRPC had its connection terminated to datastore. And needs to be re-opened. In issue #2896, they mention that the python datastore client library doesn't implement retry logic (yet). This issue was created around adding retry logic to all client libs: #2694lukesneeringer commentedon Mar 10, 2017
Are you getting the error at 30 minute intervals like the author of #2896?
speedplane commentedon Mar 10, 2017
It's happening much more regularly than once every 30 minutes. Below are logs with some timings.
lukesneeringer commentedon Mar 10, 2017
Interesting that the second log set shows so much more frequent failures than the first one.
daspecster commentedon Mar 10, 2017
@speedplane if this was asked already somewhere, sorry for the repeat question, but is this script using
multiprocessingor any kind of threading?My thought is that either it's an upstream issue(in which case I feel like there would be more people chiming in) or there's something in your architecture that is unhappy.
speedplane commentedon Mar 10, 2017
I saw that discussion. I don't use multiprocessing. I don't think there is threading, but just in case, I make sure all my clients are thread-local using the function below.
Perhaps I should have mentioned, but this call is being made across projects. It is being made from an instance within a project named
ocr-api, but is trying to grab data from a project nameddocketupdate.Also, I have a cloud support package, and I can try opening a case if that would help.
I can add my own retry logic and see if it helps, but given how often this is occurring, it would be preferable if the underlying issue could be addressed. I added a third screenshot of timestamps above.
cobookman commentedon Mar 10, 2017
daspecster commentedon Mar 10, 2017
@speedplane the project information is helpful. I believe there was an issue about that a long time ago regarding that not being supported well? I can't seem to find it though.
@dhermes @tseaver might remember?
speedplane commentedon Mar 10, 2017
Done. See case ID 12283187.
speedplane commentedon Mar 13, 2017
I stopped receiving these altogether on March 10 at around 3:30PM ET. I did not redeploy or change any settings in my app since then. Did something change on the backend?
lukesneeringer commentedon Mar 13, 2017
Not sure. Perhaps?
18 remaining items
speedplane commentedon Jan 30, 2018
chemelnucfin commentedon Jan 30, 2018
@vsoch Thank you for taking the time to respond. Perhaps in the future you can give our product a try again. I apologize for any inconvenience this may have caused.
@speedplane From 4766 it seems like getting a 503 GOAWAY message from server side is a normal part of the process. I believe that we are having retries built into our clients which will hopefully eliminate those errors. I will keep track of our progress on that. Thank you for your response.
tseaver commentedon Feb 20, 2018
The
google-cloud-datastore 1.5.0release uses newly-generated GAPIC code, which includes built-in retries for idempoten methods. @speedplane, can you please try to reproduce with that version?theacodes commentedon Feb 22, 2018
I'm going to go ahead and close this as the latest release include significant retry plumbing. If it's still an issue, feel free to comment and we'll re-open.
tgensol commentedon May 3, 2018
Hi guys,
I am using the google-cloud-datastore on AWS Lambda (serverless), and sometimes I am getting the error too :
I am using google-cloud-core 0.28.1 and google-cloud-datastore 1.6.0,
Thanks !
tseaver commentedon May 3, 2018
@tgensol Hmm, your error is propagated from a
Commitcall, which is not idempotent. I don't think we have any expected automatic retries for that case. @jonparrott can you confirm?theacodes commentedon May 3, 2018
Yeah, it's generally not safe for us to retry a commit operation blindly. If you are certain it's safe to retry, you can do so using our
retryhelper:speedplane commentedon May 3, 2018
I've dealt with this same problem. Using the retry handler directly can be difficult because the calls are often burried under middleware code. Instead, I've monkey hacked the default retry handler settings:
theacodes commentedon May 3, 2018
well, I certainly can't endorse that - but I'm glad it works for you.
EhsanKia commentedon May 19, 2020
For what it's worth, I have an AppEngine Flask project, and I used to have
datastore_client = datastore.Client()as a global, creating the client once for the lifetime of the instance (That's how it's done in the sample apps)As with above, the connection would eventually break and the client would get corrupted, so I've switched to instead instantiating a new client every time since I don't need to very often. I would've rather implemented a getter which checks if the client is working and reloads it if it isn't, but there doesn't seem to be a clean way of doing that?