Connection pool has been unable to grant a connection to thread

北战南征 提交于 2019-12-08 23:03:07

问题


I'm using GreenDAO for database handling in Android. When performing many database changes (> 15.000) I get this error Message:

The connection pool for database '/data/data/...' has been unable to grant a connection to thread 312 (Thread-312) with flags 0x1 for 30.000002 seconds.

Everything gets stuck. Why does this error happen?


回答1:


I can't say for sure about this particular implementation, but there is a connectionpool usually backing a ORM. The connection pool opens a set number of connections to the database and recycles them as you close them and open new connections. What that error is telling you is that it probably hit a limit. That can happen for a large variety of reasons, one is that possibly there is some deadlock in the DB because you are updating two tables and two different transactions are holding different tables waiting for the other to release. Or simply that there are just too many open connections and the DB or connection pool just gets confused.

Sorry that is not really an answer, but you are going to need to look at the docs for GreenDAO to see how this might happen.




回答2:


I got this message when I want to select a query on a table which is used on a transaction without ended transaction before. Problem solved after executing endTransaction() on finally block of transaction.




回答3:


I got this message when creating too many connections to SQLite via DBFlow FlowQueryList . My solution was to make sure that once you were done with the query list to call endTransactionAndNotify() and then close() on the querylist.

Calling endTransactionAndNotify() alone did not do the trick. I hope this helps, this thread certainly helped me.



来源:https://stackoverflow.com/questions/11742464/connection-pool-has-been-unable-to-grant-a-connection-to-thread

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!