Bug 94161 - sqlite_compile error: database is locked on query
Summary: sqlite_compile error: database is locked on query
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Portability-Compilation (show other bugs)
Version: 0.7.0
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-30 12:20 UTC by John Livsey
Modified: 2017-08-19 20:58 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Livsey 2004-11-30 12:20:47 UTC
Version:           0.7 (using KDE 3.3.1, compiled sources)
Compiler:          gcc version 3.3.4
OS:                Linux (i686) release 2.4.27

When digikam is started from the console I get streams of messages related to the database being locked.

digikam: WARNING: [bool AlbumDB::execSql(const QString&, QStringList*, bool)] sqlite_compile error: database is locked on query: SELECT caption FROM Images WHERE dirid='0' AND name='P0411280108.JPG';

I have just upgraded from KDE 3.1 to 3.3.3 and upgraded from digikam 0.5.
Comment 1 Renchi Raju 2004-11-30 12:48:34 UTC
what platform? 
is the album library on a nfs mounted directory?
does the application deadlock?
Comment 2 John Livsey 2004-12-03 12:25:21 UTC
System is AMD Athlon XP2100 512MB RAM
Basic install is Slackware 9.0 with some upgrades
KDE 3.3.1 XF86 4.4
album is mounted locally
Seems like the problem is restricted where the album is created outside the users home directory (Say in a shared directory) File permissions all checkout OK and images etc can be imported into the album.
Comment 3 Renchi Raju 2004-12-04 02:27:39 UTC
need some more details:
a) path to album library folder
b) owner, group, permissions on album library folder
c) owner, group, permissions on digikam.db in album library folder
d) user name and group of user running digikam
Comment 4 John Livsey 2004-12-04 02:45:19 UTC
Renchi,

Don't you go to bed ??? Its 1245 here Saturday morning. (I've go to go 
out shopping) I'll send the info this evening.

regards john

Renchi Raju wrote:

>------- You are receiving this mail because: -------
>You reported the bug, or are watching the reporter.
>        
>http://bugs.kde.org/show_bug.cgi?id=94161        
>
>
>
>
>------- Additional Comments From renchi pooh tam uiuc edu  2004-12-04 02:27 -------
>need some more details:
>a) path to album library folder
>b) owner, group, permissions on album library folder
>c) owner, group, permissions on digikam.db in album library folder
>d) user name and group of user running digikam
>
>  
>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<font face="adobe-helvetica-iso10646-1">Renchi,<br>
<br>
Don't you go to bed ??? Its 1245 here Saturday morning. (I've go to go
out shopping) I'll send the info this evening.<br>
<br>
regards john<br>
</font><br>
Renchi Raju wrote:
<blockquote cite="mid20041204012740.7465.qmail@ktown.kde.org"
 type="cite">
  <pre wrap="">------- You are receiving this mail because: -------
You reported the bug, or are watching the reporter.
        
<a class="moz-txt-link-freetext" href="http://bugs.kde.org/show_bug.cgi?id=94161">http://bugs.kde.org/show_bug.cgi?id=94161</a>        




------- Additional Comments From renchi pooh tam uiuc edu  2004-12-04 02:27 -------
need some more details:
a) path to album library folder
b) owner, group, permissions on album library folder
c) owner, group, permissions on digikam.db in album library folder
d) user name and group of user running digikam

  </pre>
</blockquote>
</body>
</html>
Comment 5 John Livsey 2004-12-04 06:33:30 UTC
I'm afraid I have mislead you, the album is mounted on a NFS share. M desktop (byron) mounts a share from my server (camilla). I have printed out the directories involved on both machines.


local machine (byron) ls -l /
<snip>
lrwxrwxrwx    1 jlivsey  users          22 Aug  5  2003 pictures -> /mnt/camilla/pictures//
<snip>

remote machine (camilla) ls -l /
<snip>
drwxrwxr-t  16 jlivsey  users        4096 Dec  3 22:40 pictures/
<snip>

remote machine (camilla) ls -l /pictures
the directory I made from digikam is "test"

drwxrwxr-x   2 jlivsey  users        4096 Dec  1 18:10 bodybronze/
drwxrwxr-x   2 jlivsey  users        4096 Dec  1 18:10 cats/
drwxrwxr-x   2 jlivsey  users        4096 Dec  1 18:10 deb/
drwxrwxr-x   2 jlivsey  users        4096 Dec  1 18:10 debutante/
drwxrwxr-x   3 jlivsey  users        4096 Dec  1 18:09 home-stuff/
drwxrwxr-x   7 jlivsey  users        4096 Dec  1 18:09 jomena/
drwxrwxr-x   2 jlivsey  users        4096 Dec  1 18:09 misc/
drwxrwxr-x   3 jlivsey  users        4096 Dec  1 18:09 mtbuller/
drwxrwxr-x   3 jlivsey  users        4096 Dec  1 18:09 stephen/
drwxr-xr-x   3 jlivsey  users        4096 Dec  4 16:01 test/
drwxrwxr-x   2 jlivsey  users        4096 Dec  1 18:09 tim/
drwxrwxr-x   3 jlivsey  users        4096 Dec  1 18:08 unfiled/
drwxrwxr-x   5 jlivsey  users        4096 Dec  1 18:08 work/
drwxrwxr-x   2 jlivsey  users        4096 Dec  1 18:08 xmas-photos/
drwxrwxr-x   3 jlivsey  users        4096 Dec  1 18:08 xmas2002/

remote machine (camilla) ls -l /pictures/test
-rw-r--r--   1 jlivsey  users           0 Dec  4 16:01 digikam.db
drwxr-xr-x   2 jlivsey  users        4096 Dec  4 16:02 one/

remote machine (camilla) ls -l /pictures/test/one
-rw-r--r--   1 jlivsey  users      424992 Nov 28 06:52 P0411280101.JPG
jlivsey@byron:/$ 
Comment 6 John Livsey 2004-12-04 06:35:37 UTC
Forgot to add the user/group that digikam is run as is jlivsey/users
Comment 7 Renchi Raju 2004-12-04 06:48:48 UTC
aha. there's the problem. nfs file locking is rather poorly implemented and sqlite is having problems with that. you probably have a stale nfs lock on the file
Comment 8 Renchi Raju 2004-12-04 06:52:24 UTC
for eg see this: http://www.sqlite.org/cvstrac/tktview?tn=81,10
and this: http://www.sqlite.org/faq.html#q7
Comment 9 John Livsey 2004-12-04 06:59:53 UTC
Thanks Renchi, guess we may as well close this.
Comment 10 Renchi Raju 2004-12-04 07:04:13 UTC
not really. there was a plan to provide a configure time option to compile digikam  such that it saves the digikam.db file in the home directory (for nfs users like you). i will keep this open till that option is implemeted.
Comment 11 Colin Panisset 2004-12-06 22:16:19 UTC
I have worked around this by mounting the directory with the digikam database (and the albums) on a Samba filesystem (smbfs). File locking works properly across SMB.
Comment 12 John Livsey 2004-12-06 23:12:26 UTC
Colin, are you mounting a Linux share via smb or is it a Windows machine
Comment 13 Renchi Raju 2004-12-08 10:39:41 UTC
CVS commit by pahlibar: 


added configure option "--enable-nfs-hack" for users facing problems
with sqlite database file locking not working on nfs mounted disk. the album
db is saved (with this option enabled) in $HOMEDIR/.kde/share/apps/digikam with
a filename encoded with the full path to the album library path. for eg, for
album library path /mnt/nfsmount/Pictures, the db filename will be
%2fmnt%2fnfsmount%2fPictures%2fdigikam.db (the %2f is escaped in konqueror as "/")
obviously this is an unsupported option and normal users should never use this option
BUG: 94161


  M +24 -0     configure.in.in   1.17
  M +14 -1     digikam/albummanager.cpp   1.15
  M +9 -2      kioslave/digikamio.cpp   1.9
  M +11 -3     kioslave/digikamtags.cpp   1.12


--- kdeextragear-3/digikam/configure.in.in  #1.16:1.17
@@ -244,2 +244,26 @@
   AC_SUBST(LIB_TIFF)
 fi
+
+#------------------------------------------------------------------
+# NFS is Evil (sqlite makes use of file locking for allowing 
+# multiple processes to access the database. but on many 
+# nfs implementations, this file locking is horribly broken and
+# can end up locking the app or not allowing access to the app. 
+# since we use kioslaves which access the db too)
+#------------------------------------------------------------------
+
+AC_ARG_ENABLE(nfs-hack,
+        AC_HELP_STRING([--enable-nfs-hack],
+[Enable a hack for album libraries on a nfs mount, 
+ which causes the database to be saved in 
+ $HOMEDIR/.kde/share/apps/digikam/directoryname.db [default=disable]]),
+ [enable_nfs_hack=$enableval],
+ [enable_nfs_hack=no]
+)
+
+if test "x$enable_nfs_hack" == "xyes"; then
+   AC_DEFINE(NFS_HACK, 1, [NFS hack enabled])
+   AC_MSG_NOTICE([NFS hack enabled. Make sure you know what you are doing])
+fi
+
+

--- kdeextragear-3/digikam/digikam/albummanager.cpp  #1.14:1.15
@@ -23,5 +23,7 @@
 #include <klocale.h>
 #include <kdeversion.h>
+#include <kstandarddirs.h>
 #include <kio/netaccess.h>
+#include <kio/global.h>
 
 #include <qfile.h>
@@ -30,4 +32,6 @@
 #include <qintdict.h>
 
+#include <config.h>
+
 #include "album.h"
 #include "albumdb.h"
@@ -166,5 +170,14 @@ void AlbumManager::setLibraryPath(const 
 
     d->libraryPath = path;
-    d->db->setDBPath(path + "/digikam.db");
+
+    QString dbPath = path + "/digikam.db";
+
+#ifdef NFS_HACK
+    dbPath = locateLocal("appdata", KIO::encodeFileName(QDir::cleanDirPath(dbPath)));
+#endif
+
+    kdDebug() << "Album libray path set to " << dbPath << endl;
+    
+    d->db->setDBPath(dbPath);
 
     d->albumLister->openURL(path, true);

--- kdeextragear-3/digikam/kioslave/digikamio.cpp  #1.8:1.9
@@ -26,4 +26,6 @@
 #include <klargefile.h>
 #include <kglobal.h>
+#include <kstandarddirs.h>
+#include <kio/global.h>
 
 #include <qfile.h>
@@ -67,8 +69,13 @@ kio_digikamioProtocol::kio_digikamioProt
     m_libraryPath = QDir::cleanDirPath(m_libraryPath);
     
-    QString path = m_libraryPath + "/digikam.db";
+    QString dbPath = m_libraryPath + "/digikam.db";
+
+#ifdef NFS_HACK
+    dbPath = QDir::homeDirPath() + "/.kde/share/apps/digikam/"  +
+             KIO::encodeFileName(QDir::cleanDirPath(dbPath));
+#endif
     
     char *errMsg = 0;
-    m_db = sqlite_open(QFile::encodeName(path), 0, &errMsg);
+    m_db = sqlite_open(QFile::encodeName(dbPath), 0, &errMsg);
     if (m_db == 0)
     {

--- kdeextragear-3/digikam/kioslave/digikamtags.cpp  #1.11:1.12
@@ -25,4 +25,6 @@
 #include <klocale.h>
 #include <kglobal.h>
+#include <kstandarddirs.h>
+#include <kio/global.h>
 
 #include <qfile.h>
@@ -63,8 +65,14 @@ kio_digikamtagsProtocol::kio_digikamtags
     }
 
-    QString path = m_libraryPath + "/digikam.db";
+    QString dbPath = m_libraryPath + "/digikam.db";
+
+
+#ifdef NFS_HACK
+    dbPath = QDir::homeDirPath() + "/.kde/share/apps/digikam/"  +
+             KIO::encodeFileName(QDir::cleanDirPath(dbPath));
+#endif
     
     char *errMsg = 0;
-    m_db = sqlite_open(QFile::encodeName(path), 0, &errMsg);
+    m_db = sqlite_open(QFile::encodeName(dbPath), 0, &errMsg);
     if (m_db == 0)
     {