I’ve been getting a strange intermittent error whe...
# android
m
I’ve been getting a strange intermittent error when executing
CREATE INDEX
SQLite statements in a coroutine (not using Room).
Copy code
SQLiteConnectionPool: The connection pool for database '+path+to+my_db' has been unable to grant a connection to thread 2676 (DefaultDispatcher-worker-8) with flags 0x2 for 12.003 seconds.
    Connections: 0 active, 1 idle, 0 available.
It only ever (not always) happens if I call
yield()
in between each
execSQL
. Is it something to do with SQLite not liking being accessed by different threads within the same transaction (which I’m guessing might happen when using
yield()
)?
a
Probably. You cannot switch threads when using those APIs
m
Thanks Adam. I guess there are other (than yield) potential ways the thread might be switched while using coroutines. Would it therefore (in the context of SQLite) be more advisable to write mostly non-suspending functions other than at the highest level?