Skip to main content

Posts

tomcat dbcp abandoned connections

We recently switched from commons dbcp to tomcat dbcp and after 2-3 weeks another architect ran into an issue where his backend job would run into a resultset close issue.  He was saying it started right about the time we made the switch and it happens only for long running jobs.  That reminds me of something I had read about abandoned connections so I asked him to check after how many minutes it does this and it was 20min 1 sec. It seems I had added a property in dbcp         dataSource.setLogAbandoned(true);         dataSource.setRemoveAbandoned(true);         dataSource.setRemoveAbandonedTimeout(1200); so first thing was to confirm if this was really the case because our transaction timeout for long running queries is also 20 min but that has been for ages so this abandoned was the only recent change. Finally I found logAbandoned would log into tomcat catalina.out ...

Band-Aid programming

I saw a code sample last Saturday for someone where there was a method with 9 TODOs and I saw some code that was doing                 xxxDao.setLastSectionNum(custId, lastSectionNum);                 xxxDao.setLastChangeNum(custId, lastChangeNum);                 xxxDao.setLastModified(custId, now, xxxContext);                 if (subject == null) {                         xxxDao.updateSubject(custId, subject);                 } My blood was boiling after seeing this. This is what is called as band ai...

Copy as cURL -- a great idea

Sometimes small actions are very powerful. I was recently using firebug and ran into a menu item called as copy as cURL. for e.g. when invoked on a  DuckDuckGo search on "Fox4 weather" gives curl 'https://duckduckgo.com/?q=fox4+weather&t=canonical' -H 'Host: duckduckgo.com' -H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:29.0) Gecko/20100101 Firefox/29.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' -H 'Accept-Language: en-US,en;q=0.5' -H 'Accept-Encoding: gzip, deflate' -H 'DNT: 1' -H 'Referer: https://duckduckgo.com/?q=fox4+wether&t=canonical' -H 'Connection: keep-alive' Great idea Firebug team and I am hoping this small action will save me a lot of time in future.

iphone5 charger cable worse quality I have seen

The lightning cable broke within a month. I was on trip to Houston and in the car it will start charging and then die. Then I went to hotel and put it on wall plug and it wont charge. I had a suspicion that putting it in car confused the phone but restart wont help. I remember 2-3 days back it would charge and 90% and then say accessory not supported. I thought its some bug in new update. So I went to walmart in Houston at 9:00 in night on a trip to NASA and then got a cable, while I was checking out I found one more customer came asking for iphone lightning charger cable, I was now sure its a cable issue.  So I bought the cable went to hotel and this also wont charge, I went again and got another cable and that one worked.  What a bummer I thought the phone went bad. Three days after I came back home I called AT&T to send me a replacement cable and they sent me their own proprietary cable which means even they know that the OEM cable by Apple sucks and they charge $30...

New relic aha moments with Java app

I am integrating New Relic at our startup and in last 2 weeks there were several Aha moments.  Below are some of the Aha moments 1) Our DBAs had done some profiling an year ago and told me that there is this "Select 1 from dual" query that is taking most of the time in database.  I was like this is the query that we do for validating connection out of commons-dbcp pool so I cant take it out and why would select 1 from dual take time in database.  But then I installed new relic on 16 app servers in a data centre and then I went to Database tab and immediately I see this query being fired 40-50K times. This was an Aha moment and immediately I started looking for alternatives. Finally I settled on tomcat-dbcp because it has a property called as validationInterval(default is 30 sec). So what it means is it would still fire select 1 from dual but will fire it on the connection only if it hasnt fired it in last 30 sec. This weekend the fix is going live so crossin...

Programming Epiphany

I hate doing tasks that are repetitive or that someone else should do but its a waste of my time. Earlier we used to store user and customer data on LDAP and there were all sort of BS requests from marketing like tell me "all customers that are on PlanY and are buy domain with >5 users".  Problem is there were 40 ldaps and each one of these would require writing a custom script. Teaching other programmers ldap was not reasonable.  One of my goals at my employer is to "Empower people to retrieve information themselves". I don’t want to be bottleneck in their chain of thoughts and they need not be bottleneck in what I want to do. I don’t want to involve humans if at all possible. So when we migrated to Ldap->Mysql, first thing I did was consolidated 40 ldaps per data centre to 4 Mysql server per datacentre.  I could have consolidated to 1 also but that would suffer from noisy neighbour issue.  Problem is that there are 3 Data centres so in total 12 mysql serve...

Jenkins Execute shell FAILURE

I was trying to run a jenkins Execute shell step with a grep to grep exceptions out of tomcat logs something like echo "grepping logs for exceptions" grep Exception purato.log*|grep -v WARN|grep -v DEBUG>error_summary.txt problem was that if the log files had no exceptions then this step would fail and mark the job as failed. Now I wanted to mark the job as successful even though the grep didnt yeild any output. I tried various solutions from putting "exit 0" as last command but problem was jenkins would fail immediately first shell step it found failure. Problem was jenkins starts shell with command [workspace] $ /bin/sh -xe /tmp/hudson6722324600236337826.sh   from man pages  """ -e errexit If not interactive, exit immediately if any untested command fails.  The exit status of a command is considered to be explicitly tested  if the command is used to control an if, elif, while, or until; or if th...