I've been playing around with WAL journaling on sqlite 3.7.2 (the
build from Ubuntu Maverick).  I consistently get corrupted dbs when I
use synchronous=NORMAL and journal_mode=WAL on XFS with multiple
concurrent writers.  If I change either of those pragmas or run it on
ext3, I don't seem to have any problems.

Here's my little repro in python:

-------

import sqlite3, time, os, multiprocessing, uuid

def connect():
    conn = sqlite3.connect('./test.db', timeout=60.0)
    conn.execute('PRAGMA synchronous = NORMAL')
    conn.execute('PRAGMA journal_mode = WAL')
    return conn

connect().execute("CREATE TABLE object (name TEXT UNIQUE);")

def insert_items():
    while True:
        conn = connect()
        conn.execute('''
            INSERT INTO object (name) VALUES (?)
        ''', (uuid.uuid4().hex,))
        conn.commit()

for x in xrange(10):
    proc = multiprocessing.Process(target=insert_items)
    proc.daemon = True
    proc.start()

while True:
    print len(list(connect().execute('select * from object order by name')))
    time.sleep(5)

-------

Running this, I get something along the lines of:

n...@cfsyn27:/mnt/sdb1$ python reproduce.py
11
3643
7479
Traceback (most recent call last):
  File "reproduce.py", line 25, in <module>
    print len(list(connect().execute('select * from object order by name')))
sqlite3.DatabaseError: database disk image is malformed


Any thoughts?

-- Michael Barton
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to