-
Notifications
You must be signed in to change notification settings - Fork 322
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
RejectedExecutionException during Graceful Shutdown when publishing with PubSubPublisherTemplate #2721
Comments
I suppose that any publishers that have been created need to be shutdown first. Are you using |
Through PubSubTemplate. |
|
Thanks a lot for the reply. Please see the attached zip in my first message - it contains small project with steps to reproduce. |
Sorry, I missed that! Thank you for providing the sample project. |
Thanks for the tip - tried it, but it did not help. |
…er ThreadPoolTaskScheduler (GoogleCloudPlatform#2721)
As of spring-6.1.x release, @Bean(name = "pubsubPublisherThreadPool")
public ThreadPoolTaskScheduler pubsubPublisherThreadPool(
GcpPubSubProperties properties) {
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.setPoolSize(properties.getPublisher().getExecutorThreads());
scheduler.setThreadNamePrefix("gcp-pubsub-publisher");
scheduler.setDaemon(true);
scheduler.setAcceptTasksAfterContextClose(true);
return scheduler;
} Proposed a PR(#2738) to supply late shutdown config options, such as:
|
Thanks for the suggestion and the PR @jayakumarc! |
@meltsufin / @jayakumarc , thanks for comment and code example. I can confirm, that the code above resolves the issue - in my small example application and in my production project. In my production project, before the fix, I had ~ 4000 errors during deploy and, after the fix, none of them appear. Thanks again for suggestion and the fix. |
Thanks for confirming @ernestaskardzys. Re-opening to track a permanent fix. |
@meltsufin So we are also getting the same issue with the pub-sub template:
I tried upgrading to springCloudGcpVersion 5.1.0 or 5.2.0 and adding the property
Any help would be much appreciated. |
@andrewpolemeni Can you please file this as a separate issue? If you can, also provide a sample that reproduces the issue. Thanks! |
Describe the bug
I use the following versions:
I have a Kotlin application, that accepts POST requests from clients and sends these requests to GCP Pub/Sub topic. Application works well during graceful shutdown, when there is low load. However, when there is high load and application is being gracefully shutdown, I get lots of errors:
It appears that
ThreadPoolTaskScheduler
fromGcpPubSubAutoConfiguration
has been already shut down, therefore in-flight requests can't be completed, resulting in errors.Could someone please advice on what to do in the above case?
Workaround (?)
As a workaround, it appears that code snippet, suggested on spring-attic/spring-cloud-gcp#1503 helps.
Sample
I have created a sample project (please see attached ZIP file) with instructions on how to start it and how to reproduce the issue in the
README.md
file.thread-error.zip
The text was updated successfully, but these errors were encountered: