Project

General

Profile

webdav module cannot open sqlite.db file.

Added by tokohito about 1 month ago

Hello

I'm testing lighttpd on embedded Linux where armel(armv5) is implemented.

# cat /proc/version
Linux version 2.6.32.28 (root@ubuntu-desktop) (gcc version 4.5.2 (Sourcery G++ Lite 2011.03-42) ) #125 PREEMPT Fri Dec 14 14:40:11 CST 2012

# cat /etc/version.txt
Product Name     : PQI Air card
Firmware Version : V147 DEC202012 M
Build Date       : 20 DEC 2012
Revision         : 2
WiFi Model       : Atheros AR6003 11n
Linux Kernel     : 2.6.32.28
Busybox          : 1.18.5

# lighttpd -v
lighttpd/1.4.39 (ssl) - a light and fast webserver
Build-Date: Oct 28 2022 13:37:19

I want to use the function of Webdav, so I tried to enable the module, but then lighttpd cannot start.
https://github.com/lighttpd/lighttpd1.4/blob/lighttpd-1.4.39/src/mod_webdav.c#L224
2012-01-01 00:01:46: (mod_webdav.c.224) can't open transaction: database is locked

I used strace command and found that the Permission denied event happened when lighttpd process exec a fcntl64() system call.

# /mnt/sd/DCIM/122_TREK/usr/bin/strace -ffff -tttt lighttpd -f /etc/lighttpd/lighttpd.conf
...
1325553933.160880 clone(/mnt/sd/DCIM/122_TREK/usr/bin/strace: Process 371 attached
child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x40007068) = 371
[pid   370] 1325553933.171192 munmap(0x404eb000, 77824 <unfinished ...>
[pid   371] 1325553933.176349 setsid()  = 371
[pid   371] 1325553933.176349 rt_sigaction(SIGHUP, {SIG_IGN, [HUP], SA_RESTORER|SA_RESTART, 0x40213b1c}, {SIG_DFL, [], 0}, 8) = 0
[pid   371] 1325553933.186662 clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x40007068) = 372
/mnt/sd/DCIM/122_TREK/usr/bin/strace: Process 372 attached
...
[pid   372] 1325553933.351667 lstat64("/tmp/webdav.db", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
[pid   370] 1325553933.361980 <... munmap resumed> ) = 0
[pid   372] 1325553933.361980 stat64("/tmp/webdav.db",  <unfinished ...>
[pid   370] 1325553933.361980 munmap(0x4045c000, 135168) = 0
[pid   370] 1325553933.367136 munmap(0x4047d000, 143360) = 0
[pid   372] 1325553933.372292 <... stat64 resumed> {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
[pid   372] 1325553933.377449 open("/tmp/webdav.db", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0644) = 5
[pid   372] 1325553933.377449 fstat64(5, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
[pid   372] 1325553933.382605 fstat64(5, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
[pid   372] 1325553933.387762 stat64("/tmp/webdav.db", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
[pid   372] 1325553933.398074 brk(0x8b000) = 0x8b000
[pid   372] 1325553933.398074 brk(0x8c000) = 0x8c000
[pid   372] 1325553933.403231 _llseek(5, 0, [0], SEEK_SET) = 0
[pid   372] 1325553933.403231 read(5, "", 100) = 0
[pid   370] 1325553933.408387 munmap(0x40276000, 69632) = 0
[pid   370] 1325553933.408387 munmap(0x40264000, 73728) = 0
[pid   370] 1325553933.413544 exit_group(0) = ?
[pid   372] 1325553933.418700 brk(0x9b000) = 0x9b000
[pid   372] 1325553933.418700 brk(0x9c000) = 0x9c000
[pid   370] 1325553933.423856 +++ exited with 0 +++
1325553933.423856 brk(0x9d000)          = 0x9d000
1325553933.429013 fcntl64(5, F_SETLK64, {l_type=F_RDLCK, l_whence=SEEK_SET, l_start=1073741824, l_len=1}) = -1 EACCES (Permission denied)
1325553933.434169 write(3, "2012-01-03 01:25:31: (mod_webdav"..., 84) = 84
1325553933.439326 write(3, "2012-01-03 01:25:31: (server.c.1"..., 83) = 83
1325553933.439326 fstat64(5, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
1325553933.444482 stat64("/tmp/webdav.db", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
1325553933.454795 close(5)              = 0
...

The target file where Permission denied event occurred is sqlight3 database.
This system has 3 filesystems(ramfs/jffs2/fat32), but I get the same error no matter which environment I try.
Also, sqlite3 originally included the function of In-memory DB, but it was not possible to use it at webdav module.

Please tell me the essential cause of the above error and how to deal with it
Best regards.


Replies (4)

RE: webdav module cannot open sqlite.db file. - Added by gstrauss about 1 month ago

It appears that you are using lighttpd/1.4.39. STOP. Do not pass go. That is such a fantastic failure that you should not continue troubleshooting until upgrading lighttpd. lighttpd 1.4.39 was released Dec 2015. lighttpd mod_webdav was completely rewritten in lighttpd 1.4.54. Latest version of lighttpd is lighttpd 1.4.67.

As you identified fcntl64(5, F_SETLK64, {l_type=F_RDLCK, l_whence=SEEK_SET, l_start=1073741824, l_len=1}) = -1 EACCES (Permission denied) is a problem. You need to figure out why that is occurring. Did you try sqlite3 commands directly against the database? Did you try putting the database on a different filesystem? e.g. test with the sqlite database in an in-memory filesystem like /tmp or /dev/shm.

You're not going to get further help here with such an ancient version of lighttpd 1.4.39.

RE: webdav module cannot open sqlite.db file. - Added by tokohito about 1 month ago

Hi

I try the same test with the latest buildroot and got the same result (please check attached log file for details).

# lighttpd -v
lighttpd/1.4.65 (ssl) - a light and fast webserver

The product I'm testing is very niche and comes in the form of an SD card, so there's no external interface.

# mount
proc on /proc type proc (0)
/dev/mtdblock0 on /mnt/mtd type jffs2 (0)
/dev/mmcblk0p1 on /mnt/sd type vfat (shortname=winnt,iocharset=utf8,rw)
none on /dev/pts type devpts (mode=0622)

The / mount point not displayed in the command output results is the ramfs.
The results were the same no matter which ramfs/jffs2/vfat(fat32) was tested.

The tests with sqlite3 command had similar results, with the exception that the In-memory DB feature did not cause any problems.

# sqlite3
SQLite version 3.39.2 2022-07-21 15:24:47
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .open /tmp/webdav.db
sqlite> .databases
main: /tmp/webdav.db r/w
sqlite> .tables
Error: database is locked

# sqlite3 :memory:
SQLite version 3.39.2 2022-07-21 15:24:47
Enter ".help" for usage hints.
sqlite> .databases
main: "" r/w
sqlite> .tables
sqlite>

RE: webdav module cannot open sqlite.db file. - Added by gstrauss about 1 month ago

The tests with sqlite3 command had similar results, with the exception that the In-memory DB feature did not cause any problems.

This is not a lighttpd issue.

If you can not get sqlite3 working on your system, then you can not get lighttpd mod_webdav using sqlite3 working on your system.

If you run lighttpd mod_webdav without webdav.sqlite-db-name then lighttpd mod_webdav will not be able to provide LOCK/UNLOCK or PROPPATCH, but lighttpd will serve other WebDAV commands. lighttpd mod_webdav will still serve standard "live properties" on the file for PROPFIND, but will not be able to PROPPATCH additional properties (or subsequently PROPFIND those additional properties) without a working sqlite3 database.

RE: webdav module cannot open sqlite.db file. - Added by gstrauss about 1 month ago

If your system is slow, then you can try tuning sqlite3. Again, this is an issue with sqlite3 on your system, not lighttpd.
https://dba.stackexchange.com/questions/47919/how-do-i-specify-a-timeout-in-sqlite3-from-the-command-line/47920#47920

    (1-4/4)