.gnucash file corruption

Roger Flores aidembb at yahoo.com
Tue Feb 21 00:55:03 EST 2017


Hello, I'm a new user that recently had a problem with GnuCash corrupting my set of books.  The quick summary is I wasted a lot of time understanding why GnuCash was no longer letting me work, I then restored an older save of the accounts, and then manually redid all the missing transactions.  It was worrisome and painful and I hope that's the only time it happens to me.

What happened:

GnuCash 2.6.12 on Windows 10

I started GnuCash after not using it for a few weeks.  When it started loading the accounts it stopped and displayed an alert reporting "No Suitable backend was found for file".  Googling for this message reveals a lot of people with problems and few solutions.  I tried opening the previous autosave but GnuCash again reported the same problem.  Both files were the appropriate sizes and there were log files.  The older log was 0 bytes though.

I did not understand how the backend could have changed or stop working.  To hopefully fix I updated to the current software, 2.6.15.  The accounts still would not open.  To rule out a problem with the installation or Windows, I installed GnuCash on a second computer, copied over the files and tried again.  The same backed error message appeared.  That meant to me it was a data problem.

I looked at the last .gnucash file in a hex dump and found it entirely comprised of zero bytes!  The problem wasn't the "no suitable backend" reported but rather a data corruption problem.  The misleading message had sent me on an unproductive chase.  I think that GnuCash should detect corrupted files and report that instead of the current behaviour.


With the problem understood, the solution now was to find the last valid autosave and reapply the log files.  The second oldest file was also all zeros, but a slightly smaller amount.  The third oldest autosave seemed fine, but it really isn't possible to tell, since there is no corruption detection.  

The log file to apply to the third oldest autosave was empty.  I applied it anyways.  I then applied the next log file and GnuCash crashed without warning.  Looking inside the file and it looked reasonable.  I tried again and GnuCash crashed again.  This game of finding valid autosaves and log files and applying them in the right order is really not fun to play.  It should be automated.

IMO some simple things could be done to make data corruption problems much less troublesome.  GnuCash should be able to detect corruption of both .gnucash and .log files.  It can be a CRC/hash in a simple wrapper/container format so the exisiting file formats do not change.  Whatever works.

Additionally, I believe when a file opened is determined to be corrupt, GnuCash, and not the user should automatically find the last valid file and apply the valid log files in the appropriate order.  In some sense, it's very much like applying Git changes.  GnuCash users are good at entering transactions, not finding valid saves and applying log files in the right order.  Crashes/corruption happen, they'll never be 100% avoided.  To me, it's the recovery that's the painful part.

I hope explains what I went through and helps shorten the mystery for others searching.  Thanks for listening.





More information about the gnucash-user mailing list