PGN database zeroised - is this a bug?

Get your specific HIARCS/Junior support questions answered here as well as up-to-the-minute news!

Moderators: Watchman, Mark Uniacke, mrudolf

Post Reply
xerxes
Member
Posts: 10
Joined: Sat Jun 22, 2013 12:58 pm

PGN database zeroised - is this a bug?

Post by xerxes »

I hibernated my laptop leaving HIARCS running with my games database open. When I started up again, I forgot to switch on the mains power, and as the battery is nearly dead it didn't have enough power to close down Windows properly before it died.

On starting up again (with power this time!), I found that my games database would not open in HIARCS. Opening it with a binary editor showed that it had been completely zeroised, i.e. every single byte was a null code. The PGN file size was as expected, i.e. the same as before the problem occurred. Its 'last modified' date was set to the time of the aborted start-up.

Fortunately I back it up regularly so only lost the last few games.
User avatar
Mark Uniacke
Hiarcs Author
Posts: 1458
Joined: Sun Jul 29, 2007 1:32 pm
Location: United Kingdom
Contact:

Post by Mark Uniacke »

I do not see how HCE could do this.

When an existing database is saved, the database is written to a *different* file name (<database-filename><randomchars>.pgn in the Databases folder). You could check there to see if such a file still exists and is of the size you expect.

Once the database is correctly saved, the previous database is removed and the new saved database is renamed to the correct database name. At no time is the existing database zero'd and no such code exists in HCE to do that.

Are you encountering other issues on your machine?

You should check your disk file system is consistent.
Best wishes,
Mark

https://www.hiarcs.com
xerxes
Member
Posts: 10
Joined: Sat Jun 22, 2013 12:58 pm

Post by xerxes »

Thanks for your reply. I suspect that what has happened is that power has failed to the memory containing the file image whilst, or just before, the image was actually being written to disk.

There is no temporary file in the database folder, and I have never seen one appear, though presumably it only exists for a very short time.

One thing I have noticed, though, is when I click the 'Save' icon, it doesn't actually save the amended file to the file system (according to the 'Date Modified' field) - this only seems to happen when exiting the program. Would it be safer if the file was actually rewritten at the time the Save button is pressed? Otherwise changes could be lost if the program is aborted for some reason, e.g. system crash.
User avatar
Mark Uniacke
Hiarcs Author
Posts: 1458
Joined: Sun Jul 29, 2007 1:32 pm
Location: United Kingdom
Contact:

Post by Mark Uniacke »

PGN files are sequential and can be huge and so writing them to disk every time a game or attribute changes would be very inefficient.

HCE has an auto save setting which is adjustable in preferences which determines how often it saves to disk a modified database.

When a database is closed it is always saved to disk if changes have been made.
Best wishes,
Mark

https://www.hiarcs.com
Post Reply