cannot use sqlite3 on cifs mount

Bug #117730 reported by casbon on 2007-05-30
28
This bug affects 3 people
Affects Status Importance Assigned to Milestone
samba
Fix Released
Medium
samba (Debian)
Fix Released
Unknown
samba (Ubuntu)
Low
Unassigned
Nominated for Feisty by Mathias Gug

Bug Description

Binary package hint: smbfs

/tmp/ is a local fs:

james@palermo:/tmp$ rm test.db
james@palermo:/tmp$ sqlite3 test.db
SQLite version 3.3.13
Enter ".help" for instructions
sqlite> create table t1 (t1key INTEGER PRIMARY KEY,data TEXT,num double,timeEnter DATE);
sqlite>

but on a cifs mount:
james@palermo:~$ rm test.db
james@palermo:~$ sqlite3 test.db
SQLite version 3.3.13
Enter ".help" for instructions
sqlite> create table t1 (t1key INTEGER PRIMARY KEY,data TEXT,num double,timeEnter DATE);
SQL error: database is locked
sqlite>

casbon (casbon) wrote :
Mathias Gug (mathiaz) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. You reported this bug a while ago and there hasn't been any activity in it recently. We were wondering is this still an issue for you? Could you make sure that you've mounted your smb share in read-write mode ?

Changed in samba:
status: New → Incomplete
Mathias Gug (mathiaz) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. However, I am closing it because the bug has been fixed in the latest development version of Ubuntu - the Gutsy Gibbon.

Changed in samba:
status: Incomplete → Fix Released
dkg (dkg0) wrote :

This looks like it's still a problem on hardy to me. The following was gathered from an up-to-date ubuntu 8.04 installation with a user's home directory mounted via CIFS

Even worse than just sqlite3, since firefox 3 uses sqlite internally, it looks like it's making firefox fail to function at all when my home directory is mounted via CIFS.

When this user starts firefox, firefox just opens a small browser window, and doesn't even respond to clicks on the green triangle in the address bar.

When i shutdown firefox, wipe out ~/.mozilla and restart firefox to make it create a new profile directory, it still misbehaves. Looking at the freshly-created ~/.mozilla, it contains the following files:

.mozilla/firefox/k81epmi7.default/places.sqlite
.mozilla/firefox/k81epmi7.default/places.sqlite-1.corrupt
.mozilla/firefox/k81epmi7.default/places.sqlite-2.corrupt
.mozilla/firefox/k81epmi7.default/places.sqlite-3.corrupt
.mozilla/firefox/k81epmi7.default/places.sqlite-4.corrupt
.mozilla/firefox/k81epmi7.default/places.sqlite-5.corrupt
.mozilla/firefox/k81epmi7.default/places.sqlite.corrupt

I made a very simple sqlite3 db on /tmp (which is ext3 on this system), and copied the file to the cifs-mounted directory.

then i ran a simple command to add a row to a table against each copy, using strace.

I'm attaching the differences between the straces.

You can see that the sqlite3 process running against the cifsmount has its second byte-range locking request fail:

+fcntl64(3, F_SETLK64, {type=F_WRLCK, whence=SEEK_SET, start=1073741824, len=1}, 0xbfbcfc24) = 0
+fcntl64(3, F_SETLK64, {type=F_WRLCK, whence=SEEK_SET, start=1073741826, len=510}, 0xbfbcfc24) = -1 EACCES (Permission denied)

though the one running on ext3 has both locking byte-range locking requests succeed:

-fcntl64(3, F_SETLK64, {type=F_WRLCK, whence=SEEK_SET, start=1073741824, len=1}, 0xbf9549d4) = 0
-fcntl64(3, F_SETLK64, {type=F_WRLCK, whence=SEEK_SET, start=1073741826, len=510}, 0xbf9549d4) = 0

I don't know if this should be listed as a bug in the kernel's cifs module, a bug in sqlite, a bug in samba, or what.

fwiw, the server this is applied against is an older samba daemon on a machine that is touchy to upgrade for a number of reasons.

This ticket claims to be closed ("fixed in gutsy") but it's not clear to me how it was fixed (i see no link to a changelog). Suggestions for next steps?

Mathias Gug (mathiaz) wrote :

Reopening.

Changed in samba:
status: Fix Released → Incomplete

We have also run into this problem with our installations. We have over 300 workstations at our university, all have CIFS-mounted home directories. So far we managed to somehow avoid using any applications that used SQLite, but now with Firefox3 using it we are in a very difficult situation.

As a temporary measure we use a custom compiled SQLite library with the -DSQLITE_DISABLE_DIRSYNC=1 flag enabled, as per advice in http://sqlite.org/cvstrac/tktview?tn=1751

Of course this makes all the databases sensitive to data corruption.

Mathias Gug (mathiaz) wrote :

Could you post the commands you've used to create the sqlite database ?

Could you also add which version of samba is running on the server ?

dkg (dkg0) wrote :

I created the database like this:

  echo 'create table foo (x int); insert into foo (x) values (1);' | sqlite3 testdb

and tested it like this:

  echo 'select * from foo;' | sqlite3 testdb

This worked fine on a tmpfs, but not on a cifsmount. I've tested this against a debian etch samba version (3.0.24-6etch9) -- previous versions seem to fail as well, but the etch version of samba is the most recent i've tested.

[0 dkg@squeak ~]$ mount | egrep '/(tmp|mnt)'
/tmp on /tmp type tmpfs (rw,nosuid,nodev)
//bob/dmz on /mnt type cifs (rw,mand,unc=\\bob\dmz,username=,uid=1000,posixpaths,rsize=16384,wsize=57344)
[0 dkg@squeak ~]$ rm -f /tmp/testdb
[0 dkg@squeak ~]$ echo 'create table foo (x int); insert into foo (x) values (1);' | sqlite3 /tmp/testdb
[0 dkg@squeak ~]$ echo 'select * from foo;' | sqlite3 /tmp/testdb
1
[0 dkg@squeak ~]$ cp /tmp/testdb /mnt/testdb
cp: overwrite `/mnt/testdb'? y
[0 dkg@squeak ~]$ echo 'select * from foo;' | sqlite3 /mnt/testdb
1
[0 dkg@squeak ~]$ echo 'insert into foo (x) values (2);' | sqlite3 /mnt/testdb
SQL error near line 1: database is locked
[1 dkg@squeak ~]$

dkg (dkg0) wrote :

Just to follow up here: this current problem seems to be associated with CIFS's byte-range locking, which behaves in unexpected ways. If i use the "nobrl" option during the CIFS mount, i can cleanly use sqlite (this comes at the cost of not having advisory locks propagate across the network, though, so it is probably not an acceptable workaround to every situation).

I reported the bug against debian's smbfs package, if you want to follow it there: http://bugs.debian.org/483507

Changed in samba:
status: Unknown → New
Pedro Villavicencio (pedro) wrote :

It was also forwarded upstream here: https://bugzilla.samba.org/show_bug.cgi?id=5994 ; linking the report and setting this to triaged, thanks all.

Changed in samba:
importance: Undecided → Low
status: Incomplete → Triaged
Changed in samba:
status: Unknown → Confirmed
Changed in samba:
status: Confirmed → Fix Released
maihacke (simon-spielmann) wrote :

I'm using a firefox profile on a windows share mounted via pam_mount.
With Ubuntu 9.10 and using the "nobrl" option I could use the profile without problems.
After upgrading to 10.04 firefox can't read the bookmarks, history etc..

dkg (dkg0) wrote :

maihacke: just to be clear: are you using the nobrl option to the cifs mount on your 10.04 installation as well?

Jelmer Vernooij (jelmer) on 2011-01-02
Changed in samba (Ubuntu):
status: Triaged → Fix Released
Changed in samba:
importance: Unknown → Medium
Changed in samba (Debian):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.