zhangyue19921010 opened a new pull request #10555: URL: https://github.com/apache/druid/pull/10555
<!-- Thanks for trying to help us make Apache Druid be the best it can be! Please fill out as much of the following information as is possible (where relevant, and remove it when irrelevant) to help make the intention and scope of this PR clear in order to ease review. --> Fixes Druid throws java.util.concurrent.RejectedExecutionException when ingest task is stopping. <!-- Replace XXXX with the id of the issue fixed in this PR. Remove this section if there is no corresponding issue. Don't reference the issue in the title of this pull-request. --> <!-- If you are a committer, follow the PR action item checklist for committers: https://github.com/apache/druid/blob/master/dev/committer-instructions.md#pr-and-issue-action-item-checklist-for-committers. --> ### Description When ingest task is finished and doing clean up action, it may meet 'RejectedExecutionException' sometimes, like ``` 2020-11-03T11:33:42,279 INFO [task-runner-0-priority-0] org.apache.druid.curator.announcement.Announcer - Unannouncing [xxxx:8101] 2020-11-03T11:33:42,288 INFO [task-runner-0-priority-0] org.apache.druid.indexing.worker.executor.ExecutorLifecycle - Task completed with status: { "id" : "xxxx__prd_73054d04b8a9754_ccpenhpd", "status" : "SUCCESS", "duration" : 3780579, "errorMsg" : null, "location" : { "host" : null, "port" : -1, "tlsPort" : -1 } } 2020-11-03T11:33:42,291 INFO [main] org.apache.druid.java.util.common.lifecycle.Lifecycle - Stopping lifecycle [module] stage [ANNOUNCEMENTS] 2020-11-03T11:33:42,293 INFO [main] org.apache.druid.curator.announcement.Announcer - Unannouncing [xxxxx.local:8101] 2020-11-03T11:33:42,295 INFO [main] org.apache.druid.java.util.common.lifecycle.Lifecycle - Stopping lifecycle [module] stage [SERVER] 2020-11-03T11:33:42,299 INFO [main] org.eclipse.jetty.server.AbstractConnector - Stopped ServerConnector@4ef8090b{HTTP/1.1,[http/1.1]}{0.0.0.0:8101} 2020-11-03T11:33:42,299 INFO [main] org.eclipse.jetty.server.session - node0 Stopped scavenging 2020-11-03T11:33:42,301 INFO [main] org.eclipse.jetty.server.handler.ContextHandler - Stopped o.e.j.s.ServletContextHandler@1f1fbc9f{/,null,UNAVAILABLE} 2020-11-03T11:33:42,304 INFO [main] org.apache.druid.java.util.common.lifecycle.Lifecycle - Stopping lifecycle [module] stage [NORMAL] 2020-11-03T11:33:42,304 INFO [main] org.apache.druid.server.listener.announcer.ListenerResourceAnnouncer - Unannouncing start time on [xxxx.cluster.local:8101] 2020-11-03T11:33:42,304 INFO [main] org.apache.druid.indexing.overlord.SingleTaskBackgroundRunner - Starting graceful shutdown of task[xxxxx__prd_73054d04b8a9754_ccpenhpd]. 2020-11-03T11:33:42,304 INFO [main] org.apache.druid.indexing.seekablestream.SeekableStreamIndexTaskRunner - Stopping forcefully (status: [PUBLISHING]) 2020-11-03T11:33:42,307 INFO [main] org.apache.druid.security.basic.authorization.db.cache.CoordinatorPollingBasicAuthorizerCacheManager - CoordinatorPollingBasicAuthorizerCacheManager is stopping. 2020-11-03T11:33:42,307 INFO [main] org.apache.druid.security.basic.authorization.db.cache.CoordinatorPollingBasicAuthorizerCacheManager - CoordinatorPollingBasicAuthorizerCacheManager is stopped. 2020-11-03T11:33:42,307 INFO [main] org.apache.druid.security.basic.authentication.db.cache.CoordinatorPollingBasicAuthenticatorCacheManager - CoordinatorPollingBasicAuthenticatorCacheManager is stopping. 2020-11-03T11:33:42,307 INFO [main] org.apache.druid.security.basic.authentication.db.cache.CoordinatorPollingBasicAuthenticatorCacheManager - CoordinatorPollingBasicAuthenticatorCacheManager is stopped. 2020-11-03T11:33:42,307 INFO [LookupExtractorFactoryContainerProvider-MainThread] org.apache.druid.query.lookup.LookupReferencesManager - Lookup Management loop exited. Lookup notices are not handled anymore. 2020-11-03T11:33:42,307 INFO [main] org.apache.druid.query.lookup.LookupReferencesManager - Closed lookup [xxxx1]. 2020-11-03T11:33:42,307 INFO [main] org.apache.druid.query.lookup.LookupReferencesManager - Closed lookup [xxxx2]. 2020-11-03T11:33:42,307 INFO [main] org.apache.druid.query.lookup.LookupReferencesManager - Closed lookup [xxxx3]. 2020-11-03T11:33:42,307 INFO [main] org.apache.druid.query.lookup.LookupReferencesManager - Closed lookup [xxxx4]. 2020-11-03T11:33:42,319 INFO [main] org.apache.druid.java.util.emitter.core.ComposingEmitter - Closing Composing Emitter. 2020-11-03T11:33:42,319 INFO [main] org.apache.druid.java.util.emitter.core.ComposingEmitter - Closing emitter org.apache.druid.emitter.statsd.StatsDEmitter. 2020-11-03T11:33:42,364 ERROR [BasicAuthenticatorCacheManager-Exec--0] org.apache.druid.java.util.common.concurrent.ScheduledExecutors - Uncaught exception. java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask@2bbf15dd rejected from java.util.concurrent.ScheduledThreadPoolExecutor@2578eeda[Shutting down, pool size = 1, active threads = 1, queued tasks = 0, completed tasks = 59] at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2063) ~[?:1.8.0_221] at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:830) ~[?:1.8.0_221] at java.util.concurrent.ScheduledThreadPoolExecutor.delayedExecute(ScheduledThreadPoolExecutor.java:326) ~[?:1.8.0_221] at java.util.concurrent.ScheduledThreadPoolExecutor.schedule(ScheduledThreadPoolExecutor.java:533) ~[?:1.8.0_221] at java.util.concurrent.Executors$DelegatedScheduledExecutorService.schedule(Executors.java:729) ~[?:1.8.0_221] at org.apache.druid.java.util.common.concurrent.ScheduledExecutors$2.run(ScheduledExecutors.java:103) [druid-core-0.17.1.jar:0.17.1] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_221] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_221] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_221] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:1.8.0_221] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_221] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_221] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_221] ``` The root cause of this exception is that the function 'call' in 'scheduleWithFixedDelay' always return Signal.REPEAT all the time. It will constance submit jobs to exec , even though exec is shutdown. This PR checks exec status before return Signal. <!-- Describe the goal of this PR, what problem are you fixing. If there is a corresponding issue (referenced above), it's not necessary to repeat the description here, however, you may choose to keep one summary sentence. --> <!-- Describe your patch: what did you change in code? How did you fix the problem? --> <!-- If there are several relatively logically separate changes in this PR, create a mini-section for each of them. For example: --> #### Fixed the bug ... #### Renamed the class ... #### Added a forbidden-apis entry ... <!-- In each section, please describe design decisions made, including: - Choice of algorithms - Behavioral aspects. What configuration values are acceptable? How are corner cases and error conditions handled, such as when there are insufficient resources? - Class organization and design (how the logic is split between classes, inheritance, composition, design patterns) - Method organization and design (how the logic is split between methods, parameters and return types) - Naming (class, method, API, configuration, HTTP endpoint, names of emitted metrics) --> <!-- It's good to describe an alternative design (or mention an alternative name) for every design (or naming) decision point and compare the alternatives with the designs that you've implemented (or the names you've chosen) to highlight the advantages of the chosen designs and names. --> <!-- If there was a discussion of the design of the feature implemented in this PR elsewhere (e. g. a "Proposal" issue, any other issue, or a thread in the development mailing list), link to that discussion from this PR description and explain what have changed in your final design compared to your original proposal or the consensus version in the end of the discussion. If something hasn't changed since the original discussion, you can omit a detailed discussion of those aspects of the design here, perhaps apart from brief mentioning for the sake of readability of this PR description. --> <!-- Some of the aspects mentioned above may be omitted for simple and small changes. --> <hr> This PR has: - [ ] been self-reviewed. - [ ] using the [concurrency checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md) (Remove this item if the PR doesn't have any relation to concurrency.) - [ ] added documentation for new or modified features or behaviors. - [ ] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links. - [ ] added or updated version, license, or notice information in [licenses.yaml](https://github.com/apache/druid/blob/master/licenses.yaml) - [ ] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader. - [ ] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for [code coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md) is met. - [ ] added integration tests. - [ ] been tested in a test Druid cluster. <!-- Check the items by putting "x" in the brackets for the done things. Not all of these items apply to every PR. Remove the items which are not done or not relevant to the PR. None of the items from the checklist above are strictly necessary, but it would be very helpful if you at least self-review the PR. --> <hr> ##### Key changed/added classes in this PR * `ScheduledExecutors` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
