Skip to content

Jobs getting stuck at preparing build #2010

Closed

Description

@pn-santos

Bug Report

For the last couple of days we've been having a strange issue. Sporadically Concourse seems to be getting stuck at the "preparing build" step, all the pre-requisitives show a ✔️ next to them (so nothing is actually pending as far as we can see) however the job stays stuck forever in that state.

When this starts happening, it affects all jobs in all teams. Fly watch of the pending jobs also hangs and shows no output. I haven't been able to narrow down exactly what fixes it, one time it was retiring+reseting one of the workers. Another time that wasn't enough and I had to delete+recreate the pipeline with the stuck job.

The only error messages I could see in the logs were these (logged when one of the workers was reset):

{"timestamp":"1517591651.263898134","source":"atc","message":"atc.create-job-build.trigger-immediately.try-start-next-pending-build.scan.failed-to-create-container-in-db","log_level":2,"data":{"build-id":8663,"build-name":"70","error":"pq: insert or update on table \"worker_resource_config_check_sessions\" violates foreign key constraint \"worker_resource_config_check__resource_config_check_sessio_fkey\"","input":"npm-debian-image","job_name":"test-mailer-master","resource":"npm-debian-image","session":"48972.1.1.2"}}
{"timestamp":"1517591651.263942957","source":"atc","message":"atc.create-job-build.trigger-immediately.try-start-next-pending-build.scan.failed-to-initialize-new-container","log_level":2,"data":{"build-id":8663,"build-name":"70","error":"pq: insert or update on table \"worker_resource_config_check_sessions\" violates foreign key constraint \"worker_resource_config_check__resource_config_check_sessio_fkey\"","input":"npm-debian-image","job_name":"test-mailer-master","resource":"npm-debian-image","session":"48972.1.1.2"}}
{"timestamp":"1517591651.265183210","source":"atc","message":"atc.create-job-build.trigger-immediately.failed-to-start-next-pending-build-for-job","log_level":2,"data":{"error":"pq: insert or update on table \"worker_resource_config_check_sessions\" violates foreign key constraint \"worker_resource_config_check__resource_config_check_sessio_fkey\"","job-name":"test-mailer-master","job_name":"test-mailer-master","session":"48972.1"}}

(the above was printed for multiple jobs, above are just the logs for one of the jobs)

We also see the messages below quite frequently on a regular basis (but since they also show up when everything is running normally I'm not sure they are relevant):

{"timestamp":"1518004152.986703157","source":"atc","message":"atc.volume-collector.run.orphaned-volumes.mark-created-as-destroying.failed-to-transition","log_level":2,"data":{"error":"volume cannot be destroyed as children are present","session":"62.13706.1.43","volume":"69b59425-83cd-4511-4a7f-f0a011c0b697","worker":"ccn4"}}

The following can also be handy:

  • Concourse version: 3.8.0
  • Deployment type: binary
  • Infrastructure/IaaS: Running on VMs (Debian 8.10 OS with 4.9.0-0.bpo.3-amd64 kernel)

Activity

  1. brownjohnf commented on Apr 13, 2018

    @brownjohnf

    I believe we're also experiencing this, but on concourse 3.10.0.

  2. gojihotsauce commented on Apr 24, 2018

    @gojihotsauce

    I can confirm this is happening on 3.11.0 as well.

  3. pn-santos commented on Apr 30, 2018

    @pn-santos
    Author

    We just had this happen again with 3.12 still... not sure if it can be a clue or it's just a fly issue but after aborting a pending build this is what fly showed when listing builds:

    6      aborted    n/a                       2018-04-30@10:44:04+0100  423633h44m4s
    

    (this is the build that was stuck in pending state) the duration is very strange as it was pending for less than 10min until I aborted it...

  4. dpb587 commented on May 2, 2018

    @dpb587
    Contributor

    Also been seeing this for a while, including on 3.13.0. I'm only noticing it happen on resources which are shared across many pipelines (e.g. 15+ pipelines). I assume it's some sort of scheduling race, as I've noticed it when 1) concourse is restarted, and 2) occasionally when a new pipeline is created. It does seem to resolve itself eventually, but when the check interval is longer, that can take a while and this is more noticeable.

  5. pn-santos commented on May 9, 2018

    @pn-santos
    Author

    I can confirm that the cause seems to be what @dpb587 suggested. We have several resources shared (i.e. with the exact same configs) across multiple pipelines, and whenever this happens, the jobs in question (stuck with pending) have at least one of those shared resources as input.

    Also I tried doing a check-resource on those resources when the jobs get stuck and there is always at least one resource where the check-resource fly command just hangs, never returning a response (all other input resource return immediately with success).

    A restart of the ATC seems to fix the issue and all stuck jobs will resume their builds.

    The resource where I've been able to confirm this behavior are git resource.

  6. akamalov commented on Jul 12, 2018

    @akamalov

    Concourse 3.14.0 and having the same issue

  7. colmtuohy commented on Jul 12, 2018

    @colmtuohy

    Can confirm we also see this on 3.13.0 also, making the system unusable. Downgrading again to 3.9.2 as a result, as it did not seem as bad then. 3 atcs, 18 workers, apx 1000 pipelines, 600unpaused,

  8. romankartgh commented on Jul 28, 2018

    @romankartgh
    Contributor

    We ran into the same issue:

    • 3.14.1
    • pipeline stuck at pending state
    • resource shows
      pq: insert or update on table "worker_resource_config_check_sessions" violates foreign key constraint "worker_resource_config_check__resource_config_check_sessio_fkey"

    We have 100+ pipelines. I strongly believe it started happening for us when git resource became unavailable because Gerrit went down. Concourse really fell on its face - not only it wasn't showing any meaningful error messages, there seems to be a possible race condition (see above)

  9. akamalov commented on Jul 28, 2018

    @akamalov

    I just had one yesterday. I immediately re-ran the job and it went through. I think it has something to do with job locking or some sort.

  10. vito commented on Aug 1, 2018

    @vito
    Contributor

    I found a theoretical cause for this. The radar creates a resource config check session but then goes in to a loop to acquire a checking lock, which could take some time if there's already an expensive check running concurrently. It then tries to create the worker resource config check session, and that can fail if the resource config check session expired in the time it took to acquire the lock.

    That's a lot of words, but I think we could fix it by moving the find-or-create of the resource config into the lock acquisition loop: https://github.com/concourse/atc/blob/4b1839fd867a3cf306fde63894a4f9efaa33fbf1/radar/resource_scanner.go#L138-L158

    This should only happen with manually-triggered builds, so there may be some other cases that trigger this error, too. It's a fundamental problem of creating the RCCS and WRCCS in separate transactions. I'm kind of hoping a lot of this just gets cleaned up as part of #2386.

  11. vito commented on Aug 22, 2018

    @vito
    Contributor
  12. munju commented on Aug 29, 2018

    @munju

    I happened again... here is the dump:
    dump.txt

  13. 2 remaining items

  14. clarafu commented on Dec 17, 2018

    @clarafu
    Contributor

    This issue was fixed along with #1598, with the fix being to remove the worker resource config check sessions table and merge it with the resource config check sessions table. If you want to read more on the fix you can do so here commit. Another issue was found which was related is #2911 where the resource configs were being gced before they were used. This issue was fixed with a commit that creates and uses the resource configs within one transaction.

  15. evanchaoli commented on Jan 15, 2019

    @evanchaoli
    Contributor

    @clarafu When this fix will be released? We still see this issue in 4.2.2.

  16. added this to the v5.0.0 milestone on Jan 15, 2019
  17. vito commented on Jan 15, 2019

    @vito
    Contributor
  18. added
    release/documented
    on Jan 21, 2019
  19. tanner-bruce commented on Apr 23, 2019

    @tanner-bruce

    @vito @clarafu I am still seeing this in 5.0.0, 5.0.1 and 5.1.0.

    concourse-concursed-web-7c9b746fb4-r7xs4 concourse-concursed-web {"timestamp":"2019-04-23T19:01:16.919870803Z","level":"error","source":"atc","message":"atc.collector.tick.volume-collector.mark-volumes.mark-created-as-destroying.failed-to-transition","data":{"error":"volume cannot be destroyed as children are present","session":"23.137.9.2.4","volume":"69fa08a3-c97e-49ef-5d33-884b6f823a57","worker":"concourse-concursed-worker-2"}}
    

    Here is my stackdump: https://gist.github.com/tanner-bruce/e410118ea9710bd9670f9e920221b27d

  20. vlad-ro commented on Apr 29, 2019

    @vlad-ro

    Seeing this as well:

    {
        "timestamp": "2019-04-29T12:56:17.482867576Z",
        "level": "error",
        "source": "atc",
        "message": "atc.collector.tick.volume-collector.mark-volumes.mark-created-as-destroying.failed-to-transition",
        "data": {
            "error": "volume cannot be destroyed as children are present",
            "session": "21.30613.10.2.2",
            "volume": "fec219c8-9380-4d34-67d9-55989151e322",
            "worker": "0b2dc3e69de8"
        }
    }
  21. vito commented on May 13, 2019

    @vito
    Contributor

    @tanner-bruce @vlad-ro That log line is a red herring: #1780

  22. DanielJonesEB commented on May 18, 2019

    @DanielJonesEB

    I'm seeing this in 5.1.0, both BOSH-deployed with Control Tower and via the Helm chart with a customer.

    I've had one build sat pending for 40 minutes now:
    Screenshot 2019-05-18 at 08 10 19

    $ fleb workers
    name                                  containers  platform  tags  team  state    version
    c228046e-4e80-4ceb-b786-757fd16c2d27  81          linux     none  none  running  2.1
    c3038858-62e7-4153-a135-975e6eb7c6e7  106         linux     none  none  running  2.1
    

    All bar 8 of the containers are check containers. Web node (AWS t2.large) seems happy: load average: 0.53, 0.52, 0.55. concourse process is spiking up to about 61% CPU. 39 pipelines, a couple of teams, but only one with any pipelines. monit restart all on the web node didn't seem to help, so presumably it's being caused by something in persisted state. Cancelling the build and triggering another one (albeit after the web process restart) got things flowing again.

    I can't see anything obviously wrong in the logs. Any suggestions of what to look for?

  23. tanner-bruce commented on May 21, 2019

    @tanner-bruce

    @vito that log line may be a red herring for sure however I am having the same symptoms as this issue states.

    • my builds are getting stuck with full check marks
    • restarting ATC's gets them going again
    • logs are full of red herring line

    The stack dump I provided is of a cluster stuck in this state. Should I open a new ticket describing what is happening?

  24. DanielJonesEB commented on May 21, 2019

    @DanielJonesEB

    Happening again on a different pipeline that I'm trying to iterate on. Build was pending for about seven hours. Aborting the build through the UI doesn't work, but fly abort-build seems to be reflected in the UI after some time.

    Something that did help:

    • restart web VM
    • abort build in UI
    • no change in UI
    • come back to this tab to say restarting VM didn't help
    • a few minutes later notice the build was aborted (turned brown in the UI, had "loading" for build details)
    • triggered through the UI, and it scheduled normally
  25. vito commented on May 28, 2019

    @vito
    Contributor

    @tanner-bruce Yeah, please open new issues with stack dumps - comments on closed issues (especially issues like this which are very broadly defined but had a specific resolution) are hard to keep track of and prioritise.

    FWIW #3928 may help but I can't really confirm whether it's the root cause for the hanging in your case.

  26. u2g-tg commented on Jul 16, 2019

    @u2g-tg

    I just received these symptoms with 5.1.0, after a manual trigger, then resolving an absent lock for the pool resource. All build pre-steps were ticked, but it didn't transition out of pending.

    A restart of the web node caused the job to start working without having to abort it.

  27. yermulnik commented on Aug 14, 2020

    @yermulnik

    Unpausing unpuased stuck in pending state job helped me as per this post #2010 (comment)

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

    bugneeds-investigationrelease/documented

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions