file locking for single user, multiple gnucash?

Geert Janssens janssens-geert at telenet.be
Mon May 12 17:55:12 EDT 2014


On Monday 12 May 2014 17:07:59 incoming-gnucash at sabot.com wrote:
> I understand how file locking works when you have two different users
> that are each trying to open the same gnucash file: the first to open
> the file succeeds and place a lock file in the directory, and second
> is told it is busy and offered read-only access.  Everything works
> great.  I'd like to ask about a different scenario.
> 
> I'm a single user, and I have two gnucash files I want to work with.
> One is personal, one is business.  As far as I can tell, I can go to a
> shell and run gnucash on the personal file, and then go to a
> different shell and run gnucash on the other file, and I get no
> complaints: both open up fine.
> 
> Ideally, I'd like to use the files like that: open both up, and leave
> them up all day, using and clicking save as convenient.  This would
> be more convenient and faster than repeatedly closing/browsing to the
> other file/re-opening.
> 
> However, I think this might be a bad idea: the two runs seem to be
> sharing access to some files in the .gnucash directory though I'm not
> 100% sure what they all are:
> 
>   1. saved-reports-2.4: my custom reports, updated only if I change a
> report

This file is read into memory when gnucash starts and completely 
rewritten when you save a report configuration. So you assumption is 
correct here.
> 
>   2. qif-accounts-map:  updated after I do a qif import?

This one I don't know because I don't use it.
> 
>   3. accelerator-map:   custom keyboard shortcuts, mine is empty but
> has a new timestamp so update might not be under my control
> 
This file is loaded when gnucash is started and written when gnucash is 
closed. In between it is not used (and not kept open either). So the 
last gnucash instance to close will write it. However the info in here 
is probably never going to change so opening two gnucash instances won't 
hurt here.

>   4. stylesheets-2.0:   ?
> 
Same as with saved-reports-2.4, but it it written when you save changes 
to a stylesheet.

>   5. expressions-2.0:   ?
> 
I'm not sure what this file is about (mine is empty) but I expect it to 
behave the same way as saved-reports-2.4 with regards to when it's being 
read/written.

>   6. .gnucash/books/*.gcm: files about my tab setup, based on gnucash
> file name so those seem safe/no collision possible.
> 
This is indeed one metadata file per data file you have. These are 
clearly separated.

>   7. Others?
> 
None that I can think of.

> For 1 and 2, likely I can control my usage well enough to not get into
> trouble, only having one open if I ever want to save some reports or
> do qif importing.  And if I screw up, hopefully the symptom would be
> whichever gnucash saved out last would be saving its stale view of
> the world (plus its change), overwriting the newer file system copy
> left by the other copy of gnucash.  The file would not be corrupt; I
> would just be missing some newish custom report or qif mapping.
> 
> For the others, I'm not clear on what might happen!
> 
> So in summation: is it safe to be a single user and open up two
> different gnucash files at the same time?
> 
Aside from the potential conflict in saved-reports and stylesheets there 
is no issue IMO. The conflict won't result in corrupt data, but you may 
overwrite changes made from the other data file.

I'm regularly running two instances of gnucash at the same time and 
never experienced problems.

Geert


More information about the gnucash-user mailing list