Search code examples
javaehcacheshiro

shiro + ehcache + replication: login and logout not being replicated


Our web application is using shiro for authentication. We're storing sessions in EHCache, backed by a filestore, and using replication to ensure that all web servers have all of the sessions. We are using peer to peer replication, not the multicast configuration. Things seem to work most of the time. However, from time to time, logins or logouts will not be replicated.

We will see stacktraces with the following exception: org.apache.shiro.session.UnknownSessionException: There is no session with id [dc996ea4-daff-431f-946b-6a5a214f9477]

If the file goes out of sync, it stays out of sync.

Does anyone have a suggestion as to why we might see this behavior?


Solution

  • Frankly, I'd try to get away from peer-to-peer replication altogether...as it has potential for race conditions and concurrent exceptions, which could explain your missing entries at random. I'd move towards a much more robust distributed caching solution using Bigmemory Max which is free for up to 4 clients + 4GB of memory storage (http://terracotta.org/products/bigmemorymax)

    EDIT - FYI, BigMemory Max is still ehcache...it's just a "distributed ehcache" with extra "off-heap" memory capability...