You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by "Jarek Gawor (JIRA)" <ji...@apache.org> on 2010/08/27 20:46:56 UTC

[jira] Commented: (OPENEJB-1345) improving stateful cache and the management of timedout stateful beans

    [ https://issues.apache.org/jira/browse/OPENEJB-1345?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12903526#action_12903526 ] 

Jarek Gawor commented on OPENEJB-1345:
--------------------------------------

Thiago,

I don't quite see how these changes make the cache work under multiple threads. Here are some problems I see:

1) The code uses HashSet for keeping track of in-memory instances and other things. But multiple threads can be adding and removing from these maps at the same time. That can lead to bad problems i.e. infinite loops.

2) CacheListener.timedout() is never called.

3) Multiple threads calling updateTimeout() at the same time can cause multiple RemoveBeanThread tasks to be scheduled (since future cancel and future schedule are not synchronized). That can cause a bean to be removed that should not be removed.

4) The timeoutQueue is sorted by expiration date of the bean... but it's really not. A bean entry is added to the queue when the bean is first added to the cached. The place of the entry in the queue depends on its expiration time. However, the expiration time of the bean changes as the bean is used. So in order for the bean entry to be in the right place in the queue the entry has to be removed and added back it each time a updateTimeout() is called. Or at least that's how I understand a PriorityQueue to be working. It doesn't automatically re-sort itself.

There might be other problems as well. This cache functionality is pretty hard to get it right so I would suggest creating a separate Cache implementation that could be used to replace the SimpleCache implementation. I think that's pretty much the reason why the Cache interface was created in the first place.


> improving stateful cache and the management of timedout stateful beans
> ----------------------------------------------------------------------
>
>                 Key: OPENEJB-1345
>                 URL: https://issues.apache.org/jira/browse/OPENEJB-1345
>             Project: OpenEJB
>          Issue Type: Improvement
>          Components: container system
>    Affects Versions: 3.2
>            Reporter: Thiago Veronezi
>             Fix For: 3.2
>
>         Attachments: OPENEJB-1345.patch, OPENEJB-1345.patch
>
>
> Use of a single scheduled thread to manage timedout beans.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.