[jira] [Created] (FLINK-11235) fix thread lack when elasticsearch transport client init failed

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Created] (FLINK-11235) fix thread lack when elasticsearch transport client init failed

Shang Yuanchun (Jira)
lamber-ken created FLINK-11235:
----------------------------------

             Summary: fix thread lack when elasticsearch transport client init failed
                 Key: FLINK-11235
                 URL: https://issues.apache.org/jira/browse/FLINK-11235
             Project: Flink
          Issue Type: Bug
          Components: ElasticSearch Connector
    Affects Versions: 1.7.1
            Reporter: lamber-ken
            Assignee: lamber-ken
             Fix For: 1.7.2
         Attachments: image-2018-12-31-22-31-19-081.png, image-2018-12-31-22-31-53-635.png

h2. *elasticsearch transport sink init steps*

1, create client thread

2, try to check every host:port

3, if each host:port is unreachable, while throw RuntimeException

but, because of throw RuntimeException{color:#FF0000}, the client can not close{color}, so causing thread leak
h2. *transport client code*

```

TransportClient transportClient = {color:#000080}new {color}PreBuiltTransportClient(settings);
{color:#000080}for {color}(TransportAddress transport : ElasticsearchUtils.convertInetSocketAddresses({color:#660e7a}transportAddresses{color})) {
 transportClient.addTransportAddress(transport);
}

{color:#808080}// verify that we actually are connected to a cluster
{color}{color:#000080}if {color}(transportClient.connectedNodes().isEmpty()) {
 {color:#000080}throw new {color}RuntimeException({color:#008000}"Elasticsearch client is not connected to any Elasticsearch nodes!"{color});
}

{color:#000080}return {color}transportClient;
}

```
h2. *thread leak*

*!image-2018-12-31-22-31-19-081.png!*
h2. *thread dump*

!image-2018-12-31-22-31-53-635.png!

 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)