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

starting docker image with --autosave causes crontab.db to grow continuously #189

Closed
holygekko opened this issue Mar 6, 2022 · 7 comments · May be fixed by #224
Closed

starting docker image with --autosave causes crontab.db to grow continuously #189

holygekko opened this issue Mar 6, 2022 · 7 comments · May be fixed by #224
Labels

Comments

@holygekko
Copy link

holygekko commented Mar 6, 2022

I've created a fork with the only change being adding --autosave to command=node /crontab-ui/app.js in supervisord.conf
This way the crontabs get autostarted after a container restarts.

I noticed however that crontab.db keeps growing and growing. It continuously adds the same commands to the file. It got to 900mb in a two months.

What causes this and what can i do to prevent it?

@stale
Copy link

stale bot commented Sep 1, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Sep 1, 2022
@stale stale bot closed this as completed Sep 8, 2022
@rodriciru
Copy link
Contributor

It still happens...

@rodriciru
Copy link
Contributor

It turns out that it's not a bug, it's a desired behavior, but annoying and possibly causing some trouble.
Crontab-ui uses a database called nedb.
Apparently, it is much more "expensive" (in terms of time) to rewrite the entire database (which is a JSON) every time you do an update or a delete, than to add a line at the end of the file and then let the engine do what it has to do. The engine will compact the database when the app is restarted and that's it.
If you notice, if you reload the ui (with a F5) of crontab-ui, the database gets smaller.
But as I guess you don't get into the ui every 10 minutes, the engine has an option to auto compact the db every X milliseconds.
Just add db.persistence.setAutocompactionInterval(interval); on line 13 of crontab.js (just below var db = new Datastore({ filename: exports.crontab_db_file});) and the engine will compact the database every X milliseconds and you're done.

@rodriciru
Copy link
Contributor

Likewise all this is due to an infinite loop which is as follows:

  • Every time the database is modified in any way, node.js calls a method
  • That method, writes some files, runs the cron and does an update to the database
  • The database is modified and it starts all over again.

@alseambusher
Copy link
Owner

Interesting. Thanks for the investigation! I will fix this

@alseambusher alseambusher reopened this Oct 24, 2022
@stale stale bot removed the wontfix label Oct 24, 2022
@rodriciru
Copy link
Contributor

I create a PR about that issue
#214

@stale
Copy link

stale bot commented Jan 8, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jan 8, 2023
@stale stale bot closed this as completed Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants