Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database keeps clearing out for some unknown reason. #443

Closed
ghost opened this issue Jan 23, 2024 · 3 comments
Closed

Database keeps clearing out for some unknown reason. #443

ghost opened this issue Jan 23, 2024 · 3 comments
Labels
question Further information is requested

Comments

@ghost
Copy link

ghost commented Jan 23, 2024

I'm running a local server in Python 3.10 I've have my records for the month cleared out two times now. I don't know exactly what causes it. I'm on a guest account on localhost. This time it happened I did the following.

  1. Had many records for the month
  2. I accidently opened up a second tab to the timetagger page on localhost while one was clocking some time
  3. I stopped the clock on one of the tabs
  4. I refreshed one of the tabs
  5. I closed out one of the tabs, the data on the still open tab still had my records.
  6. I put the computer to sleep
  7. Woke the computer up the next day and the timetagger server was no longer running on wakeup and it looked like the page had gotten to a login page before the server closed. I assume that happened in the process of putting the computer to sleep the day before.

How do I keep timetagger from totally erasing my database lol. Now I'm guessing how much time I spent.

@almarklein
Copy link
Owner

almarklein commented Jan 24, 2024

@cherrerajobs I can understand that this is very annoying. From what you explain in your post I don't see an obvious reason of what's going on, but I can give a view pointers to check.

The server losing it's records is very strange. There is no logic in the server where it e.g. deletes a database. This means that either the database got deleted by something else, or it never stored the records in the first place.

The browser application stores all records locally, this is so that when your wifi is down, you can just keep tracking, and when the wifi connection is up again, it will sync all changes to the browser. However, all this local data is deleted when you log out or clear your browser cache.

  • If you are running the server in a Docker container, you have to make sure to map the directory containing the databases to a directory on the host system. Otherwise all is lost when the container restarts.
  • If you are running the timetagger server locally, with Python on your machine, be aware that the directory where the databases are stored is writable by the process, and is not a temporary directory. Linux clears its temp dirs on each reboot.
  • You could check the database file, and see if it changes size when you create a new record
  • And finally, in the browser app, make sure that the sync icon next to the menu-icon does not show an error. Otherwise the changes you make never reach the server and get deleted when logging out.

I hope this helps you resolve your problem.


image

Sync icon indicating a connection problem. You can click it to get more details.

@almarklein almarklein added the question Further information is requested label Jan 24, 2024
@ghost
Copy link
Author

ghost commented Jan 25, 2024

Thank you for the quick response.

I did notice that error indicator periodically actually, I didn't realise I could click it, I would hover over it but nothing would show. A cursor: pointer style would be a nice addition there for desktop. This was on Windows by the way.

I think the browser cache explains it as I would periodically close and restart my browser and even open up new tabs to the local timetagger server and it would fetch all the records I had created without a hitch. My .db file hasn't been updated since December 15th 2023 though.

I can confirm it's a caching confusion as I can load the timetagger app on the browser but not on a private browser/tab (The server is not actually running).

So what REALLY happened was:

  1. I (thought I) started Timetagger
  2. Recorded many records over time without the server even running.
  3. Restarted the computer and went to the url of the local server
  4. Timetagger loads up normally so I assume it's all working. Meanwhile the little error indicator is trying to tell me it can't connect to the server because it's not actually running
  5. Eventually clearing out the browser cache destroys the local cache.

Knowing that I now have the understanding so that it won't happen again.

I think the following information box can be even more useful if it explained a little bit more about local browser caching and the server:

image

Or if the error message did instead:
image

I'm sure I missed all this info in my eagerness to get it all up and running. Thanks again.

Edit: Actually starting the server and placing an entry now correctly saves the content to the .db file.

@almarklein
Copy link
Owner

Glad that it's now clear what happened. Yet I understand it frustrating to lose your data this way. I made #444 that includes your suggestion to make things more clear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant