Re: [sqlite] race condition?

2018-10-30 Thread Lei Chen
Thanks Dan. I just found another report regarding the hot journal, "Hot-Journal with VFS", https://www.mail-archive.com/sqlite-users@mailinglists.sqlite.org/msg112377.html. It seems the same issue as I hit. Thanks, Lei Chen Lei Chen 于2018年10月29日周一 下午4:45写道: > Hi experts, > > I'm debugging a

Re: [sqlite] race condition?

2018-10-29 Thread Dan Kennedy
On 10/29/2018 03:45 PM, Lei Chen wrote: Hi experts, I'm debugging a tricky issue related to sqlite(3.9.2) database access. This is on Linux 3.2 kernel. Basically, when the failure occurs, there are two processes accessing the same -journal file concurrently, see below log. When daemon scsitgtd

[sqlite] race condition?

2018-10-29 Thread Lei Chen
Hi experts, I'm debugging a tricky issue related to sqlite(3.9.2) database access. This is on Linux 3.2 kernel. Basically, when the failure occurs, there are two processes accessing the same -journal file concurrently, see below log. When daemon scsitgtd wants to "commit" a transaction, it finds

Re: [sqlite] Race condition -- fixed?

2007-10-29 Thread Trevor Talbot
I wrote: > I would still perform rollbacks for any errors other than the above > expected SQLITE_BUSY cases, of course, since they indicate something > else went wrong (such as running out of disk space). I think it's > safe to say those are all unusual cases though. Hmm,

Re: [sqlite] Race condition -- fixed?

2007-10-29 Thread Trevor Talbot
On 10/29/07, Richard Klein <[EMAIL PROTECTED]> wrote: > Perhaps the best solution is to follow these rules: > > IF THE TRANSACTION IS A WRITER (i.e. will eventually write to the db): > -- > (1) Begin the transaction with 'BEGIN

Re: [sqlite] Race condition -- fixed?

2007-10-29 Thread Richard Klein
Trevor Talbot wrote: On 10/29/07, Richard Klein <[EMAIL PROTECTED]> wrote: But am I correct in assuming that one way that SQLite provides serializable transactions is by automatically rolling back transactions when necessary (and returning SQLITE_IOERR)? No. That will happen in some

Re: [sqlite] Race condition -- fixed?

2007-10-29 Thread Trevor Talbot
On 10/29/07, Richard Klein <[EMAIL PROTECTED]> wrote: > But am I correct in assuming that one way that SQLite provides > serializable transactions is by automatically rolling back > transactions when necessary (and returning SQLITE_IOERR)? No. That will happen in some specific unavoidable

Re: [sqlite] Race condition -- fixed?

2007-10-29 Thread Ken
Its up to you to rollback the transaction. It would return a SQLITE_BUSY, not an IOERR. Richard Klein <[EMAIL PROTECTED]> wrote: But am I correct in assuming that one way that SQLite provides serializable transactions is by automatically rolling back transactions when necessary (and returning

Re: [sqlite] Race condition -- fixed?

2007-10-29 Thread Richard Klein
But am I correct in assuming that one way that SQLite provides serializable transactions is by automatically rolling back transactions when necessary (and returning SQLITE_IOERR)? Thanks, - Richard Klein [EMAIL PROTECTED] wrote: Ken <[EMAIL PROTECTED]> wrote: BEGIN TRANSACTION; SELECT

Re: [sqlite] Race condition -- fixed?

2007-10-27 Thread Florian Weimer
> This is true of SQLite because isolation in SQLite > is "SERIALIZABLE". This is the highest level of isolate > provided by SQL. Most client/server database engines > by default implement "READ COMMITTED". The value of > "balance" might change between the SELECT and the > UPDATE in MySQL, for

Re: [sqlite] Race condition -- fixed?

2007-10-26 Thread Trevor Talbot
On 10/26/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > This is true of SQLite because isolation in SQLite > is "SERIALIZABLE". This is the highest level of isolate > provided by SQL. Most client/server database engines > by default implement "READ COMMITTED". The value of > "balance"

Re: [sqlite] Race condition -- fixed?

2007-10-26 Thread Ken
Richard: Actually No, process A will not acquire the reserved lock. It failes returning a sqlite_busy, and must perform a rollback. Even if Process B commits. Process A will get a sqlite_busy, forcing you to rollback. In order for the application to be correct the entire transaction must be

Re: [sqlite] Race condition -- fixed?

2007-10-26 Thread Ken
That makes sense given SERIALIZABLE transactions. The entire trasaction will require rollback since it gets a sqlite_busy, Not just the update. This also has the effect of invalidating the data selected within the transaction that performs the rollback. Oracle defaults to Read Committed. But

Re: [sqlite] Race condition -- fixed?

2007-10-26 Thread drh
Ken <[EMAIL PROTECTED]> wrote: > > BEGIN TRANSACTION; > SELECT balance FROM accounts WHERE accountId = '123-45-6789'; > UPDATE accounts SET balance = > WHERE accountId = '123-45-6789'; > COMMIT; > > This is a comman and naive assumption that the balance selected > will

Re: [sqlite] Race condition -- fixed?

2007-10-26 Thread Ken
Richard Klein <[EMAIL PROTECTED]> wrote: Dan Kennedy wrote: > On Wed, 2007-10-24 at 21:38 -0700, Richard Klein wrote: >> As I was thinking about the locking mechanism in SQLite 3, >> it occurred to me that the following race condition could >> occur. >> >> Imagine a joint bank account with a

Re: [sqlite] Race condition -- fixed?

2007-10-25 Thread Richard Klein
Trevor Talbot wrote: On 10/25/07, Richard Klein <[EMAIL PROTECTED]> wrote: Trevor Talbot wrote: The thing is, SQLite's synchronization mechanism is simpler than most full-featured SQL databases. In all cases, the point is that if you are attempting to do simultaneous writes from two

Re: [sqlite] Race condition -- fixed?

2007-10-25 Thread Trevor Talbot
On 10/25/07, Richard Klein <[EMAIL PROTECTED]> wrote: > Trevor Talbot wrote: > > The thing is, SQLite's synchronization mechanism is simpler than most > > full-featured SQL databases. In all cases, the point is that if you > > are attempting to do simultaneous writes from two connections, each >

Re: [sqlite] Race condition -- fixed?

2007-10-25 Thread John Stanton
I am sure that you are correct, that Sqlite's sync mechanism is not terribly complicated for you and for anyone else who understands the principles, however it does confuse many users as you see from the posts to this forum. Simple to use could become simpler to use. Synchronizing

Re: [sqlite] Race condition -- fixed?

2007-10-25 Thread Richard Klein
Dan Kennedy wrote: On Wed, 2007-10-24 at 21:38 -0700, Richard Klein wrote: As I was thinking about the locking mechanism in SQLite 3, it occurred to me that the following race condition could occur. Imagine a joint bank account with a balance of $10,000. The wife makes a withdrawal of $1,000

Re: [sqlite] Race condition -- fixed?

2007-10-25 Thread Richard Klein
Trevor Talbot wrote: The thing is, SQLite's synchronization mechanism is simpler than most full-featured SQL databases. In all cases, the point is that if you are attempting to do simultaneous writes from two connections, each connection must be prepared to receive an error, rollback the

Re: [sqlite] Race condition -- fixed?

2007-10-25 Thread Richard Klein
Lee Crain wrote: I've wrapped all of my company's SQLite database accesses in my own API layer that encapsulates all of our applications' business rules and forces ALL transactions, no matter how lengthy or trivial, to be atomic by using a MUTEX to avoid the types of scenarios described below.

Re: [sqlite] Race condition -- fixed?

2007-10-25 Thread Trevor Talbot
The thing is, SQLite's synchronization mechanism is simpler than most full-featured SQL databases. In all cases, the point is that if you are attempting to do simultaneous writes from two connections, each connection must be prepared to receive an error, rollback the transaction, and try again.

Re: [sqlite] Race condition -- fixed?

2007-10-25 Thread John Stanton
October 24, 2007 10:39 PM To: sqlite-users@sqlite.org Subject: [sqlite] Race condition -- fixed? As I was thinking about the locking mechanism in SQLite 3, it occurred to me that the following race condition could occur. Imagine a joint bank account with a balance of $10,000. The wife makes a

Re: [sqlite] Race condition -- fixed?

2007-10-25 Thread John Stanton
A classic solution to that problem is not to perform updates but to insert transactions, The concept of log file systems to give concurrency is worth scrutiny. Richard Klein wrote: As I was thinking about the locking mechanism in SQLite 3, it occurred to me that the following race condition

RE: [sqlite] Race condition -- fixed?

2007-10-25 Thread Lee Crain
-users@sqlite.org Subject: [sqlite] Race condition -- fixed? As I was thinking about the locking mechanism in SQLite 3, it occurred to me that the following race condition could occur. Imagine a joint bank account with a balance of $10,000. The wife makes a withdrawal of $1,000 at ATM 'A' (serviced

Re: [sqlite] Race condition -- fixed?

2007-10-25 Thread Dan Kennedy
On Wed, 2007-10-24 at 21:38 -0700, Richard Klein wrote: > As I was thinking about the locking mechanism in SQLite 3, > it occurred to me that the following race condition could > occur. > > Imagine a joint bank account with a balance of $10,000. > The wife makes a withdrawal of $1,000 at ATM 'A'

[sqlite] Race condition -- fixed?

2007-10-24 Thread Richard Klein
As I was thinking about the locking mechanism in SQLite 3, it occurred to me that the following race condition could occur. Imagine a joint bank account with a balance of $10,000. The wife makes a withdrawal of $1,000 at ATM 'A' (serviced by process A in the bank's mainframe), while at the same

Re: [sqlite] Race condition in testThreadLockingBehavior?

2005-03-03 Thread Christopher R. Palmer
D. Richard Hipp wrote: On Thu, 2005-03-03 at 07:30 -0500, Christopher R. Palmer wrote: It looks to me like this test assumes that no other process currently has a lock on this file. If any other process has any lock on this file, I believe one or both of the locking calls will fail which will

Re: [sqlite] Race condition in testThreadLockingBehavior?

2005-03-03 Thread D. Richard Hipp
On Thu, 2005-03-03 at 07:30 -0500, Christopher R. Palmer wrote: > It looks to me like this test assumes that no other process currently has a > lock on this file. If any other process has any lock on this file, I > believe one or both of the locking calls will fail which will trick sqlite >

[sqlite] Race condition in testThreadLockingBehavior?

2005-03-03 Thread Christopher R. Palmer
I am using version 3.0.8 of sqlite. In the course of trying to track down a strange error in my application where I very infrequently get a database is locked error (even though my busy timeout is set to some insanely large number, like a billion seconds), I was looking through the code is