Hi Jesper, the code you posted is not the offending code, it's just the symptom of a problem happening somewhere else. We will need
to see the other operations also done by the DB code to know what goes on with it, but from some experiences on the list the
following is likely:
- You have another open operation or transaction which has not been committed
or finalized or in some way completed.
- The insert_statement contains a binding linked to a function that is not completing (though this should only ever break in a
multi-threaded case)
- There is a dependency on a binding or code within the DB operations to another read operation which can't succeed while the insert
query is executing.
The fact that it does not happen often does make tracing hard, but it also is a great clue to look for code executing with values
which either change a lot or have other dependencies with fluctuating results or execution timeframes.
Bottom line is this: SQLite can't report a BUSY signal if it isn't actually BUSY. Being busy means it is waiting to finish some
open DB operation (which only you could have started) and you have either not yet finished it or released it of its responsibility,
so pay good attention to where you release/close the queries. If you still can't eradicate the problem, post the code for the whole
transaction please.
On 2013/07/22 08:28, Jesper Baekdahl wrote:
Hey everybody.
I'm getting SQLITE_BUSY on sqlite_step on insert statement, that is
part of an explicit transaction of multiple statements. There is only
1 thread and 1 connection, so there should not be anything holding a
lock.
It does not happen very often, so I'm having a hard time debugging it.
The code is something like this:
do {
res = sqlite3_step(insert_statement);
if( res == SQLITE_BUSY )
usleep(1000);
} while ( res == SQLITE_BUSY);
And it will just hang there forever..
Looking foward to some advice.
Regards,
Jesper
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users