SQLite Forum

In which cases shall sqlite3_prepare return SQLITE_BUSY?
Login
Hello, 

I am developing a http server in rust using `actix-web` and
`r2d2-rusqlite`. If I understand well `r2d2-rusqlite` keeps a
pool of sqlite3 connections. `Actix-web` runs several threads
for handling incoming http requests. Each thread acquires
an idle sqlite3 connection from the pool. Once this connection is
taken from the pool, no other thread can get it, until it is returned
to the pool by the thread that acquired it. When this thread terminates,
the connection is returned to the pool.

Now, I've found in logs that the call to the sqlite3_prepare
returned (for me unexpected) result SQLITE_BUSY. I'am trying
to understand what really has happened.

I am not familiar with sqlite3 internals. Can someone explain me is it
really possible that sqlite3_prepare can not finish because database is
locked? What can I do to prevent this from happening? Or perhaps I need to
check every call to sqlite3_prepare for this condition?

Thank you very much.
Vitalije