feat: add scheduled workflow history cleaner#1122
Open
youngxpepp wants to merge 1 commit into
Open
Conversation
Adds WorkflowHistoryCleaner, a Spring @scheduled component that periodically deletes terminal workflows older than the configured retention threshold. The batch pages over candidates with IndexDAO#searchArchivableWorkflows and delegates the actual removal to ExecutionDAOFacade#removeWorkflow, so it reuses the existing execution-store / index ordering guarantees. Single-instance execution is enforced through the pluggable com.netflix.conductor.core.sync.Lock abstraction with non-blocking tryLock semantics. Cooperative shutdown is handled via LifecycleAwareComponent. The component is disabled by default; opt in with conductor.workflow-history-cleanup.enabled=true. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Author
|
@akhilpathivada Could you take a look when you get a chance? This PR addresses #1081 — based on your earlier comment on the issue, I'd appreciate your review on the initial scope (global TTL only; field-value-based retention left as a follow-up). |
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.
Summary
Closes #1081.
Adds
WorkflowHistoryCleaner, a Spring@Scheduledcomponent that periodically deletes terminal workflows (COMPLETED/FAILED/TERMINATED/TIMED_OUT) older than the configured retention threshold.IndexDAO#searchArchivableWorkflowsand delegates the actual removal toExecutionDAOFacade#removeWorkflow, reusing the existing execution-store / index ordering guarantees.com.netflix.conductor.core.sync.Lockabstraction with non-blockingtryLocksemantics — contenders exit immediately instead of queueing on the lock.LifecycleAwareComponent: any in-flight run checksisRunning()between iterations and at workflow boundaries.conductor.workflow-history-cleanup.enabled=true.Rolling indices (
conductor_task_log_*,conductor_event_*,conductor_message_*) are out of scope — manage their retention through index-level lifecycle policies (e.g. OpenSearch ISM).Key Properties
conductor.workflow-history-cleanup.enabledfalseconductor.workflow-history-cleanup.cron0 0 * * * *conductor.workflow-history-cleanup.zoneUTCconductor.workflow-history-cleanup.retention-days30conductor.workflow-history-cleanup.catch-up-days7conductor.workflow-history-cleanup.max-iterations-per-day200conductor.workflow-history-cleanup.processed-cache-size5000conductor.workflow-history-cleanup.batch-pause500msconductor.workflow-history-cleanup.index-refresh-wait2sconductor.workflow-history-cleanup.lock-idworkflow-history-cleanupconductor.workflow-history-cleanup.lock-lease-time2hconductor.workflow-history-cleanup.workflow-index-nameindex-prefix)SchedulerConfigurationthread pool size bumped from 3 to 4 to accommodate the new scheduled job.Test plan
./gradlew :conductor-core:test— 18 new test cases inTestWorkflowHistoryCleanercover lock contention, async index-delete lag, mid-run shutdown, exception handling, iteration caps, and null-result edge cases../gradlew :conductor-core:spotlessCheck./gradlew :conductor-core:compileJava :conductor-core:compileTestJava🤖 Generated with Claude Code