Custom Search



Finally, I’m going somewhere now in debugging and tuning my assigned application. :D

While looking into the codes, I noticed this java thread which acts as a session manager that kicks in every 10 minutes to flush expired user sessions. During startup this session should load all user sessions stored in the database onto the memory cache. This should only be done once which as I’ve said is during startup, and then subsequent runs would just check the memory cache for expired session deletion. But somehow on every run, the database session retrieval isn’t bypassed. By checking the codes, I found something like this:

dbReloadSessionsDone = false;

If (dbReloadSessionsDone == false) {
//should only be called upon startup
reloadSessionsFromDB();
}


So there’s the culprit! The boolean variable dbReloadSessionsDone was initially declared with a false value but there’s no method or call within the class or subclasses that changes the value to true. This resulted to the reloadSessionsFromDB() method being called after the session manager thread is done sleeping since dbReloadSessionsDone is always false. The solution to this is simple:

If (dbReloadSessionsDone == false) {
//should only be called upon startup
reloadSessionsFromDB();
dbReloadSessionsDone == true;
}

By changingthe value of dbReloadSessionsDone to true after the first call, the reloadSessionsFromDB() method wouldn’t be called anymore on session manager thread subsequent runs.

Well, the fix was simple, but the peformance impact was quite significant considering the amount of data that needs to be directly retrieved from the DB on each call. ;)

Popularity: 3% [?]

Leave a Reply

Get Adobe Flash playerPlugin by wpburn.com wordpress themes