Joanne Pham wrote:
Hi John,
Thanks a lot for your response.
Make sure I am understanding your answer related to SQLITE_BUSY. So I need to
change my code from
Open the database connection
BEGIN
insert ...using sqlite3_step
insert ...using sqlite3_step
END
to
Open the database connection
BEGIN
insert ...using sqlite3_step
insert ...using sqlite3_step
...
do {
rc = END (transaction or commit)
while (rc == SQLITE_BUSY)
So I just loop on if the return statement is SQLITE_BUSY.
Is that correct John?
Thanks a ton,
JP
Correct. You might add a count to drop out if there is a deadlock.
e.g.
use sqlite3_prepare_v2
var count = MAX_SPINS;
while (1) {
rc = sqlite3_step(<compiled "END" statement>);
if (rc == SQLITE_BUSY) yield();
else {
if ((rc != SQLITE_OK) || (count <= 0)) report_error();
break;
}
count--;
}
----- Original Message ----
From: John Stanton <[EMAIL PROTECTED]>
To: sqlite-users@sqlite.org
Sent: Wednesday, November 28, 2007 12:04:34 PM
Subject: Re: [sqlite] SQLITE_BUSY retry
You could use a BEGIN IMMEDIATE to lock the DB before you launch the
transaction and loop on SQLITE_BUSY or use the plain BEGIN which will
allow reads during the transaction and not lock the DB until you issue a
COMMIT (the END). Just loop on the BUSY on the END SQL statement until
the user who has the DB locked releases it.
A technique we use to get a minimum latency but reasonably efficient
busy wait is to issue a yield call each time an SQLITE_BUSY is
encountered so that the time slice is dropped and other processes can
run. A alternative is to issue a short delay or sleep.
Joanne Pham wrote:
Hi All,
Here my statements to insert rows into the database
Open the database connection
BEGIN
insert ...using sqlite3_step
insert ...using sqlite3_step
END
So at the time I issued "END" transaction I got the error message SQLITE_BUSY so I need
to issue the "END" transaction again or What should I do in this case to handle
SQLITE_BUSY.
Thanks a lot in advance for the help or advice.
JP
----- Original Message ----
From: Joanne Pham <[EMAIL PROTECTED]>
To: sqlite-users@sqlite.org
Sent: Wednesday, November 28, 2007 11:27:52 AM
Subject: [sqlite] SQLITE_BUSY retry
Hi All,
I have used "BEGIN" and "END" Transaction to insert the data to SQLite database.
BEGIN
insert ...
insert ...
END
When I issued the "END" operation the error message return back is "SQLITE_BUSY".
What should I do if I want to handle SQLITE_BUSY /retry the transaction. Should I execute "END" transaction again.
How to handle the SQLITE_BUSY?
Thanks,
JP
____________________________________________________________________________________
Get easy, one-click access to your favorites.
Make Yahoo! your homepage.
http://www.yahoo.com/r/hs
____________________________________________________________________________________
Be a better sports nut! Let your teams follow you
with Yahoo Mobile. Try it now. http://mobile.yahoo.com/sports;_ylt=At9_qDKvtAbMuh1G1SQtBI7ntAcJ
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------
____________________________________________________________________________________
Be a better pen pal.
Text or chat with friends inside Yahoo! Mail. See how. http://overview.mail.yahoo.com/
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------