Sorry for taking so long to respond to this email.  More inline...

On Wed, Dec 17, 2008 at 5:46 AM, Emmanuel Lecharny <> wrote:

this is the last step to handle the paged search request : cleaning the remaining paged search when they are not used.

The problem is that a client can launch a paged search, get some few pages, and then stop requesting the remaining pages, without closing the request. Obviously, this is bad, bad, bad, but we won't be able to spank all the clients ;)

The created paged search context will then remain until the session is closed, keeping all the associated data (cursors, and such) in memory. Plus the client may launch more than one paged search request, leading to a quick OOM...

There are a few strategy we can implement to avoid such a problem :
1) first, we can limit the number of paged search request per session. I guess that a session with more than  5 or 10 opened paged search is very unlikely to occur. I suggest that we limit the number of opened paged searches to 5 atm (of course, this should be configurable), and unlimited for the administartor. When we reach this number, then the oldest paged search will be removed from the session.

I like this idea very much.  It's perhaps the best way to limit run away resource consumption.

2) we can also manage a timeout for the paged search. That mean a thread will be in charge of removing all the time-outed paged search across the sessions.

I hate doing things like this because of synchronization issues but if we have to we must.

3) We can also wait until the session dies, and cleanup the associated paged search.

I think we should do this always: meaning cleaning up all resources associated with a session including all the open cursors it has. 

In any case, we must do something, as the cursors _have_ to be closed.

Does those 3 proposals make sense to you? Did I forgot something? Do you see a better strategy ?

I think 1 & 3 should be done.  2 is an option but it's something I would do as a last resort if 1 & 3 do not seem adequate.