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
Too many thread pools created #842
Comments
Thanks for the report. Try not to use
It will be fixed next release. |
wow, maybe i have found the problem, thanks for you reply anyway. |
i have changed two places to solve the problem. the first one is in JdbcImporter: private void execute() throws ExecutionException, InterruptedException {
logger.debug("executing (queue={})", getQueue().size());
if (executor != null) {
try {
executor.shutdown();
logger.info("shutdown executor:{}", executor);
} catch (Exception e) {
e.printStackTrace();
logger.error("error shutdown executor:{}", executor);
}
}
executor = new MetricSimplePipelineExecutor<SettingsPipelineRequest, Pipeline<SettingsPipelineRequest>>()
.setQueue(getQueue())
.setConcurrency(settings.getAsInt("concurrency", 1))
.setPipelineProvider(pipelineProvider())
.prepare()
.execute()
.waitFor();
logger.debug("execution completed");
} i have added the the second one is in private Ingest createIngest(Settings settings) {
Settings.Builder settingsBuilder = Settings.settingsBuilder()
.put("cluster.name", settings.get("elasticsearch.cluster.name", settings.get("elasticsearch.cluster", "elasticsearch")))
.putArray("host", settings.getAsArray("elasticsearch.host"))
.put("port", settings.getAsInt("elasticsearch.port", 9300))
.put("sniff", settings.getAsBoolean("elasticsearch.sniff", false))
.put("autodiscover", settings.getAsBoolean("elasticsearch.autodiscover", false))
.put("name", "importer") // prevents lookup of names.txt, we don't have it
.put("client.transport.ignore_cluster_name", false) // ignore cluster name setting
.put("client.transport.ping_timeout", settings.getAsTime("elasticsearch.timeout", TimeValue.timeValueSeconds(5))) // ping timeout
.put("client.transport.nodes_sampler_interval", settings.getAsTime("elasticsearch.timeout", TimeValue.timeValueSeconds(5))); // for sniff sampling
// optional found.no transport plugin
if (settings.get("transport.type") != null) {
settingsBuilder.put("transport.type", settings.get("transport.type"));
}
// copy found.no transport settings
Settings foundTransportSettings = settings.getAsSettings("transport.found");
if (foundTransportSettings != null) {
Map<String, String> foundTransportSettingsMap = foundTransportSettings.getAsMap();
for (Map.Entry<String, String> entry : foundTransportSettingsMap.entrySet()) {
settingsBuilder.put("transport.found." + entry.getKey(), entry.getValue());
}
}
//设置GcMonitor可以通过参数控制,默认不开启
settingsBuilder.put("monitor.gc.enabled", settings.getAsBoolean("monitor.gc.enabled", false));
return ClientBuilder.builder()
.put(settingsBuilder.build())
.put(ClientBuilder.MAX_ACTIONS_PER_REQUEST, settings.getAsInt("max_bulk_actions", 10000))
.put(ClientBuilder.MAX_CONCURRENT_REQUESTS, settings.getAsInt("max_concurrent_bulk_requests",
Runtime.getRuntime().availableProcessors() * 2))
.put(ClientBuilder.MAX_VOLUME_PER_REQUEST, settings.getAsBytesSize("max_bulk_volume", ByteSizeValue.parseBytesSizeValue("10m", "")))
.put(ClientBuilder.FLUSH_INTERVAL, settings.getAsTime("flush_interval", TimeValue.timeValueSeconds(5)))
.setMetric(sinkMetric)
.toBulkTransportClient();
} i haved added this line: settingsBuilder.put("monitor.gc.enabled", settings.getAsBoolean("monitor.gc.enabled", false)); this lines allow me to control whether or not to switch on the 'GcMonitor', the Monitor will be scheduled each time the so my problem : too many threadpools are created but no one is destroy,
the second solution is not a good practice because i think it is a bug which need to be fixed |
and my config file: "schedule" : "0 0/1 * * * ? *", |
@medusar 这个问题在你修改了代码之后解决了没? |
@backingwu 解决了,就是按照我上面的方法 |
when the next release is going to be ready ? |
Fixed in 2.3.3.1 release. |
this problem happens in method SimplePipelineExecutor.prepare, property executorService is null, it will be create a fixedThreadPool every times. and it seems not fixed in 2.3.4.0 release
add setExecutorService method in MetricSimplePipelineExecutor and SimplePipelineExecutor, |
@liangcz thanks |
Let me close this.. |
Hi, recently, i have met a problem, when i use the JdbcImporter for a while , too many threads are created(about 2000 in 10 hours), and no thread is destroyed, after analyzed by jstack, i find that the threads are all named like 'pool-{threadpool-num}-thread-1', and when i check the code, i think problems are here in JdbcImportor:
each time the
execute
method is invoked, a new ThreadPool is created, and the pool will never be destroyed, as time goes by, too many thread pools are created, and because the concurrency is 1, there are also too many threads!The text was updated successfully, but these errors were encountered: