> It's locked into EXCLUSIVE mode if it was in EXCLUSIVE mode when you
switched to WAL.  But > there's nothing requiring it.

I was not referring to the locking_mode, I was writing about the lock
itself over the database (iNode structure). On QNX the exclusive
locking_mode it is required, because it seems that shared memory is not
working properly.

The entry point when enabling WAL:

JOURNALMODE_WAL will be enabled (a trace added by me)

LOCK    11 SHARED was NONE(NONE,0) pid=229454 tid=20 (unix)
fcntl pid=229454 tid=20 11 SETLK RDLCK 1073741824 1 125195676 0
fcntl pid=229454 tid=20 11 SETLK RDLCK 1073741826 510 125195676 0
fcntl pid=229454 tid=20 11 SETLK UNLCK 1073741824 1 125195676 0
LOCK    11 SHARED ok (unix)

READ    11     16      24 0
LOCK    11 RESERVED was SHARED(SHARED,1) pid=229454 tid=20 (unix)
fcntl pid=229454 tid=20 11 SETLK WRLCK 1073741825 1 125195740 0
LOCK    11 RESERVED ok (unix)

LOCK    11 EXCLUSIVE was RESERVED(RESERVED,1) pid=229454 tid=20 (unix)
fcntl pid=229454 tid=20 11 SETLK WRLCK 1073741824 1 125195708 0
fcntl pid=229454 tid=20 11 SETLK WRLCK 1073741826 510 125195708 0
LOCK    11 EXCLUSIVE ok (unix)

TRANSACTION 139542152
OPENX   12  /mnt/share/testApp/myDB.nal 0402
fcntl unknown pid=229454 tid=20 12 1 0
fcntl unknown pid=229454 tid=20 12 2 0
OPEN    12  /mnt/share/testApp/myDB.nal
WRITE   12    512       0 0
WRITE   12      4     512 0
WRITE   12  65536     516 0
WRITE   12      4   66052 0
JOURNAL 139542152 page 1 needSync=1 hash(00000000)

Filename:      /mnt/share/testApp/myDB.db
State:         WRITER_CACHEMOD errCode=0
Lock:          EXCLUSIVE
Locking mode:  locking_mode=exclusive
Journal mode:  journal_mode=wal
Backing store: tempFile=0 memDb=0 useJournal=1
Journal:       journalOff=66056 journalHdr=0
Size:          dbsize=35 dbOrigSize=35 dbFileSize=35

DATABASE SYNC: File=/mnt/share/testApp/myDB.db zMaster= nSize=35
READ    12      0   66560 0
SYNC journal of 139542152
SYNC    12
DIRSYNC /mnt/share/testApp/myDB.nal (have_fullfsync=0 fullsync=0)
fcntl unknown pid=229454 tid=20 13 1 0
fcntl unknown pid=229454 tid=20 13 2 0
OPENDIR 13  /mnt/share/nav
WRITE   12     12       0 0
SYNC journal of 139542152
SYNC    12
READ    11      4      24 0
WRITE   11  65536       0 0
STORE 139542152 page 1 hash(00000000)
SYNC    11
COMMIT 139542152
CLOSE   -1

So far no UNLOCK... it continues opening four more connections to same db:

OPENX   12  /mnt/share/testApp/myDB.db 02
fcntl unknown pid=229454 tid=20 12 1 0
fcntl unknown pid=229454 tid=20 12 2 0
OPEN    12  /mnt/share/testApp/myDB.db
OPEN 139532984 /mnt/share/testApp/myDB.db
OPEN 139506232 /mnt/share/testApp/myDB.db
OPENX   13  /mnt/share/testApp/myDB.db 02
fcntl unknown pid=229454 tid=20 13 1 0
fcntl unknown pid=229454 tid=20 13 2 0
OPEN    13  /mnt/share/testApp/myDB.db
OPEN 139543832 /mnt/share/testApp/myDB.db
OPEN 139505000 /mnt/share/testApp/myDB.db
OPENX   14  /mnt/share/testApp/myDB.db 02
fcntl unknown pid=229454 tid=20 14 1 0
fcntl unknown pid=229454 tid=20 14 2 0
OPEN    14  /mnt/share/testApp/myDB.db
OPEN 139531896 /mnt/share/testApp/myDB.db
OPEN 139524696 /mnt/share/testApp/myDB.db
OPENX   15  /mnt/share/testApp/myDB.db 02
fcntl unknown pid=229454 tid=20 15 1 0
fcntl unknown pid=229454 tid=20 15 2 0
OPEN    15  /mnt/share/testApp/myDB.db
OPEN 139501056 /mnt/share/testApp/myDB.db
OPEN 139501688 /mnt/share/testApp/myDB.db

Next read requests - SHARED locks will fail:

LOCK    12 SHARED was NONE(EXCLUSIVE,1) pid=229454 tid=16 (unix)
LOCK    12 SHARED failed (unix)
UNLOCK  12 0 was 0(4,1) pid=229454 tid=16 (unix)
ROLLBACK 139532984
LOCK    12 SHARED was NONE(EXCLUSIVE,1) pid=229454 tid=20 (unix)
LOCK    12 SHARED failed (unix)
UNLOCK  12 0 was 0(4,1) pid=229454 tid=20 (unix)
ROLLBACK 139532984
LOCK    12 SHARED was NONE(EXCLUSIVE,1) pid=229454 tid=20 (unix)
LOCK    12 SHARED failed (unix)
UNLOCK  12 0 was 0(4,1) pid=229454 tid=20 (unix)
ROLLBACK 139532984
LOCK    12 SHARED was NONE(EXCLUSIVE,1) pid=229454 tid=20 (unix)
LOCK    12 SHARED failed (unix)
UNLOCK  12 0 was 0(4,1) pid=229454 tid=20 (unix)
ROLLBACK 139532984
LOCK    12 SHARED was NONE(EXCLUSIVE,1) pid=229454 tid=20 (unix)
LOCK    12 SHARED failed (unix)
UNLOCK  12 0 was 0(4,1) pid=229454 tid=20 (unix)
ROLLBACK 139532984

So, the same process, it is clear that no other process/thread is accessing
the database. Why the EXCLUSIVE lock acquired during the WAL enabling is
not released?

Regards,
Sandu Buraga
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to