Comments (8)
I've also dug a bit into the library code and it might have something to do with gax?
from google-cloud-java.
Probably not the core of the problem, but the code example is not using try-with-resources: try (ImagesClient imagesClient = ImagesClient.create(ImagesSettings.newBuilder().build())) {
.
from google-cloud-java.
I'm able to reproduce this. The regression was introduced in google-cloud-compute:1.27.0 in May, corresponding to libraries-bom:26.15.0.
@lqiu96 I confirmed that this is the PR that caused the regression: googleapis/sdk-platform-java#1603
from google-cloud-java.
Hi @Martiul, thank you for reporting this. I followed the steps that you listed above and was able to reproduce this locally. With or without the client initialized in try-with resources, the client isn't able to fully close properly and the program isn't able to terminate. Thanks @meltsufin for pointing to my previous PR, I reverted gax-httpjson back to the version before the PR (v0.111.0) and was able to confirm that the program was able to terminate properly.
My repro pom.xml
that reverts a previously working version
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-compute</artifactId>
<version>1.43.0</version>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax-httpjson</artifactId>
<version>0.111.0</version>
</dependency>
Output:
Exception in thread "main" java.lang.NoSuchMethodError: 'com.google.api.gax.httpjson.HttpJsonCallSettings$Builder com.google.api.gax.httpjson.HttpJsonCallSettings$Builder.setParamsExtractor(com.google.api.gax.rpc.RequestParamsExtractor)'
at com.google.cloud.compute.v1.stub.HttpJsonGlobalOperationsStub.<init>(HttpJsonGlobalOperationsStub.java:368)
at com.google.cloud.compute.v1.stub.HttpJsonGlobalOperationsStub.create(HttpJsonGlobalOperationsStub.java:337)
at com.google.cloud.compute.v1.stub.HttpJsonImagesStub.<init>(HttpJsonImagesStub.java:629)
at com.google.cloud.compute.v1.stub.HttpJsonImagesStub.<init>(HttpJsonImagesStub.java:614)
at com.google.cloud.compute.v1.stub.HttpJsonImagesStub.create(HttpJsonImagesStub.java:594)
at com.google.cloud.compute.v1.stub.ImagesStubSettings.createStub(ImagesStubSettings.java:277)
at com.google.cloud.compute.v1.ImagesClient.<init>(ImagesClient.java:343)
at com.google.cloud.compute.v1.ImagesClient.create(ImagesClient.java:326)
at com.google.cloud.compute.v1.ImagesClient.create(ImagesClient.java:318)
at org.example.Main.main(Main.java:21)
Process finished with exit code 1 <--- I see the exit code for termination
It's a different error regarding dynamic routing headers, but I believe it shows that the program was able to terminate properly.
I checked the RPC's settings and saw that it was configured with a default timeout value of 10 minutes (as defined in the RetrySettings here and then configured here). I believe this value determines when the program would actually terminate and the spring shell timeout is probably just a coincidence that matches.
My previous PR introduced the concept of terminating the call if the call's duration has exceed the total timeout configured for the RPC. This is done via a "deadline schedule executor" which just schedules a timeout task once the configured timeout elapsed. The deadline scheduler's timeout tasks is scheduled for current_time() + rpc_timeout()
, which for this RPC is 10m from when the RPC was invoked.
I believe the issue is with the deadlineScheduler's shutdown()
call. The javadocs for shutdown()
suggests if the task has been added to the scheduler, the task will continue until it's completed. I think the intended behavior is that once we've received a result (either error or response) prior to the timeout, the timeout task should be cancelled and the client should return the response back to the user.
I ran a test locally which cancels the timeout task once a response has been received and was able to see the client terminate properly:
...
}
],
"status": "PERMISSION_DENIED",
"details": [
{
"@type": "type.googleapis.com/google.rpc.Help",
"links": [
{
"description": "Google developers console API activation",
"url": "https://console.developers.google.com/apis/api/compute.googleapis.com/overview?project=foo"
}
]
},
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "SERVICE_DISABLED",
"domain": "googleapis.com",
"metadatas": {
"service": "compute.googleapis.com",
"consumer": "projects/foo"
}
}
]
}
}
at com.google.api.client.http.HttpResponseException$Builder.build(HttpResponseException.java:293)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1118)
at com.google.api.gax.httpjson.HttpRequestRunnable.run(HttpRequestRunnable.java:115)
... 6 more
Process finished with exit code 1 <--- Expected to see this to show that the JVM has exited
I believe the output above should be the intended result. I think there should be a simple fix for this, but I'll do some more investigating to confirm.
from google-cloud-java.
Probably not the core of the problem, but the code example is not using try-with-resources:
try (ImagesClient imagesClient = ImagesClient.create(ImagesSettings.newBuilder().build())) {
.
yes. I split the example into try-catch-finally so it's easier to debug imagesClient.isTerminated()
from google-cloud-java.
thanks @lqiu96 for the deepdive on the scheduler, i was also under the impression that there was some unfinished job somewhere. Looking forward to the fix
from google-cloud-java.
I added a draft POC of a possible fix: googleapis/sdk-platform-java#2360. I'm taking a look into grpc-java (httpjson is mostly a mirror/ inspired from there) and other possible implementations.
CC: @blakeli0
from google-cloud-java.
@Martiul @meltsufin @suztomo, I added priority:p2
to this bug, let me know if you feel differently.
from google-cloud-java.
Related Issues (20)
- The header-check is failing in 2024 HOT 3
- New client library generation creates a commit without proper author email
- CHANGELOG.md is not generated for java-vertexai module HOT 1
- emoji error HOT 2
- Warning: a recent release failed
- Authentication error when using a regional endpoint HOT 12
- Remove `codecov.yaml` and `synth.metadata` in java modules
- [attachDiskAsync]: Attach disk does not work unless "iam.serviceAccounts.actAs" permission is set HOT 13
- The CI status link in README.md is broken
- Nightly IT Failure (java-talent): Tenant Already Exists error. HOT 1
- Nightly IT Failure (graalvm-nightly-17): Terraform cleanup error
- IT Nightly (graalvm): Missing jar-file for com.google.api.grpc:grpc-google-cloud-gkehub-v1alpha2 HOT 1
- IT failure: ITPaginationTest.testPaginationNextToken
- Generate signed URLs when using workload identity in Java HOT 3
- IT failure: aiplatform/v1/JobServiceGrpc incompatible types
- [language]: exception while trying to create LanguageServiceClient instance HOT 2
- Use a single unique java library to call the vertex AI API HOT 1
- [Dialogflow] Flaky test - ITSystemTest.detectIntentTest, ITSystemTest:listContextsTest HOT 1
- `com.google.cloud.aiplatform.v1beta1.PredictionServiceClient#countTokens` promotion from v1beta1 to v1 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from google-cloud-java.