merrimanr opened a new pull request #1367: METRON-2022: Metron rest creates 
large number of connections to ZK which causes subsequent connection to zk fail
URL: https://github.com/apache/metron/pull/1367
 
 
   ## Contributor Comments
   I was able to track down the problem in the `SolrMetaAlertRetrieveLatestDao` 
class.  Every time the latest meta alert is retrieved in 
`SolrMetaAlertRetrieveLatestDao.getLatest`, a new `SolrClient` is being created 
and never closed.  This issue also happens when updating a meta alert because 
the latest version of the meta alert is retrieved first.
   
   To fix this, the `SolrClient` created in `SolrDao` is now shared with all 
child Dao classes.  Some slight refactoring was needed to achieve this and I 
tried to keep it as consistent with other `SolrDao` classes as possible.
   
   ### Testing
   1. Spin up full dev and create a meta alert:
   ```
   curl -X POST --header 'Content-Type: application/json' --header 'Accept: 
application/json' -d '{
     "alerts": [
       {
         "guid": "f130166c-ba0d-4ecd-8395-eaea8aa950fe",
         "sensorType": "bro"
       }
     ],
     "groups": [
       "string"
     ]
   }' 'http://user:password@node1:8082/api/v1/metaalert/create'
   ``` 
   2. Record the number of active zookeeper connections by first getting the 
REST PID:
   ```
   [root@node1 tmp]# ps -ef | grep metron-rest
   metron   18151     1  7 00:59 ?        00:01:36 
/usr/jdk64/jdk1.8.0_112/bin/java -Dhdp.version=2.6.5.0-292 -cp 
/etc/hadoop/conf/:/usr/hdp/current/hbase-client/conf:/usr/metron/0.7.1/lib/metron-rest-0.7.1.jar:/usr/metron/0.7.1/lib/metron-parsing-storm-0.7.1-uber.jar:/usr/metron/0.7.1/lib/metron-solr-0.7.1-uber.jar
 org.apache.metron.rest.MetronRestApplication 
--spring.config.location=/usr/metron/0.7.1/config/rest_application.yml,classpath:/application.yml
 --server.port=8082 --spring.profiles.active=dev 
--index.dao.impl=org.apache.metron.solr.dao.SolrDao,org.apache.metron.indexing.dao.HBaseDao
 --meta.dao.impl=org.apache.metron.solr.dao.SolrMetaAlertDao 
--index.writer.name=solr
   root     20411   566  0 01:21 pts/0    00:00:00 grep metron-rest
   ```
   Then print the number of connections for that PID:
   ```
   [root@node1 tmp]# netstat -nape | awk '{if ($5 == "::ffff:127.0.0.1:2181") 
print $9;}' | sort | uniq -c | grep 18151
         2 18151/java
   ```
   3. Update the created meta alert `alert_status` field  several times with 
different values:
   ```
   curl -X PATCH --header 'Content-Type: application/json' --header 'Accept: 
application/json' -d '{
     "guid": "f8da66bc-0d26-4f90-9d93-4689e70e9ce3",
     "index": "metaalert",
     "patch": [
      {"op":"add","path":"/alert_status","value":"DISMISSED"}
     ],
     "sensorType": "metaalert"
   }' 'http://user:password@node1:8082/api/v1/update/patch'
   ```
   4. Printing the number of zookeeper connections should continue to be 2.  
Before this the number of connections would continue to grow as updates are 
sent.
   
   ## Pull Request Checklist
   
   Thank you for submitting a contribution to Apache Metron.  
   Please refer to our [Development 
Guidelines](https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=61332235)
 for the complete guide to follow for contributions.  
   Please refer also to our [Build Verification 
Guidelines](https://cwiki.apache.org/confluence/display/METRON/Verifying+Builds?show-miniview)
 for complete smoke testing guides.  
   
   
   In order to streamline the review of the contribution we ask you follow 
these guidelines and ask you to double check the following:
   
   ### For all changes:
   - [x] Is there a JIRA ticket associated with this PR? If not one needs to be 
created at [Metron 
Jira](https://issues.apache.org/jira/browse/METRON/?selectedTab=com.atlassian.jira.jira-projects-plugin:summary-panel).
   - [x] Does your PR title start with METRON-XXXX where XXXX is the JIRA 
number you are trying to resolve? Pay particular attention to the hyphen "-" 
character.
   - [x] Has your PR been rebased against the latest commit within the target 
branch (typically master)?
   
   
   ### For code changes:
   - [ ] Have you included steps to reproduce the behavior or problem that is 
being changed or addressed?
   - [ ] Have you included steps or a guide to how the change may be verified 
and tested manually?
   - [ ] Have you ensured that the full suite of tests and checks have been 
executed in the root metron folder via:
     ```
     mvn -q clean integration-test install && 
dev-utilities/build-utils/verify_licenses.sh 
     ```
   
   - [x] Have you written or updated unit tests and or integration tests to 
verify your changes?
   - [x] If adding new dependencies to the code, are these dependencies 
licensed in a way that is compatible for inclusion under [ASF 
2.0](http://www.apache.org/legal/resolved.html#category-a)?
   - [x] Have you verified the basic functionality of the build by building and 
running locally with Vagrant full-dev environment or the equivalent?
   
   ### For documentation related changes:
   - [x] Have you ensured that format looks appropriate for the output in which 
it is rendered by building and verifying the site-book? If not then run the 
following commands and the verify changes via 
`site-book/target/site/index.html`:
   
     ```
     cd site-book
     mvn site
     ```
   
   #### Note:
   Please ensure that once the PR is submitted, you check travis-ci for build 
issues and submit an update to your PR as soon as possible.
   It is also recommended that [travis-ci](https://travis-ci.org) is set up for 
your personal repository such that your branches are built there before 
submitting a pull request.
   

----------------------------------------------------------------
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]


With regards,
Apache Git Services

Reply via email to