Annyce Davis

Davis Technology Consulting

  • Home
  • About Me
  • Blog
  • Courses
  • Newsletter

Killing Long Running Processes in MySQL

October 18, 2010 by Annyce Davis

This should never happen, but it does and so I’m going to tell you one way that I kill stale processes on my MySQL database server:

cat longprocesses.txt | awk ‘{print “kill “$1″;”}’

I run the show full processlist command on MySQL and then copy the list of stale processes to a file that I have named longprocesses.txt. Once that is done I have several lines of code that look like this:

kill 12345;
kill 93479;
….

I then copy this into MySQL or SequelPro and run the kill commands. This is somewhat tedious so I’m looking for a faster way to do this, any ideas, just post a comment. Thanks.

3 Tips to Help Avoid the Hibernate Flush

August 7, 2010 by Annyce Davis

When using Grails, the default behavior of Hibernate is to do a flush before queries, at the end of requests, and pretty much whenever Hibernate feels like it. So here are three tips that can help you avoid some of the flushing and/or at the very least decrease the number of database connections that Hibernate attempts to get:

  1. Use read() function when possible: If you are only going to read some field of a domain object and will make no changes to it, then just use object.read(), instead of the get() method
  2. Make sure your services are only transactional if they need to be, so if you are not updating, saving, or deleting records in the db chances are you do not need your Service to be transactional
  3. If you do have some transactional logic, put it inside a domain.withTransaction {} closure instead of making the entire function or class transactional

Configuration of DataSource.groovy for Highly Concurrent Grails Application

August 7, 2010 by Annyce Davis

In developing a highly concurrent Grails Application, I ran into an issue where many connections were being created to the database and were subsequently not released. After reading several blog posts it seems that the library used to handle the connection pooling was not designed for highly concurrent systems. I found that using the following setup in your DataSource.groovy file eliminates the stale connection issue and allows a high level of concurrency.

dataSource {
pooled = true
driverClassName = “com.mysql.jdbc.Driver”
dialect = “org.hibernate.dialect.MySQL5InnoDBDialect”
properties {
maxActive = 50
maxIdle = 10
initialSize = 10
minEvictableIdleTimeMillis = 10000
timeBetweenEvictionRunsMillis = 20000
maxWait = 10000
validationQuery = “/* ping */”
testWhileIdle = true
numTestsPerEvictionRun = 3
testOnBorrow = true
}
}

Hope this can help someone else.

Monitor Hibernate Cache Statistics in Grails Application v2

May 24, 2010 by Annyce Davis

In an earlier post I wrote about monitoring your cache hits in a Grails Application using a programmatic approach, this time I will show you how to use jconsole and have it done for you automatically.

All you need to do is start your Grails Application: grails run-app. Then start jconsole and choose your running Grails’ process. Go over to the MBeans tab and navigate to the area of your application server where you can see the cache.

What I really love about this is that you can perform actions in your application and watch the cache hits over time.

« Previous Page
Next Page »

Follow Me

  • Bluesky

Categories

  • Android (61)
  • Career (5)
  • Communication (4)
  • Flutter (1)
  • Git (4)
  • Gradle (4)
  • Grails (23)
  • iOS (1)
  • Java (8)
  • JavaScript (6)
  • Kotlin (17)
  • Life (5)
  • Public Speaking (26)
  • Revenue (2)
  • RxJava (1)
  • Software Development (14)
  • Twitter (3)
  • Uncategorized (11)
  • Video Course (5)

Follow Me

  • Bluesky

Copyright © 2025 · All Rights Reserved · Log in