-
Notifications
You must be signed in to change notification settings - Fork 960
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
Unclosed gRPC Channels in VertexAiTextEmbeddingModel: Channel Orphan Warnings #2059
Comments
`import java.io.IOException; import org.springframework.ai.embedding.EmbeddingRequest; import com.google.cloud.aiplatform.v1.EndpointName; @slf4j
}` After writing this, the warnings have disappeared. |
wow, thanks for the deep investigate. Getting back to triage after a break. Would you be able to create a PR to address this please? |
@markpollack Yea sure no problem |
@markpollack I am getting permission denied when trying to push my changes. Do you have any idea of how to get around this? Change:Modified call(...) with Try-With-Resources When the block finishes, the gRPC channel is cleanly shut down. |
Thanks for your work here, @RyanHowell30 ! I walked into this issue today, and am glad you already identified it. I hope you don't mind if I lift your implementation in the meantime. There's just no easy way (with the private/package methods, the lambda call) to make just that change. 🙏 |
@charlie-ang-collibra go for it man. Let me know if you need anymore assistance. Just put the prediction service client in a try-with-resources. Then everywhere you call |
When using the Spring AI VertexAiTextEmbeddingModel class to create text embeddings, I see repeated warnings like the following in my logs:
Previous channel ManagedChannelImpl{...} was garbage collected without being shut down! Make sure to call shutdown()/shutdownNow()
These warnings indicate that a gRPC ManagedChannel created by the underlying Google Cloud client (PredictionServiceClient) is being garbage-collected without a proper call to close() or shutdown().
Inside VertexAiTextEmbeddingModel, the call(EmbeddingRequest request) method creates a new PredictionServiceClient instance on each call, but it never closes it. As a result, every ephemeral client spawns a gRPC channel that never gets shut down. Eventually, the channel is garbage-collected, triggering the “orphan channel” warnings in logs.
Other classes in Spring AI—such as VertexAiMultimodalEmbeddingModel—use a try-finally or a try-with-resources approach to ensure that each ephemeral PredictionServiceClient is closed after use, so they do not exhibit the same problem.
### This causes:
Logs are flooded with warnings about unclosed channels.
Possible resource leaks, as each PredictionServiceClient holds onto gRPC channels.
Performance overhead and potential memory usage issues from many channels staying alive longer than needed.
### Steps to Reproduce
Configure VertexAiTextEmbeddingModel as a Spring bean (for example, in a @configuration class).
Inject and repeatedly call the textEmbeddingModel.embed(...) or textEmbeddingModel.call(...) method on multiple requests.
Monitor application logs. Over time, you will see repeated warnings about an orphaned ManagedChannel or “Previous channel ... was garbage collected without being shut down!”
Technologies:
Spring AI version: 1.0.0-M5
Google Cloud AI libraries version: google-cloud-aiplatform: 3.40.0, gax-grpc: 2.46.1
Java version: 21
Running on local environment
The text was updated successfully, but these errors were encountered: