[GNC] Unexpected behaviour of locking mechanis

John Ralls jralls at ceridwen.us
Sat Apr 20 17:34:34 EDT 2019


Colin,

Maybe a problem with your book. I just did the same exercise (stepping in the debugger to make sure that everything was getting called in the right places, it is) and didn't get any such errors.

Regards,
John Ralls


> On Apr 20, 2019, at 8:49 AM, Colin Law <clanlaw at gmail.com> wrote:
> 
> I thought I would try this with 3.5 on Ubuntu 18.10.  Using Save As
> repeatedly to sqlite3 does not result in locked files. I can go back
> and open the previous versions without issue.
> 
> However, when saving to sqlite, which I don't normally, I do see in
> the trace file
> * 16:43:29 ERROR <gnc.backend.dbi> [error_handler()] DBI error: 19:
> UNIQUE constraint failed: books.guid
> * 16:43:29 ERROR <gnc.backend.dbi>
> [GncDbiSqlConnection::execute_nonselect_statement()] Error executing
> SQL INSERT INTO books(guid,root_account_guid,root_template_guid)
> VALUES('2e45bf75396f1f5d2c459c4bb687b8da','f70697860ee4e46e92997a700eb37f1c','b4415e84471d47e166dd9d00f5293faf')
> * 16:43:29 ERROR <gnc.backend.sql>
> [GncSqlBackend::execute_nonselect_statement()] SQL error: INSERT INTO
> books(guid,root_account_guid,root_template_guid)
> VALUES('2e45bf75396f1f5d2c459c4bb687b8da','f70697860ee4e46e92997a700eb37f1c','b4415e84471d47e166dd9d00f5293faf')
> * 16:43:29 ERROR <qof.engine> [commit_err()] Failed to commit: 17
> 
> Whether that is a serious issue I don't know.
> 
> Colin
> 
> On Sat, 20 Apr 2019 at 16:20, mc <mc8 at privmgt.com> wrote:
>> 
>> Thanks John
>> 
>> The SQL locks are in a table inside the database, not in a separate file"
>> That would mean there is one for each gnucash file.  Good to know.
>> 
>> "How are you creating these "earlier saved versions""
>> Just with "save as".
>> Then I do some more changes, then do another "save as" with a higher
>> version number.
>> So in one long session, I may have several earlier versions with diff
>> version numbers.
>> 
>> eg:
>> Lets call the files I have created in the session v0, v1, v2, v3.
>> I initially open v0, then (say) 1 hour later do save as v1,
>> another hour later save as v2, later save as v3, etc.
>> 
>> So the likely answer is:
>> as the lock is inside the database,
>> doing a new "Save As" to create v1
>> doesn't release the lock on the older, now superseded v0.
>> Then save as v2, doesnt release the lock on v1, etc.
>> So at the end of the session, I quit while v3 is open,
>> and only the lock on v3 is released.
>> 
>> But, v0, v1, v2 all still have locks inside their database.
>> 
>> So "save as" doesnt release locks on earlier versions used in the session,
>> Also, "Quit" also only releases the lock on the current file,
>> not the earlier versions used in this session.
>> 
>> So to release the locks
>> (if that were useful)
>> would have to go back and open, then Quit from each earlier version.
>> 
>> Thanks for your guidance.
>> 
>> mc
>> 
>> 
>> On 20/04/2019 22.53, John Ralls wrote:
>>> 
>>>> On Apr 20, 2019, at 5:58 AM, mc <mc8 at privmgt.com> wrote:
>>>> 
>>>> Config:
>>>> gnucash 3.5 clean install.
>>>> (X)ubuntu Linux 18.04
>>>> gnucash files saved as sqlite.
>>>> 
>>>> Am new to gnucash and testing it.
>>>> 
>>>> I keep several versions of a gnucash file,
>>>> saved with names like <file>-<date>-<id>.gnucash
>>>> 
>>>> After cleanly exiting gnucash by a normal Quit,,
>>>> I may try to open an earlier saved version.
>>>> I frequently get the message:
>>>> 
>>>> GnuCash could not obtain a lock for .../<filename>.gnucash
>>>> the database may be in use by another user, in which case you should not open the database.
>>>> What would you like to do?
>>>> open read only / create new file / open anyway / quit
>>>> 
>>>> I have checked that gnucash is not running,
>>>> and there is no lock file to be found.
>>>> I open it anyway, and it is without problems,
>>>> other than my tabs have disappeared and there is only the default "Accounts" tab.
>>>> 
>>>> In fact there is no .LCK file even when gnucash has a file opened.
>>>> 
>>>> So:
>>>> a.  has gnucash changed the locking mechanism in v3
>>>> or do sqlite files not use a locking mechanism?
>>>> 
>>>> b.  is there a possible issue with this locking mechanism?
>>> The SQL locks are in a table inside the database, not in a separate file. The file will be locked if you didn't properly quit GnuCash the last time you had *that file* open.
>>> 
>>> The locking mechanism itself hasn't changed, but the SQL/DBI backend got a complete rewrite into C++ for GnuCash 3.x.
>>> 
>>> It's a computer program. Of course it's possible that there's a problem, and since you're doing something a bit different from what everyone else does you might be the first to have found it. How are you creating these "earlier saved versions"?
>>> 
>>> Regards,
>>> John Ralls
>>> 
>> 
>> _______________________________________________
>> gnucash-user mailing list
>> gnucash-user at gnucash.org
>> To update your subscription preferences or to unsubscribe:
>> https://lists.gnucash.org/mailman/listinfo/gnucash-user
>> If you are using Nabble or Gmane, please see https://wiki.gnucash.org/wiki/Mailing_Lists for more information.
>> -----
>> Please remember to CC this list on all your replies.
>> You can do this by using Reply-To-List or Reply-All.



More information about the gnucash-user mailing list