google-cloud-ruby: Datastore: does not work inside Puma webserver
Would be good to receive independent confirmation, but from what I can tell is that Datastore queries hang if run inside Puma webserver. Same query runs fine from rails console
process. Worker processes running other queries/inserts also look to be running ok. All environment is the same.
Web process just hangs when calling dataset.run(query)
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 41 (29 by maintainers)
In summary, this is what we discovered when testing with Ruby web servers configured to fork processes (Puma, Passenger, Unicorn):
require 'gcloud/datastore'
require 'gcloud/datastore
executed in a Rails initializer or in any code that is eager loaded (such as within the Rails app/ directory)Here is an example of a Rails CloudDatastore initializer that is currently working with Puma:
@blowmage Unrelated to the grpc initialization problem, we are also trying out your one Gcloud grpc client instance per web server thread concept.
@bmclean Thanks for such a great writeup! This is incredibly useful!
If you (or anyone reading this) are bothered by the fact that you require the library each time you access the dataset object, you can change the implementation a bit to run the require only when you need to create the object: