This project has moved and is read-only. For the latest updates, please go here.

EsentOutOfSessionsException - limit of sessions

Aug 7, 2013 at 9:37 AM
Hi,
First of all: Thank you for this library - it works really great.
But I have a small problem I don't know how to deal with: We'd like to use the PersistentDictionary to queue data that can be transfered to Db async. This gives us the advantage of not depending that much on network problems and gives us a higher throughput - and it works extremely fast and reliable.
In the past week we ran some endurance and load tests - not just on this library but on the whole application(s) - and sometimes we got an EsentOutOfSessionsException.

Do you know of any way or have any info / links / ... to determine how many sessions can be created, per application or per host so we can implement "locking" or limits before we run into the exception?

Thanks in advance, klausi
Aug 7, 2013 at 10:26 AM
PersistentDictionary.cs has:
        this.instance.Parameters.MaxSessions = 256;
        this.instance.Parameters.MaxOpenTables = 256;
These numbers can easily be increased and recompiled.

However the question to answer is whether 256 is truly too small, or if there's a leak. There is very little downside in setting these numbers large if you never use them, but the point of artificially keeping the limits smaller is to make subtle leaks easier to find. Because leaks WILL be very painful eventually.

Most of the access functions close their Cursor after using them. Is it possible that you have many valid access functions at any point?
I also see that a new Cursor is opened during an Enumerator operation, for the life of that Enumerator. Do you have any long-lived foreach loops?

If the usage is legitimate, then increase these numbers.

-martin
Marked as answer by linky on 8/10/2015 at 3:19 AM
Aug 7, 2013 at 12:13 PM
Edited Aug 7, 2013 at 12:15 PM
Most of the access functions close their Cursor after using them. Is it possible that you have many valid access functions at any point?
I also see that a new Cursor is opened during an Enumerator operation, for the life of that Enumerator. Do you have any long-lived foreach loops?
Yes, it's possible and likely that that it's accessed by 256 concurrently. In test environments there are some spikes, and sometimes the exception got thrown, a second later everything was OK again (1 second is the closest I can narrow it down)

martinc wrote:
PersistentDictionary.cs has:
        this.instance.Parameters.MaxSessions = 256;
        this.instance.Parameters.MaxOpenTables = 256;
These numbers can easily be increased and recompiled.
If the usage is legitimate, then increase these numbers.
Good to know. But would it be possible to overload the constructor that it takes and object similar to instance.Parameters to initilize with, the current string constructor using this new constructor as well? Would it be possible that I make those changes and send you the code to merge it into or to join the project and check it in?

BR, Klaus
Aug 12, 2013 at 8:42 PM
The Legal People prohibit us from accepting source contributions; sorry.

I also don't think that it's appropriate to be on the constructor. The constructor's parameters should be reserved for what can't be easily changed later.

If exposed, it would be cleaner to expose parameters either one-by-one, or exposing the InstanceParameters object:
PersistentDictionary.InstanceParameters.MaxSessions = 1000;
PersistentDictionary.MaxSessions = 1000;

-martin