Skip to content

Conversation

@Hell1213
Copy link
Contributor

@Hell1213 Hell1213 commented Jan 6, 2026

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.

Checklist

  • Ran npx prettier --write . (for formatting)
  • Ran gofmt -w . (for Go backend)
  • Ran npm test (for JS/TS testing)
  • Added unit tests, if applicable
  • Verified all tests pass
  • 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.

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.

Resolves CCExtractor#367
@github-actions
Copy link

github-actions bot commented Jan 6, 2026

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!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

documented new config options and persistent queue feature

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added required dependencies for bbolt and cron

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added required dependencies for bbolt and cron

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initialize maintenance worker on startup, clean integration

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

implemented simple cron worker for cleeanup,configurable schedule and retention

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comprehensive tests covering job lifecycle and cleanup

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added clean bbolt implementation with proper interface and error handling

Copy link
Contributor Author

@Hell1213 Hell1213 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR solves the job persistence issue cleanly. Jobs were getting lost on backend restarts, now they're saved to disk with bbolt and restored automatically. Added a maintenance worker to clean up old logs so disk doesn't fill up. Everything is configurable and backward compatible - existing code keeps working even if the database fails. Tested live and confirmed jobs survive restarts.

@Hell1213
Copy link
Contributor Author

Hell1213 commented Jan 6, 2026

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

@its-me-abhishek
Copy link
Collaborator

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

@@ -1,6 +1,6 @@
module ccsync_backend

go 1.19
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be skipped?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Go 1.23 bump is because bbolt v1.4.3 requires it. I can either downgrade bbolt to v1.3.7 (works with Go 1.19) or keep 1.23. Leaning towards downgrading to stay consistent with the codebase. any Thoughts?

func (mw *MaintenanceWorker) Start() error {
schedule := os.Getenv("CLEANUP_CRON_SCHEDULE")
if schedule == "" {
schedule = "0 0 * * *"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe provide some more context on these in form of comments and how to update it as well. what can be the other values for this?

Copy link
Contributor Author

@Hell1213 Hell1213 Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure , Added detailed comments explaining the cron format and example values. will push changes soon when complete change ready !

@Hell1213
Copy link
Contributor Author

Hell1213 commented Jan 12, 2026

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Persistent Job Queue & Maintenance Worker for backend

2 participants