Skip to content

Pinned resources that aren't build triggers are never re-checked once they have history (regression since 8.2.0 / #9492) #9646

Closed

Description

@fbehrens51

Summary

Pinned resources that aren't build triggers are never re-checked once they have history (regression since 8.2.0 / #9492)

Summary

Since v8.2.0 (#9492, "Smarter resource checking - Only check triggering resources"), Lidar stops scanning any resource that is not a build trigger, once that resource has at least one successfully-checked version. This is fine for normal get-only resources, but it breaks pinned resources (version: {path: ...} / version: {ref: ...} etc. in the pipeline config) whose underlying artifact is published by a system outside Concourse: updating the pin to a newly-published version now fails with pinned version ... not found, even though the artifact genuinely exists, because Concourse's DB was never told to look for it.

Environment

  • Concourse: 8.2.4 (also reproduces on 8.2.0–8.2.3)
  • Confirmed absent on 8.1.0 — atc/db/check_factory.go's Resources() query in 8.1.0 includes any resource that's an input to any job, regardless of trigger:. This is exactly the query Smarter resource checking - Only check triggering resources #9492 changed.
  • Resource type: s3 (concourse/s3-resource), but the bug is in ATC core, not the resource type — confirmed the check/versions code is byte-identical between the s3 versions bundled with 7.14.3 (v2.4.0) and 8.2.4 (v2.5.4).

Root cause

atc/scheduler/algorithm/pinned_resolver.go's Resolve() resolves a pin via VersionsDB.FindVersionOfResource, which is a pure SQL lookup against resource_config_versions — it never live-checks the resource's source:

version, found, err := r.vdb.FindVersionOfResource(ctx, r.inputConfig.ResourceID, r.inputConfig.PinnedVersion)
...
if !found {
    return nil, db.PinnedVersionNotFound{PinnedVersion: r.inputConfig.PinnedVersion}.String(), nil
}

So a pin can only resolve if some check has already discovered and recorded that exact version.

Since #9492, checkFactory.Resources() (atc/db/check_factory.go) only includes a resource in Lidar's scan set if one of:

  1. it's a triggering input to some job (bool_or(trigger) = true, excluding passed:-constrained inputs), or
  2. it has never been successfully checked, or
  3. it's a non-triggering input with zero versions in resource_config_versions.

A resource that is (a) not a trigger, (b) already has a working pinned history, and (c) gets a new externally-published version pinned in config, satisfies none of these. It's permanently excluded from Lidar's rotation, so the new pin's version is never discovered, and pinnedResolver fails with "not found" — indefinitely, until someone manually runs fly check-resource -f <version>.

Workarounds we're aware of

  • fly check-resource -r <pipeline>/<resource> -f path:<value> immediately after set-pipeline — works, but requires remembering to script it for every pin change, on every resource whose pin changed.
  • webhook_token on the resource — requires external plumbing to call the webhook after publishing each artifact.
  • trigger: true — works, but has broader semantics: it turns the resource into an active build trigger, which for pipelines using a single dedicated "trigger" resource to drive a serial passed: chain (a common pattern) is an unwanted behavior change for every other pinned resource.
  • Holding off on upgrading past 8.1.x for now — avoids the regression entirely (confirmed above), at the cost of missing 8.2.x's fixes, including two CVEs (a containerd privilege-escalation fix in 8.2.2 and an open-redirect fix in 8.2.3). This is what we've done in the meantime.

Proposed fix

Extend the third condition in checkFactory.Resources() from "non-triggering input resources with no versions in history" to "non-triggering input resources whose currently pinned version (if any) is not present in history." That directly targets the gap without reintroducing checks for every non-triggering resource (which is what #9492 was trying to avoid).

I have a fix implemented along these lines, with test coverage, here: https://github.com/fbehrens51/concourse/tree/fix/pinned-resource-lidar-check. Happy to open a PR against this if it looks like the right direction.

Note: this fix passes the full atc/db test suite (including a regression test confirmed to fail without it and pass with it), but hasn't yet been deployed and observed handling a real pinned-resource update end-to-end.

Steps to Reproduce

  1. Pipeline has a resource pinned via version: {path: "artifact/artifact-1.0.0.zip"}, consumed only via a plain (non-trigger) get, and it's already been successfully checked at least once (so it has existing rows in resource_config_versions).
  2. Something outside Concourse uploads artifact/artifact-1.0.1.zip to the bucket.
  3. Update the pipeline config's pin to artifact/artifact-1.0.1.zip and set-pipeline.
  4. Any job that gets this resource fails at "Preparing build" / "not found" for the pinned version — indefinitely — even though the object is confirmed to exist in the bucket.

Expected Results

Either:

  • Lidar continues to check pinned, non-triggering resources when the currently configured pin isn't yet present in resource_config_versions (a natural extension of the existing "no versions in history" fallback condition in the Resources() query — the resource does have history, just not the newly pinned version), or
  • pinnedResolver falls back to an on-demand check when FindVersionOfResource misses, instead of failing immediately.

Actual Results

The resource is silently dropped from all future automatic checking, and pin updates fail permanently without manual intervention.

Web Node(s) configuration

No response

Worker(s) configuration

No response

Concourse Version

= 8.2.4

Browser (if applicable)

No response

Did this use to work?

prior to 8.2.x, yes

Activity

  1. added this to the v8.3.0 milestone on Jul 20, 2026
  2. taylorsilva commented on Jul 20, 2026

    @taylorsilva
    Member

    Thanks for the report. Looked at the diff on your fork. I'd need to do some performance testing on the query before deciding that is the route to take.

    I'll reproduce and see what solutions seems viable. I've added this to the next release milestone since I want to fix as many regressions as I can from the scheduling change I made in 8.2.

  3. moved this from Icebox to In progress in Concourse Roadmapon Jul 20, 2026
  4. fbehrens51 commented on Jul 20, 2026

    @fbehrens51
    Author

    Thanks for the update — Let me know if you need anything from me.

  5. taylorsilva commented on Jul 22, 2026

    @taylorsilva
    Member

    Took a different route and refactored the scheduler code to instead take into consideration pinned resources. Mostly meant deleting a bunch of code, so yay!

  6. taylorsilva commented on Jul 22, 2026

    @taylorsilva
    Member

    Realized my change didn't cover the case for automatically triggered builds! I think the query modification you've suggested is going to be the best way to resolve this.

    Just did some EXPLAIN ANALYZE on the query in question to see if there was any impact on performance:

    rows, err := resourcesQuery.
    LeftJoin("(SELECT resource_id, bool_or(trigger) AS trigger FROM job_inputs WHERE passed_job_id IS NULL GROUP BY resource_id) ji ON ji.resource_id = r.id").
    Where(sq.And{
    sq.Eq{"p.paused": false},
    }).
    Where(sq.Or{
    sq.And{
    // find all resources that are triggering inputs to jobs
    sq.Eq{"ji.trigger": true},
    },
    sq.And{
    // find resources that have errored or never been checked
    sq.Or{
    sq.Eq{"rs.last_check_build_id": nil},
    sq.Eq{"rs.last_check_succeeded": false},
    },
    // that are put-only or non-triggering resources
    sq.Or{
    sq.Eq{"ji.resource_id": nil},
    sq.Eq{"ji.trigger": false},
    },
    },
    sq.And{
    // find non-triggering input resources that have no versions in
    // their version history
    sq.Eq{"ji.trigger": false},
    sq.Expr(`NOT EXISTS (SELECT 1
    FROM resource_config_versions rcv
    WHERE rcv.resource_config_scope_id = r.resource_config_scope_id
    )`),
    },
    }).
    OrderBy("r.id ASC").

    Current query:

    Planning Time: 1.273 ms
    Execution Time: 17.694 ms
    

    With new filter for resource pins:

    Planning Time: 1.336 ms
    Execution Time: 17.180 ms
    

    Looks like no impact on the run time of the query. I ran this against the db backing https://ci.concourse-ci.org/

    I'll make a PR merging in your changes and some of the stuff I changed as well. Ended up fixing up some tests while exploring the problem space.

  7. moved this from In progress to Done in Concourse Roadmapon Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions