• Bug
  • Status: Closed
  • 2 Major
  • Resolution: Fixed
  • ehcache
  • hsingh
  • Reporter: foshea
  • April 30, 2010
  • 0
  • Watchers: 0
  • January 17, 2013
  • May 03, 2010

Description

Upon closing a cache, the WriteBehindManager(s) attached to the queue do not by default finish flushing the WriteBehindQueue before exiting.

I am using a ehcache in standalone version 2.0.1

Is there an existing API/options that allow this? If not any idea/suggestions on how this should be done?

Comments

Martin Rose 2010-05-03

I had a test case all coded up demonstrating, I don’t still have it around though.

It basically created a new write behind cache, that had a counter as it processed tasks.

A main thread started up a cache, through 10k entries at it, then called cache close.

In the dispose of the cache writer dispose it printed out the state of counter, and it was nowhere near 10k.

I’m pretty sure the problem is in

core/src/main/java/net/sf/ehcache/writer/writebehind/WriteBehindQueue.java

public void stop() {
    queueWriteLock.lock();
    try {
        cancelled = true;
        queueIsEmpty.signal();
    } finally {
        queueWriteLock.unlock();
    }
}

It calls the write lock to say it’s manipulating, they Queue, says that the write behind is now cancelled, and signals that the queue is empty without at least trying to flush out

private List<SingleOperation> waiting = new ArrayList<SingleOperation>();

Let me know if I can be of any further assistance.

Geert Bevin 2010-05-03

FYI, I’m about to commit a fix that will go into the next release. Just doing a final run-through of all the tests.

Himadri Singh 2010-05-12

CacheWriterTest covers the issue and its running on monkeys.