Hello,

I'm confused by the effects of WAL on the EXCLUSIVE locking mode. The
following works just fine (example uses the apsw Python interface, but
it's the same when using the C API):

import apsw
conn1 = apsw.Connection('barf.db')
cur1 = conn1.cursor()
cur1.execute('create table foo (bar int)')
cur1.execute('pragma journal_mode = DELETE')
conn2 = apsw.Connection('barf.db')
cur2 = conn2.cursor()
cur2.execute('pragma locking_mode = EXCLUSIVE')
cur2.execute('insert into foo values(22)')

But this gives a BusyError on the last statement:

import apsw
conn1 = apsw.Connection('barf.db')
cur1 = conn1.cursor()
cur1.execute('create table foo (bar int)')
cur1.execute('pragma journal_mode = WAL')
conn2 = apsw.Connection('barf.db')
cur2 = conn2.cursor()
cur2.execute('pragma locking_mode = EXCLUSIVE')
cur2.execute('insert into foo values(22)')

I guess that in the first case the second connection has no way of
knowing that there already is a connection to the database (since the
first connection isn't holding any locks), while in the second case the
WAL shared memory allows the connections to see each other without
holding locks.

However, should the second connection's write attempt really fail in
this situation? It seems counter-intuitive to me that in the same
situation (two connections to the database, only one holding a lock) the
behavior is so different depending on the journal mode...


Best,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to