Skip to content

Performance and database issues #2111

Closed

Description

@aleliaert

Hi,

We're having concourse jobs stuck in pending state for a very long time, all while seeing lots of slow queries on our postgres server. Also seeing resources being slow to trigger, sometimes taking hours, even when check_every not set (defaulting to 1m). When things get really bad, the list of jobs on the left in the GUI is not updated.

The first time this happened, we got some relief by reducing amount of logs being retained via build_logs_to_retain for a job on a 3m timer.

The problem recently struck again and we found another job that needed the build_logs_to_retain treatment. However, once addressed, we still the pending state and slow triggers. Also seeing the job run but it take minutes for tasks to get going.

Clues in database:

  • Several instances of query REFRESH MATERIALIZED VIEW CONCURRENTLY latest_completed_builds_per_job are often running in parallel. Nominally taking a few seconds when things seem fine, often minutes or over an hour when experiencing aforementioned issues.
  • Load average on database often 30-40, with 8 cores at hand.
  • Usually seeing 40-50 active connections into database, sometimes over 100 reported, from concourse
  • Table concourseinfrastructureprod.builds went from 20000+ down to 4000 when we most recently removed/refactored a job with excessive build logs retained.

Other details:

  • Concourse version: 3.8.0
  • Deployment type: BOSH
  • Infrastructure/IaaS: Openstack
  • Browser (if applicable): Chrome
  • Database - Postgres 9.5, 8 core CPU, no significant io wait
  • 5 workers
  • Concourse web and worker VMs all sized reasonably to our knowledge (low cpu/load)
  • Did this used to work? - Yes

Please help the Concourse fans on my team keep using Concourse, so that mgmt doesn't force us on to Jenkins. :)

Thanks!

Aaron

Activity

  1. timrchavez commented on Mar 24, 2018

    @timrchavez
    Contributor

    Are you using btrfs or overlay (the current default) for your filesystem driver?

  2. aleliaert commented on Mar 24, 2018

    @aleliaert
    Author

    @timrchavez - Default overlay filesystem driver is being used to my knowledge. We're deploying via concourse-deployment with just a small set of ops files to change scale, get https, and use an externalized postgres. Is there a good clue in our interpolated bosh manifest which shows which one? I don't see btrfs or overlay in the manifest.

    On the database front, I did some more postgres sleuthing and noticed that the jobs table has lots of tuples relative to rows. Perhaps there is a garbage collection issue inside the database? We tried vaccuming tables but maybe we need a steam cleaner?

    SELECT schemaname,
           relname,
           n_live_tup 
      FROM pg_stat_user_tables 
     WHERE schemaname = 'concourseinfrastructureprod'
     ORDER BY n_live_tup DESC;
    
             schemaname          |                relname                | n_live_tup 
    -----------------------------+---------------------------------------+------------
     concourseinfrastructureprod | jobs                                  |     545402
     concourseinfrastructureprod | pipeline_build_events_108             |     281912
     concourseinfrastructureprod | pipeline_build_events_159             |     101687
     concourseinfrastructureprod | pipeline_build_events_127             |      92841
     concourseinfrastructureprod | versioned_resources                   |      67696
     concourseinfrastructureprod | pipeline_build_events_178             |      36423
     concourseinfrastructureprod | pipeline_build_events_132             |      26730
     <snip...>
    

    Then...

    select count(1) from jobs;
     count 
    -------
       212
    (1 row)
    

    It sounds like tuples should normally be close to rows?

  3. phillbaker commented on Mar 26, 2018

    @phillbaker
    Contributor

    This also looks similar to #1298.

  4. troykinsella commented on Mar 27, 2018

    @troykinsella
    Contributor

    Default overlay filesystem driver

    The naive driver is the default (for binaries, at least - I know nothing about bosh), which has poor performance. Perhaps you need to explicitly set overlay or btrfs.

  5. aleliaert commented on Apr 12, 2018

    @aleliaert
    Author

    Update - our friends at Crunchy Data helped us discover that a long-running query/transaction within another schema on the same database was causing our issue. This query was keeping auto vacuum from cleaning up dead rows across all schemas, including our concourse schema. Dead rows can cause major performance problems evidently.

    It was a good lesson for us on what the blast radius can be between schemas within the same database. Monitoring is being added to catch both long-running transactions and accumulation of dead tuples.

    For reference, the query we ran to find the guilty query (will show itself in output):

    select *, now() - xact_start as txn_runtime from pg_stat_activity 
    where state != 'idle' order by xact_start;
    

    Thanks for the replies and suggestions on how to go after this. Happy Concoursing!

  6. keithkroeger commented on Mar 22, 2019

    @keithkroeger

    We are also seeing a similar problem in our 3.13 environment.

    Once you found the queries, did you kill the sessions or take some other approach?

  7. aleliaert commented on Mar 22, 2019

    @aleliaert
    Author
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions