GoogleCloudPlatform / appengine-java-standard

Google App Engine Standard Java runtime: Prod runtime, local devappserver, Cloud SDK Java components, GAE APIs, and GAE API emulators.
Apache License 2.0
199 stars 45 forks source link

Fixes to completion of RequestManager in HttpMode #278

Open lachlan-roberts opened 5 days ago

lachlan-roberts commented 5 days ago

For the HttpConnector mode we now do not call RequestManager#finishRequest until we get HttpStream completion in Jetty12, or HttpChannel completion in Jetty-9.4.

lachlan-roberts commented 4 days ago

@gregw @ludoch the error still occurs after these changes, and I can see that for Jetty94, the datastore.put() for DatastoreSessionStore is always called before the requestManager.finishRequest() even in case of the error. And these are also called by the same thread.

So I do not know why we get the error "the API call to datastore_v3.Put() was explicitly cancelled". Because we are not out of the scope of the request because we have not called RequestManager.finishRequest() yet.

ludoch commented 4 days ago

Thanks Lachlan for the deep investigation. Its indicates that where the issue is: in the backend C++ api server and request manager, which has a potential of race condition between the end of the request and the 'release' of the API ticket necessary to do the last datastore put to store the session... I am inclined on trying to fix this race condition on the appserver side, not Java side. In fact, searching this ApiProxy$CancelledException error in our internal bug system shows that it happened a little bit in the past, and then stopped showing up so no actions were taken...

ludoch commented 4 days ago

Filed https://github.com/GoogleCloudPlatform/appengine-java-standard/issues/279

ludoch commented 1 day ago

Working on the server side fix in C++