Skipping to the end of the story - the Eclipse Memory Analyzer is awesome!
We have a high profile and very politically entrenched application which is plagued by many issues outside the control of the IT department. Recently a consultant with much history with the application produced changes to support a mobile application. We were told that the changes were minimal - basically bolt-on pieces only. That did not turn out to be the case, the consultants idea of small bolt-on involved replacing some core Struts configuration affecting the original core application as well as the new code. Timing of this could not have been much worse since we ended up needing to upgrade to the Struts 2.5.15.3 library due to security issues at the same time. Anyways, the mobile bolt-on had not been well-tested and neither was the combined application code. This was determined a bit later when IT went back and did some testing of the mobile code related branch code.
Anyways, IT was forced to fix a number of issues before a Struts upgrade can occur while merging the mobile release and producing a build for deployment. Due to a lack of adequate functional user resources assigned to the application, testing is typically inadequate. The build was forced to go into production and then the problems began. The symptoms were basically high heap utilization, increasingly high CPU utilization followed by instability and finally out-of-memory (OOM) errors being logged after which the application is basically brain dead.
After a couple days of analysis, it was still unclear as to what the root cause was. There was never a clear repeating pattern. We ended up implementing multiple daily application restarts to help clear the memory but that was only mildly effective. There were some items which seemed odd while analyzing the application with jvisualvm but the problem was "lost in the trees". Some initial attempts at analyzing the heap dump produced when the OOM error occurred failed because of issues related to the size of the heap dump and a lack of functionality to help identify the root cause.
I had installed the Eclipse Memory Analyzer a while back with the intent of trying it out but never had the time to do so. At this point, it seemed like a good time to try. The first attempt was not successful though since I tried it on my "old" laptop which was running Windows 7 32bit. Fortunately, I had received another laptop a week or so prior with Win 7 x64 which I was in the midst of setting up. After increasing memory in Eclipse upto around 3200mb, I started the import of the heap dump from our prod system and after around 45 minutes it was done processing and offered up to show leak suspects. I gladly selected yes and found that it had one suspect which was taking up more than 300mb of memory. It provided a stack trace which led me to a some particular functionality. The interesting item found was that data in the stack/trace was indicative that the functionality was accessed by a non-logged in user. After some communication with the consultant, functional staff and another developer on the application indicated that the functionality should NOT be accessible to a non-logged in user - further investigation followed. This lead to identifying that a DB call was returning around over 400k rows of data instead of under of 100 rows and was retaining it. It turned out that the consultant had an "OR" condition which explicitly returned all data to a non-logged in user (even though the functionality shouldn't be available when not logged in..). After removing the extraneous OR and having the functional team test for any negative effects - the changes were put into production.
The result of the fix was the application was stable and using under 50% of the average memory in use when unstable and CPU utilization averages mostly in the single digits.
So roughly one hour of work with the Memory Analyzer helped solve a problem which was not anywhere near being solved after multiple days of effort.
Hats off the the people responsible for the Memory Analyzer - you have my gratitude!
Now if we can figure out what the consultant did which is causing a non-logged in behavior.
Software Development, family, religious, hobby, fun and humorous items.
Wednesday, November 13, 2013
Monday, October 7, 2013
Jenkins jobs and subversion access via certificate and batch related stuff
Jenkins is a very nice solution to a number needs outside of automated builds. Use as a general batch solution is feasible at smaller scales. This has further improved recently with the credentials plugin. This makes it pretty easy to setup jobs which use certificates to access subversion instead of requiring a specific persons credentials which require a much more regular change. Of course, this works best when an organization has the infrastructure to securely manage certificates.
[2014/05/20] Works! It seems easiest to setup 2 separate Apache Virtual servers though; one with Basic Auth and the other with Certificate auth.
Related to general batch processing, the Elastic Axis plugin is a great solution. This is a perfect fit for when you have load balanced servers implementing an application and you need to run a job on any one but only one of them. You can take an application node offline and Jenkins/Elastic Axis will happily pick an available node out of the remaining configured nodes.
My wish list for Jenkins includes a few enhancements which would improve some things to a large extent - this mainly revolves around new/improved support for high availability, multiple masters with fail-over and a clear/clean clustering solution. A database backed job store might be a big plus depending on how the previously mentioned features were implemented. I would love to be able to easily integrate Jenkins into our DR environment but as it stands it is a more manual integration.
[2014/05/20] Works! It seems easiest to setup 2 separate Apache Virtual servers though; one with Basic Auth and the other with Certificate auth.
Related to general batch processing, the Elastic Axis plugin is a great solution. This is a perfect fit for when you have load balanced servers implementing an application and you need to run a job on any one but only one of them. You can take an application node offline and Jenkins/Elastic Axis will happily pick an available node out of the remaining configured nodes.
My wish list for Jenkins includes a few enhancements which would improve some things to a large extent - this mainly revolves around new/improved support for high availability, multiple masters with fail-over and a clear/clean clustering solution. A database backed job store might be a big plus depending on how the previously mentioned features were implemented. I would love to be able to easily integrate Jenkins into our DR environment but as it stands it is a more manual integration.
Java security manager policy mechanism and non-trivial applications
We have a "pest" bothering us and to deal with the issue we decided to implement multiple security mechanisms. The mechanism I am currently working on revolves around the age old Java security manager policy. This really should be done at initial design/implementation if it is done at all. A multitude of open source libraries isn't making this easy. Not complaining mind you - just wishing that security was part of the initial requirements for all open source libraries. Unfortunately, there are some pretty popular libraries which are somewhat troublesome and securing them is a bit disconcerting. I can't comment on what libraries I am referencing out of security concerns and respect for my employer. I will say that this is making my recommendation for complete removal of the libraries much easier to justify.
The general process to getting the security manager working with an existing application is:
* start application server with security manager enabled
* access application while monitoring logs
* when a failure occurs; update the policy file based on data in the log, clear logs and start this process over again
The app server logging is pretty good; it almost always contains 'denied' in the message and many times the remainder of the content can be cut/pasted nearly as is into the policy file. There are times that debugging isn't easy; as when there are problems with components which start up early and/or eat exceptions instead of logging.
I would not bother trying to debug the security manager polices by setting
The general process to getting the security manager working with an existing application is:
* start application server with security manager enabled
* access application while monitoring logs
* when a failure occurs; update the policy file based on data in the log, clear logs and start this process over again
The app server logging is pretty good; it almost always contains 'denied' in the message and many times the remainder of the content can be cut/pasted nearly as is into the policy file. There are times that debugging isn't easy; as when there are problems with components which start up early and/or eat exceptions instead of logging.
I would not bother trying to debug the security manager polices by setting
-Djava.security.debug=allthat just generates way too much useless data. I think that
-Djava.security.debug=policy,accessis a better setting which gives a good amount of data to help in resolving failures and understanding what the application is accessing.
Subscribe to:
Posts (Atom)