ccsync icon indicating copy to clipboard operation
ccsync copied to clipboard

feat: implement persistent job queue with bbolt and maintenance worker

Open Hell1213 opened this issue 10 months ago • 13 comments

The current job queue was volatile and jobs would be lost on backend restarts. This implements a bbolt-based persistent queue that stores jobs to disk and restores them on startup. Also added a cron-based maintenance worker that automatically cleans up old completed and failed job logs to prevent unbounded disk usage. All existing functionality is preserved and the new features are fully configurable via environment variables.

Description

Added persistent job queue using bbolt database to store jobs on disk. Jobs now survive backend restarts and are automatically restored on startup. Implemented maintenance worker with cron scheduler to clean up old job logs and prevent disk usage issues.

  • Fixes: #367

Checklist

  • [x] Ran npx prettier --write . (for formatting)
  • [x] Ran gofmt -w . (for Go backend)
  • [x] Ran npm test (for JS/TS testing)
  • [x] Added unit tests, if applicable
  • [x] Verified all tests pass
  • [x] Updated documentation, if needed

Terminal Screenshot Screenshot from 2026-01-06 00-44-17

Additional Notes

New environment variables added for configuration:

  • CLEANUP_CRON_SCHEDULE - Schedule for maintenance worker (default: daily at midnight)
  • CLEANUP_RETENTION_DAYS - How long to keep job logs (default: 7 days)
  • QUEUE_DB_PATH - Database file location (default: /app/data/queue.db)

The implementation gracefully falls back to in-memory queue if persistent storage fails, ensuring no breaking changes.

Hell1213 avatar Jan 06 '26 06:01 Hell1213

Thank you for opening this PR!

Before a maintainer takes a look, it would be really helpful if you could walk through your changes using GitHub's review tools.

Please take a moment to:

  • Check the "Files changed" tab
  • Leave comments on any lines for functions, comments, etc. that are important, non-obvious, or may need attention
  • Clarify decisions you made or areas you might be unsure about and/or any future updates being considered.
  • Finally, submit all the comments!

More information on how to conduct a self review: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/reviewing-proposed-changes-in-a-pull-request

This helps make the review process smoother and gives us a clearer understanding of your thought process.

Once you've added your self-review, we'll continue from our side. Thank you!

github-actions[bot] avatar Jan 06 '26 06:01 github-actions[bot]

hey @its-me-abhishek , PR is ready for Review , open to any further changes required.

Hell1213 avatar Jan 06 '26 19:01 Hell1213

@Hell1213, the implementation looks great. will review it once locally first and then here.

its-me-abhishek avatar Jan 07 '26 17:01 its-me-abhishek

Hey @its-me-abhishek, should we keep Go 1.23 or downgrade bbolt to v1.3.7 (works with Go 1.19)? The Go 1.23 bump is because bbolt v1.4.3 requires it - the link you mentioned in the issue points to use bbolt v1.4.3.

Hell1213 avatar Jan 12 '26 15:01 Hell1213

hey @its-me-abhishek , I have downgraded bbolt to v1.3.7 to keep Go 1.19 consistent with the main app. Also added cron schedule comments, pls take a look when you got time .

Hell1213 avatar Jan 15 '26 06:01 Hell1213

hey @its-me-abhishek ,pls check the pr ,its ready I have implemented those changes as requested

Hell1213 avatar Jan 17 '26 19:01 Hell1213

@Hell1213 there seems to be some misunderstanding, please do add those updated creds to production/example.backend.env and the related Docs to production/README along with their default values. Since that is the ideal way to run the backend.

Additionally, just checked that this PR will probably require to update the Kubernetes config, as well, in order to keep that working

its-me-abhishek avatar Jan 17 '26 19:01 its-me-abhishek

@Hell1213 there seems to be some misunderstanding, please do add those updated creds to production/example.backend.env and the related Docs to production/README along with their default values. Since that is the ideal way to run the backend.

Additionally, just checked that this PR will probably require to update the Kubernetes config, as well, in order to keep that working

thanks , apologies for misunderstanding ,I'm on it will make those changes as told .

Hell1213 avatar Jan 17 '26 19:01 Hell1213

hey @its-me-abhishek , i have pushed changes as needed pls take a look ,open to make any required changes

Hell1213 avatar Jan 18 '26 19:01 Hell1213

hey @its-me-abhishek , plss take a look when you get time , I have resolved conflicts .

Hell1213 avatar Jan 24 '26 09:01 Hell1213

hey @its-me-abhishek , if you have some time pls take a look at #375 , this must the correct solution accordingly as we discussed , but in case any chnages needed im open to make changes . thanks

Hell1213 avatar Feb 04 '26 13:02 Hell1213

@Hell1213 apologies for the delay on this PR but this requires somewhat more testing on my end since it touches both Docker, Kubernetes. Just need to test how much space is being required in order to store jobs as well. Moreover have to look into the tradeoffs, of adding more environment vars. Can mark this as draft, for the time being.

its-me-abhishek avatar Feb 04 '26 13:02 its-me-abhishek

sure , no worries at all , that make sense for now I'll mark this as draft .

Hell1213 avatar Feb 04 '26 16:02 Hell1213