We are getting this on more and more applications.
Status code: 500 Error Code: TObjectPool<XData.Aurelius.ConnectionPool.TDBConnectionWrapper>.EPoolAcquireException Cannot retrieve object from object pool
On the particular instance I am looking at this happens, even when we have only one user accessing the system, after a number of actions (a combination of service calls and entity cruds).
if we increase the pool size then more actions can be processed before the exception is raised.
so if we have a pool size of 1 then we can’t do anything at all (we did this just for testing). If we have a pool size of 10 then we get to add ~10 items to the shopping basket before we hit the error. This involves about 3 service calls and a CRUD Post.
Is there a way to track when the pool is released? How long is a pool held? I think it might be the service calls rather than the CRUD, but am not certain. There are no entity objects freed in the calls, the entities are all manager by the ObjectManager.
One rule of thumb for this pool errors is to answer this question:
After a pool acquire exception happens, does the server goes back to the normal (is able to process requests) after a while? Or do you have to restart the server?
If the servers goes back to normal after a while, it means your server is processing more requests than it's capable for. Either you must increase your pool size, and/or improve your code performance so whenever a connection is retrieved from the pool, it shouldn't take too long to be returned back.
If you need to restart the server: that means that your code is flawed and a connection that is retrieved from the pool is never returned. In this case you must fix your code, looking for memory leaks or racing conditions that might causing the IDBConnection interface handing around and never released.
You can take a look at ConnectionPoolDebugger demo in XData demos folder. It shows advanced techniques to properly debug connection pool handling in a way that makes it easier (or less harder) for you to tell in which parts of the code something wrong might be happening with the pool and its connections.