GNOME Bugzilla – Bug 629238
Need database locking for sqlite/mysql/postgresql
Last modified: 2018-06-29 22:44:29 UTC
Gnucash 2.3.x and also 2.4.0 will in no way be multi-user enabled. Instead, each time more than one user (or: more than one instance of gnucash) accesses the same database backend, data loss will occurr almost inevitably. To prevent that, for XML files we create an extra lock file and display a big red warning sign in case it already exists. Because of the non-existence of multi-user capabilities, we *must* ship with a similar database lock in case the backend is not XML but sqlite3 or mysql or postgresql (depending on the available dbi drivers). I've asked this before, and the conclusion was that a lock on the full database is probably easiest and also sufficient. This bug reminds that we need such a database locking. http://lists.gnucash.org/pipermail/gnucash-devel/2010-August/029177.html https://lists.gnucash.org/pipermail/gnucash-devel/2010-May/028421.html
AFAICT, locking is generally transaction-based in SQL databases. This makes sense considering that they're generally designed to be multi-user. Since that's apparently not the way we're using the database backend at the moment, I propose that we add a lock table with a single row. Is there any reason that this wouldn't work?
r19738 implements the lock table for PostgresQL and MySQL. I had some concerns about that approach working with SQLite, so I tested multiple access with it and it worked out OK. r19739 adds the lock table function to SQLite initialization as well.
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=629238. Please update any external references or bookmarks.