Conversation
|
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:
More information on how to conduct a self review: 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! |
There was a problem hiding this comment.
added required dependencies for bbolt and cron
There was a problem hiding this comment.
added required dependencies for bbolt and cron
Hell1213
left a comment
There was a problem hiding this comment.
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.
|
hey @its-me-abhishek , PR is ready for Review , open to any further changes required. |
|
@Hell1213, the implementation looks great. will review it once locally first and then here. |
|
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. |
95da0ee to
de09939
Compare
|
hey @its-me-abhishek , |
|
hey @its-me-abhishek ,pls check the pr ,its ready I have implemented those changes as requested |
|
@Hell1213 there seems to be some misunderstanding, please do add those updated creds to 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 . |
3715a97 to
546cf7c
Compare
|
hey @its-me-abhishek , i have pushed changes as needed pls take a look ,open to make any required changes |
546cf7c to
46cb216
Compare
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
Fixed job restoration to prevent duplicates and added queue environment variables to production files for Docker/Kubernetes deployments.
46cb216 to
24d32f8
Compare
|
hey @its-me-abhishek , plss take a look when you get time , I have resolved conflicts . |
|
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 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. |
|
sure , no worries at all , that make sense for now I'll mark this as draft . |
|
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:
More information on how to conduct a self review: 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! |
|
hey @its-me-abhishek long time no see here we go again can you pls let me know if this pr needs any changes or they were just old changes you requested which i fixed already in /utils pls let me know . |
its-me-abhishek
left a comment
There was a problem hiding this comment.
Got this from Copilot (added a few pointers as well, please check):
Review — PR #375
Recommendation: Request changes. CI passes, but the persistence implementation does not preserve or resume actual jobs and can cause queued operations to be silently lost.
Findings
1. Critical — Persisted jobs are never marked completed or failed
backend/controllers/job_queue.go:53-70
AddJob generates a persistent UUID and stores the job as pending, but that UUID is not attached to the in-memory Job. processJobs therefore has no way to call UpdateJobState.
As a result, every successfully executed or failed job remains in the pending bucket indefinitely. The maintenance worker only cleans completed and failed buckets, so these records are never removed.
This also means every pending record is restored after every restart.
Fix: Keep the persistent job ID with the runtime job and transition it atomically/appropriately:
pending→inprogressbefore executioninprogress→completedafter successinprogress→failedafter failure
The runtime Job likely needs a persistent ID field, or AddJob needs to return the created ID.
2. Blocker — Restored jobs do not execute the original operation
backend/controllers/job_queue.go:115-121
Restored jobs are reconstructed with:
Execute: func() error {
return nil
},Therefore, after a restart, an Add Task, Edit Task, Delete Task, sync operation, etc. is reported as successful without performing any operation. The PR description says jobs survive restarts, but the actual request payload and executable operation are not persisted.
This is a data-loss/incorrect-success bug: users can receive a successful job status while their requested task operation never occurs.
Fix: Persist enough typed job data to reconstruct and safely execute the operation, or change the design so only replayable command types and their validated payloads are stored. Do not restore arbitrary closures; Go function values cannot be serialized.
3. High — Persistent records are created before the job is actually queued
backend/controllers/job_queue.go:53-70
The database entry is written before sending to jobChannel. If the channel is full, AddJob blocks after persistence. If the process is terminated while blocked, the job remains persisted as pending even though it may not have entered the in-memory queue.
This is especially problematic because the restoration path cannot execute the original operation anyway, and the code has no explicit lifecycle/ownership model for these records.
Fix: Define and test the enqueue/persistence ordering and make state transitions reflect whether a job is actually accepted for execution. Also consider bounded queue behavior and request timeouts/backpressure.
4. Medium — Maintenance worker lifecycle is unmanaged
The worker is started but its returned handle is discarded. Consequently:
- it cannot be stopped during graceful shutdown;
- the bbolt database is never closed;
- the cron goroutine and database remain active until process termination.
Fix: Retain the worker and queue handles, install graceful shutdown handling, call MaintenanceWorker.Stop(), and close the persistent queue.
5. Medium — Invalid retention values are accepted
backend/utils/maintenance_worker.go:35-42
Any integer is accepted for CLEANUP_RETENTION_DAYS. A negative value makes the cutoff time lie in the future and can delete all completed/failed records. 0 also removes nearly all records older than the cleanup instant.
Fix: Reject values < 1 (or explicitly document and test an intended 0 policy), and return an error rather than silently using an unsafe value.
Testing gaps
The tests do not verify the core behavior:
- no test reopens the database and verifies that a restored job performs the requested operation;
- no test verifies pending → in-progress → completed/failed transitions;
- no test verifies that completed and failed jobs are actually removed by cleanup;
TestJobCleanupdoes not assert anything after callingCleanupOldJobs;- no test covers persistence failure or queue saturation.
The current passing CI does not validate the persistence feature’s correctness.
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
npx prettier --write .(for formatting)gofmt -w .(for Go backend)npm test(for JS/TS testing)Terminal Screenshot

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.