Menu

#192 Autosave

open
nobody
Others (41)
5
2013-01-09
2011-04-12
Marcus
No

Rachota is a really nice time tracker but when used in the real world it is near unusable as it keeps losing data. Whenever either Rachota or Windows crashes the data of that day are lost. But it does not take a crash. Just logging out of Windows without explicitly saving will lose that days data.

Many of the stability issues would not matter so much if Rachota had an autosave feature. For example, it could save its state every five minutes or so.

Discussion

  • Jiri Kovalsky

    Jiri Kovalsky - 2011-04-15

    Marcus, this is also strange. Rachota of course has a backup system. By default Rachota creates backup_diary.xml file every 30 seconds. This file should contain almost identical data as your current diary. Can you please make sure such file exists in your user directory? Besides, Rachota supports downtime measurement which means that if you kill Rachota or your computer shuts down without prior exiting Rachota normally, next time you launch it Rachota asks if you want to add the time when it was not running to the last task.

    For more info on switching settings see here: http://rachota.sourceforge.net/en/faq.html#4

     
  • Marcus

    Marcus - 2011-04-15

    I do have a backup_diary.xml but it was last saved on October 13th, 2010.

    I also did check the settings.cfg to make sure that savingPeriod is set to 30.

    After exiting Rachota abnormally, I have never been asked whether to add time.

     
  • Jiri Kovalsky

    Jiri Kovalsky - 2011-04-15

    I cannot believe it. :( What output do you get if you type "java -version" into the console? And is the behaviour same with the latest build of Rachota 2.4?

     
  • Marcus

    Marcus - 2011-04-15

    When I type "jave -version" I get the following:

    java version "1.6.0_24"
    Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
    Java HotSpot(TM) Client VM (build 19.1-b02, mixed mode, sharing)

    I also just tried it with Rachota 2.4. When I log out and then back in all of the data not explicitly saved are lost. The backup_diary.xml is still unchanged. I am going to attach two screenshots, one before and one after the logout/login procedure.

     
  • Marcus

    Marcus - 2011-04-15

    Before logout/login

     
  • Marcus

    Marcus - 2011-04-15

    After logout/login

     
  • Jiri Kovalsky

    Jiri Kovalsky - 2011-04-15

    And can you create a brand new directory (e.g. C:\rachota\new), copy rachota_24.jar to that directory and launch it from that directory?

    C:\>cd C:\rachota\new [Enter]
    C:\rachota\new>java -jar rachota_24.jar [Enter]

    Now create new "Test" task and start it. Does Rachota still not record "Started at:" time? Then click "System > Exit", confirm that you want to exit and confirm that you want to measure the time while Rachota will not be running. Then launch it again. Does Rachota asks you whether some seconds should be added to "Test" task?

     
  • Marcus

    Marcus - 2011-04-15

    I just did what you asked me to and it worked.

    Should I see a backup_diary.xml?

     
  • Jiri Kovalsky

    Jiri Kovalsky - 2011-04-15

    Yes, the C:\rachota\new directory should contain the following files:

    diary.dtd
    diary_2011_15.xml
    rachota_24.jar
    settings.cfg

    plus lock.tmp while Rachota is running. What's your content of the C:\rachota\new directory?

     
  • Jiri Kovalsky

    Jiri Kovalsky - 2011-04-15

    Oh, now I realized that I gave you incorrect switch. The diary_backup.xml shows up after 10 minutes by default so if you want to see it sooner, change value of backupAge setting from 10 to 1. Launch Rachota and wait 1 minute until the backup is created. Then exit Rachota, corrupt the diary_2011_15.xml file e.g. remove first line and change <week to <wek and launch Rachota again. It will detect the problem and offer you possibility to use the backup data.

    Can you confirm this?

     
  • Alex

    Alex - 2012-09-11

    Rachota regularly loses data for me. After a crash (my video card seems to work badly) the diary file, and sometimes also the backup file, are frequently empty. This is my theory:
    - Rachota opens and truncates the diary file (ordinary or backup). This is a simple update to FS metadata, and with my OS and FS (FreeBSD and ufs) this seems to get to the disk quickly.
    - Rachota writes the new contents and closes the file. It doesn't call fsync(), so the new data goes to the OS buffer but not yet to disk.
    - When the system crashes only the empty file remains.
    - Rachota rewrites the file very frequently, and the more frequently it does so the more likely the data is to still be in OS cache and not the disk.....so Rachota is very likely to lose data in a crash.

    The quick fix (I'm trying this out, I haven't had a crash yet):
    call fos.getFD().sync(); in Plan.saveWeek(), where fos is the FileOutputStream.

    The correct fix:
    - write the new data to a second temporary file
    - fsync the second file
    - rename the new file to the correct diary file name

     
  • Jiri Kovalsky

    Jiri Kovalsky - 2012-09-12

    Thanks for your comment Alex. If you test the fix fully, please attach it here and I will integrate it. I am afraid I am too busy to find some time for it now. Thank you!

     
  • Alex

    Alex - 2012-11-22

    No lost data despite several crashes. There's still a possible window for it to happen, but it's much smaller with this patch. It looks like I can't attach files, so here it is (from 'cvs diff'):

    Index: src/org/cesilko/rachota/core/Plan.java

    RCS file: /cvsroot/rachota/rachota/src/org/cesilko/rachota/core/Plan.java,v
    retrieving revision 1.25
    diff -u -r1.25 Plan.java
    --- src/org/cesilko/rachota/core/Plan.java 7 Jan 2011 15:07:44 -0000 1.25
    +++ src/org/cesilko/rachota/core/Plan.java 22 Nov 2012 14:09:44 -0000
    @@ -281,7 +281,8 @@
    else location = location + File.separator + "diary_" + year + "_" + week + ".xml";
    try {
    String encoding = (String) Settings.getDefault().getSetting("systemEncoding");
    - PrintStream stream = new PrintStream(new BufferedOutputStream(new FileOutputStream(location)), true, encoding);
    + FileOutputStream fos = new FileOutputStream(location);
    + PrintStream stream = new PrintStream(new BufferedOutputStream(fos), true, encoding);
    stream.println("<?xml version=\"1.0\" encoding=\"" + encoding + "\"?>");
    stream.println("<!--");
    stream.println(" Rachota 2.1 diary file - editing not recommended");
    @@ -298,6 +299,7 @@
    }
    stream.println("</week>");
    stream.flush();
    + fos.getFD().sync();
    stream.close();
    } catch (IOException e) {
    JOptionPane.showMessageDialog(null, Translator.getTranslation("ERROR.WRITE_ERROR", new String[] {location}), Translator.getTranslation("ERROR.ERROR_TITLE"), JOptionPane.ERROR_MESSAGE);

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.