Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The new migration generates config ID 80, which already exists, causing a duplicate-key failure that blocks fresh PostgreSQL setup before the server starts.
1 open issue
What changed in this PR
Moves server housekeeping out of agent progress requests and into scheduled background jobs, using the existing job runner.
Changes:
- Adds configurable periodic scheduling and cleanup for agent statistics, zap entries, stale uploads, expired refresh tokens, and old job history.
- Corrects upload-expiration cleanup and reports deletion counts and per-step failures.
- Adds database migrations and tests for scheduling, cleanup, and interval validation.
| File | Description |
|---|---|
src/migrations/postgres/20261112120000_cleaning-interval-config.sql |
Adds the PostgreSQL cleaning interval setting. |
src/migrations/mysql/20261112120000_cleaning-interval-config.sql |
Adds the MySQL cleaning interval setting. |
src/inc/utils/RefreshTokenUtils.php |
Returns the number of expired tokens deleted. |
src/inc/utils/Lock.php |
Defines a periodic-scheduler lock. |
src/inc/utils/ConfigUtils.php |
Requires a positive cleaning interval. |
src/inc/Util.php |
Removes inline scheduling, returns cleanup counts, and corrects upload expiry handling. |
src/inc/templating/Statement.php |
Removes the obsolete cleaning constant registration. |
src/inc/jobs/PeriodicJobScheduler.php |
Schedules due jobs using persisted timestamps and unfinished-job checks. |
src/inc/jobs/PeriodicBackgroundJobHandler.php |
Defines the periodic job interface. |
src/inc/jobs/handlers/CleaningJob.php |
Runs housekeeping steps and prunes old job history. |
src/inc/jobs/BackgroundJobRegistry.php |
Registers cleaning and discovers periodic handlers. |
src/inc/defines/DConfig.php |
Defines and describes the cleaning interval setting. |
src/inc/defines/DCleaning.php |
Removes the obsolete cleanup timestamp constant. |
src/inc/defines/DBackgroundJobType.php |
Adds the cleaning job type. |
src/inc/cron.php |
Schedules periodic jobs before draining the queue. |
src/inc/apiv2/helper/ImportFileHelperAPI.php |
Deletes only the expired upload addressed by the request. |
src/inc/agentapi/model/SendProgressAction.php |
Stops running cleanup during progress reports. |
ci/phpunit/inc/jobs/PeriodicJobSchedulerTest.php |
Tests scheduling cadence and duplicate prevention. |
ci/phpunit/inc/jobs/CleaningJobTest.php |
Tests cleanup behavior and result reporting. |
ci/apiv2/test_config.py |
Tests rejection of a zero cleaning interval. |
ci/apiv2/test_backgroundjob.py |
Tests cron-driven cleaning and interval enforcement. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Added background cleaning for: