Ticket #1660 (closed Discussion: invalid)
Unbounded data loss if Jajuk crashes?
|Reported by:||mats.ahlgren@…||Owned by:||bflorat|
I think it is possible that, if Jajuk crashes, all song preferences/ratings and statistics since the last program-open (e.g all pref changes in the last week) will be lost?
If this is true, suggested priority=major, and suggested solution is to edit the database after every operation. (This may not work well if the database is >30MB and there is no way to edit it in-place without resaving it all; also editing in-place is dangerous due to possible bugs that might creep up, unless the java-based XML library you guys are using has support for it.)
Perhaps provide an option "autosave database every N minutes"?
Or if you can make all changes be idempotent, you could just make a log of changes that can be replayed?
e.g. say you want to change a Smiley from =\ to =)
Instead of doing something like inMemoryXmlDatabase.change(...), you would do log.append("[logobject; time=[datetime object of now], action=[inMemoryXmlDatabase.change(...)]"). If you crash, then load all the logs since the last "Successfully synced to database" log entry and replay all those items in *sorted* order on the in-memory database, then resave the database (after making a backup), then make a "Successfully synced to database" log entry.
(Example of an operation that would not be idempotence: "increase hits by +1" (because if you replayed it twice, it would give a different result (+2) than if you replayed it once). Example of making it idempotent: "set hits to "+(getHits()+1))