Skip to content

Feat: permenantly delete build_inputs for reaped builds - #9328

Closed
abishek003-tech wants to merge 1 commit into
concourse:masterfrom
abishek003-tech:master
Closed

abishek003-tech wants to merge 1 commit into
concourse:masterfrom
abishek003-tech:master

Conversation

@abishek003-tech

Copy link
Copy Markdown

Problem Overview
The build_resource_config_version_inputs table was growing indefinitely because:

Old build inputs weren't being cleaned up after builds were reaped
No garbage collection mechanism existed for this table
This caused performance degradation, especially in the /input_to API endpoint
Solution Implementation
We implemented a solution with three main components:

  1. Build Factory Interface Extension
    In atc/db/build_factory.go:

  2. Garbage Collector Implementation
    Created new file atc/gc/old_build_collector.go:

  3. Integration with GC System
    In command.go:

Key Features
90-Day Retention Policy: Builds are cleaned up 90 days after being marked as "reaped"
Cascading Deletion: Proper cleanup of related records in build_resource_config_version_inputs
Performance Monitoring: Added metrics to track cleanup duration and success
Integration: Works with existing GC framework running every 30s (default interval)
Metrics Added
In atc/metric/metrics.go:

Verification Steps
Database Cleanup:

Orphaned inputs should be removed
Table size should decrease
No builds older than 90 days post-reap
Performance:

/input_to API endpoint response time improved
GC runs verified in logs
Metrics showing successful cleanup
Data Integrity:

Cascade deletion working correctly
Required indexes in place
No orphaned records
How It Works
Every 30 seconds, the GC process runs
The OldBuildCollector identifies builds that were:
Marked as "reaped"
Reaped more than 90 days ago
These builds and their associated inputs are cleaned up
Metrics are emitted for monitoring
Testing
We provided a verification script (atc/scripts/verify_cleanup.sh) that:

Checks for orphaned inputs
Verifies retention window
Tests cascade deletion
Validates required indexes
Shows table statistics
Configuration
No additional configuration needed - works with existing GC settings:

Performance Impact
Reduced database size
Improved query performance
Minimal overhead during cleanup
No impact on running builds
Rollback Plan
If issues occur:

Remove the OldBuildCollector from GC components
Revert BuildFactory interface changes
Remove metrics collection

Claude Sonnet 3.5 • 1x

@taylorsilva

Copy link
Copy Markdown
Member

Thanks for the PR! This sounds awesome for those that are using Concourse at a large scale or just for a really long time.

I'm a bit backlogged right now but I will get around reviewing this probably end of Oct or early Nov. Thanks for your patience 🙏

Comment thread atc/atccmd/command.go

collectors := map[string]component.Runnable{
atc.ComponentCollectorBuilds: gc.NewBuildCollector(dbBuildFactory),
atc.ComponentCollectorOldBuilds: gc.NewOldBuildCollector(dbBuildFactory, 90*24*time.Hour), // 90 days

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Best we allow to customize this via env var

@taylorsilva taylorsilva left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hey, I had a moment to quickly skim this. I appreciate that you added some tests, but they don't use any of our existing test suites and therefore aren't run in our CI right now. It would be better if you could add tests to one or more of the existing test suites.

Tests at the following places would be great:

analytically's comment about making the reap time configurable should also be addressed.

This component should be behind a feature flag as well and off by default, similar to the automatic pipeline pausing feature. You can reference the PR that added that feature for how to do that: #7876

Overall, I think your PR is heading in the right direction. Adding a new component is what I would have done too. I'm happy to answer any questions you have. Feel free to message on discord as well in the #dev channel.


Ah, just saw this at the end of your PR description:

Claude Sonnet 3.5 • 1x

Thanks for the transparency. Explains the weird test setup.

@taylorsilva taylorsilva changed the title Concourse DB Feat: permenantly delete build_inputs for reaped builds Nov 17, 2025
@taylorsilva taylorsilva moved this from Todo to Waiting on Contributor in Pull Requests Nov 25, 2025
@taylorsilva

taylorsilva commented Dec 2, 2025 •

Copy link
Copy Markdown
Member

@abishek003-tech Do you have any intention to follow up on this PR? Totally fine if not.

@taylorsilva

Copy link
Copy Markdown
Member

No response from OP. Feel free to ask to re-open this PR, or you can submit a new one.

@taylorsilva taylorsilva closed this Jan 2, 2026
@github-project-automation github-project-automation Bot moved this from Waiting on Contributor to Done in Pull Requests Jan 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants