> While((result = sqlite3_step(stmt)) == SQLITE_BUSY) > { > Usleep(_random [0s, 1s[_); > }
When sqlite3_step returned SQLITE_BUSY you have to call sqlite3_reset before calling sqlite3_step again. So your loop should look like this: While((result = sqlite3_step(stmt)) == SQLITE_BUSY) { sqlite3_reset(stmt); Usleep(_random [0s, 1s[_); } Pavel On Fri, Nov 25, 2011 at 5:07 AM, <joel.bertr...@external.gdfsuez.com> wrote: > Hello, > > I'm writing a multithreaded application (sqlite 3.7.9 on linux > i386). > First thread exports some parts of a database, deletes exported records and > starts a vacuum. Second thread tries to write in database. > When my application tries to write data when the other thread is running > vacuum, sqlite3_step() returns SQL_BUSY. I have set busy_timeout to 1000. > > If sqlite3_step() returns BUSY_TIMEOUT, I try to restart > statement : > > While((result = sqlite3_step(stmt)) == SQLITE_BUSY) > { > Usleep(_random [0s, 1s[_); > } > > But this loop always enters in a deadlock : if sqlite3_step() returns > SQLITE_BUSY, and if I try to restart the same statement, it always will > returns SQLITE_BUSY even if there is no other concurrent transaction. If I > write : > > Int I = 0; > While((result = sqlite3_step(stmt)) == SQLITE_BUSY) > { > Usleep(_random [0s, 1s[_); > If (++I > 10) break; > } > > I have forgotten current statement (and data) but following SQL query returns > SQLITE_OK. Why does sqlite3_step() always returns SQLITE_BUSY on a statement > when it has returned SQLITE_BUSY the first time ? > > Regards, > > JB > > > GDF SUEZ Mail Disclaimer: http://www.gdfsuez.com/disclaimer/disclaimer-fr.html > > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users