Transaction Log after crash

Benjamin benjamincarlyle at optusnet.com.au
Thu Feb 12 08:52:31 CST 2004


G'day,

I've been periodically evaluating gnucash as an alternative to quicken for my 
home finances. I used to have several reasons for preferring quicken, but due 
to some simplification in my accounts I only have one left. That reason is 
the issue of how to manage a gnucash crash. I'll explain my gripe in detail 
below, but the crux of it is that I think the code is there but it's just the 
GUI that is lacking. I'd like to know whether anyone is working on it, any 
technical issues I might not have thought of, and whether anyone else thinks 
this would be a worthwhile feature.

Here is my use case:
1) Open gnucash account
2) Make some changes (without saving)
3) killall -SIGSEGV guile-1.6

If I do the same with quicken, it comes up with all my transactions (including 
the unsaved ones) still in my file. Nothing is lost, and there is nothing 
required to restore the unsaved data. Here is the procedure required in 
gnucash:

1) Start gnucash again.
Gnucash says that it can't get a lock for my file. It wants to know whether to 
quit, open anyway, or create a copy. I don't want it to do any of those 
things, so I go to 2)
2) Manually delete myfile.LCK
3) Close and restart gnucash.
Gnucash comes up ok, now, but is missing my unsaved transactions
4) File -> Import -> Replay gnucash .log file
The open dialogue places me in my home area, instead of where my accounts file 
is. I navigate to the accounts file location. I see the following files:
myfile
myfile.20040207000036.log
myfile.20040207000223.log
myfile.20040208230628.log
myfile.20040208230928.xac
myfile.20040213002043.log
myfile.LCK
myfile.a8c01e69.3753.LNK
myfile.a8c01e69.3769.LNK
5) Choose myfile.20040213002043.log
At this point I see nothing happen at all! :)
The account totals don't update. I only realise that the log has been applied 
when I open the account I expected to change and find the new transactions 
already there. I don't know of any way to update the account totals, apart 
from closing and reopening the file (hoping this isn't a sign of 
corruption ;)

So.

The two main problems I see in this are the LCK file management and the 
selection of the log... I'll treat the account balances not updating as an 
out-and-out bug for the purposes of this email :) The LCK file's existence 
doesn't imply a living gnucash process, and the name of the log file is 
obscure, especially among a large set of similarly-named files. Is the reason 
an OS lock isn't used for the LCK something to do with antiquated NFS 
implementations that don't support locking? Is there some assistance you 
could give the user in both finding that they need to import the log and 
finding the file?

Anyway, here is my proposal:
* Write the name of the log file into the LCK file, or use the LCK as your log 
file
* Lock the LCK file with a real OS lock so that you can ask the OS if the file 
is still locked. An OS lock will go away if your process crashes, but a file 
will not.
* On startup, check the existence and lock of the LCK file. If one exists and 
is unlocked, lock it and ask the user if they want to reapply the 
transactions from the data the LCK file refers to.

I suggest text like "The previous session of gnucash appears to have 
terminated prematurely. Some transactions you entered after your last save 
are still available, saved separately to the main file. Restoring the 
transactions will not affect your main file until your next save, and if you 
decide you don't want them you can exit without saving. Do you want to 
restore them?" or maybe something as simple as "Restore unsaved transactions 
from previous session? You should usually answer 'yes'.". You could supliment 
the short form with an "Tell me more..." button with more complete 
explaintory text. You'd still want to allow the option to say 'no', primarily 
for the case where restoring the transactions is what causes the crash :)

At the very least, if everything else stays the same, I'd like to see the 
"I've just found a LCK file with no lock on it" event cause gnucash to guide 
the user step-by-step through the recovery process.

I can live with crashes. Every application has them I've certainly seen them 
with quicken and gnucash alike. I can live with having to press the save 
button to create a fresh XML file every time I exit the application. I can 
live with slow startup times (quicken under wine takes longer!). I just need 
to know that I'm going to be able to get at my unsaved (but logged) data when 
gnucash does crash, and I need to be able to explain the procedure to my wife 
over the phone when she calls me up saying "gnucash crashed and I had just 
entered all my receipts!" "No! I hadn't saved, yet. I was just looking 
through the graphs first."

So, is anyone looking at this? Would it be worth me looking at this? I'm a 
programmer, but haven't ever used gtk nor programmed in scheme. Have I missed 
something vital? Thoughts, anyone?

Benjamin.


More information about the gnucash-user mailing list